Skip to content

Commit

Permalink
Add in output samplerate (#27)
Browse files Browse the repository at this point in the history
* add in output samplerate
  • Loading branch information
armandobelardo authored Nov 30, 2023
1 parent 46c8a9a commit 65e41fc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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)

0 comments on commit 65e41fc

Please sign in to comment.