mirror of
https://github.com/larsimmisch/pyalsaaudio.git
synced 2026-06-01 10:57:01 +00:00
Support all essential parameters in alsapcm_new.
This commit is contained in:
+12
-7
@@ -423,11 +423,16 @@ alsapcm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
char *card = NULL;
|
||||
int cardidx = -1;
|
||||
char hw_device[128];
|
||||
char *kw[] = { "type", "mode", "device", "cardindex", "card", NULL };
|
||||
int rate = 44100;
|
||||
int channels = 2;
|
||||
int format = SND_PCM_FORMAT_S16_LE;
|
||||
int periodsize = 32;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oisiz", kw,
|
||||
char *kw[] = { "type", "mode", "device", "cardindex", "card", "rate", "channels", "format", "periodsize", NULL };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oisiziiii", kw,
|
||||
&pcmtypeobj, &pcmmode, &device,
|
||||
&cardidx, &card))
|
||||
&cardidx, &card, &rate, &channels, &format, &periodsize))
|
||||
return NULL;
|
||||
|
||||
if (cardidx >= 0) {
|
||||
@@ -471,10 +476,10 @@ alsapcm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
self->handle = 0;
|
||||
self->pcmtype = pcmtype;
|
||||
self->pcmmode = pcmmode;
|
||||
self->channels = 2;
|
||||
self->rate = 44100;
|
||||
self->format = SND_PCM_FORMAT_S16_LE;
|
||||
self->periodsize = 32;
|
||||
self->channels = channels;
|
||||
self->rate = rate;
|
||||
self->format = format;
|
||||
self->periodsize = periodsize;
|
||||
|
||||
res = snd_pcm_open(&(self->handle), device, self->pcmtype,
|
||||
self->pcmmode);
|
||||
|
||||
@@ -108,7 +108,7 @@ PCM objects in :mod:`alsaaudio` can play or capture (record) PCM
|
||||
sound through speakers or a microphone. The PCM constructor takes the
|
||||
following arguments:
|
||||
|
||||
.. class:: PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, device='default', cardindex=-1)
|
||||
.. class:: PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, rate=44100, channels=2, format=PCM_FORMAT_S16_LE, periodsize=32, device='default', cardindex=-1)
|
||||
|
||||
This class is used to represent a PCM device (either for playback and
|
||||
recording). The arguments are:
|
||||
@@ -117,6 +117,10 @@ following arguments:
|
||||
(default).
|
||||
* *mode* - can be either :const:`PCM_NONBLOCK`, or :const:`PCM_NORMAL`
|
||||
(default).
|
||||
* *rate* - the sampling rate. The default value is 44100.
|
||||
* *channels* - the number of channels. The default value is 2 (stereo).
|
||||
* *format* - the data format. The default value is :const:`PCM_FORMAT_S16_LE`,
|
||||
* *periodsize - the period size. The default value is 32. Each write should consist of *periodsize* frames.
|
||||
* *device* - the name of the PCM device that should be used (for example
|
||||
a value from the output of :func:`pcms`). The default value is
|
||||
``'default'``.
|
||||
@@ -125,12 +129,11 @@ following arguments:
|
||||
the `device` keyword argument is ignored.
|
||||
``0`` is the first hardware sound card.
|
||||
|
||||
This will construct a PCM object with these default settings:
|
||||
This will construct a PCM object with the given settings.
|
||||
|
||||
* Sample format: :const:`PCM_FORMAT_S16_LE`
|
||||
* Rate: 44100 Hz
|
||||
* Channels: 2
|
||||
* Period size: 32 frames
|
||||
*Changed in 0.9:*
|
||||
|
||||
- Added optional arguments `rate`, `channels`, `format` and `periodsize`.
|
||||
|
||||
*Changed in 0.8:*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user