Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in output samplerate #27

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lameenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static PyObject* setBitRate(EncoderObject* self, PyObject* args)
}

/**
* Set the sample rate
* Set the input sample rate
*/
static PyObject* setInSampleRate(EncoderObject* self, PyObject* args)
{
Expand All @@ -139,6 +139,27 @@ static PyObject* setInSampleRate(EncoderObject* self, PyObject* args)
Py_RETURN_NONE;
}

/**
* Set the output sample rate
*/
static PyObject* setOutSampleRate(EncoderObject* self, PyObject* args)
{
int outsamplerate;

if (!PyArg_ParseTuple(args, "i", &outsamplerate))
{
return NULL;
}

if (lame_set_out_samplerate(self->lame, outsamplerate) < 0)
{
PyErr_SetString(PyExc_RuntimeError, "Unable to set the output sample rate");
return NULL;
}

Py_RETURN_NONE;
}

/**
* Set the number of channels for the encoder
*/
Expand Down Expand Up @@ -334,6 +355,7 @@ static PyMethodDef Encoder_methods[] = {
{ "set_quality", (PyCFunction) &setQuality, METH_VARARGS, "Set the encoder quality, 2 is highest; 7 is fastest." },
{ "set_bit_rate", (PyCFunction) &setBitRate, METH_VARARGS, "Set the constant bit rate" },
{ "set_in_sample_rate", (PyCFunction) &setInSampleRate, METH_VARARGS, "Set the input sample rate" },
{ "set_out_sample_rate", (PyCFunction) &setOutSampleRate, METH_VARARGS, "Set the output sample rate" },
{ "encode", (PyCFunction) &encode, METH_VARARGS, "Encode a block of PCM data, little-endian interleaved." },
{ "flush", (PyCFunction) &flush, METH_NOARGS, "Flush the last block of MP3 data" },
{ "silence", (PyCFunction) &silence, METH_NOARGS, "Silence the stdout from LAME" },
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
configuration['setup_requires'] = ['setuptools-git-versioning']
configuration['setuptools_git_versioning'] = {
'enabled': True,
'starting_version': '1.6.3'
'starting_version': '1.7.0'
}
else:
configuration['version'] = '1.6.3'
configuration['version'] = '1.7.0'

# Create the package
setuptools.setup(**configuration)
Loading