diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2015-06-21 13:24:24 +0200 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2015-07-01 15:32:00 +0200 |
| commit | 2dc760120b06ced36b407a0e6cf1c6c605bf60ef (patch) | |
| tree | badf87f29845aa1233a14be3a89c1fe0346d5ff9 | |
| parent | 8761c1616fa05d9ba6a7e1ab9bdab117dff18c13 (diff) | |
playrec: Rename input_channels, input_dtype -> channels, dtype
| -rw-r--r-- | README.rst | 2 | ||||
| -rw-r--r-- | sounddevice.py | 22 |
2 files changed, 13 insertions, 11 deletions
@@ -151,7 +151,7 @@ Simultaneous Playback and Recording To play back an array and record at the same time, use `sounddevice.playrec()`: ->>> myrecording2 = sd.playrec(myarray, fs, input_channels=2) +>>> myrecording2 = sd.playrec(myarray, fs, channels=2) The number of output channels is obtained from ``myarray``, but the number of input channels still has to be specified. diff --git a/sounddevice.py b/sounddevice.py index 87c2e72..27d1471 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -357,7 +357,7 @@ def rec(frames=None, samplerate=None, channels=None, dtype=None, return ctx.out -def playrec(data, samplerate=None, input_channels=None, input_dtype=None, +def playrec(data, samplerate=None, channels=None, dtype=None, out=None, input_mapping=None, output_mapping=None, blocking=False, **kwargs): """Simultaneous playback and recording. @@ -366,12 +366,14 @@ def playrec(data, samplerate=None, input_channels=None, input_dtype=None, ---------- data : array_like Audio data to be played back. See :func:`play`. - input_channels : int, sometimes optional - See the parameter `channels` of :func:`rec`. - input_dtype : str or numpy.dtype, optional - See the parameter `dtype` of :func:`rec`. - If `input_dtype` is not specified, it is taken from `data.dtype` + channels : int, sometimes optional + Number of input channels, see :func:`rec`. + The number of output channels is obtained from `data.shape`. + dtype : str or numpy.dtype, optional + Input data type, see :func:`rec`. + If `dtype` is not specified, it is taken from `data.dtype` (i.e. :attr:`default.dtype` is ignored). + The output data type is obtained from `data.dtype` anyway. input_mapping, output_mapping : array_like, optional See the parameter `mapping` of :func:`rec` and :func:`play`, respectively. @@ -402,10 +404,10 @@ def playrec(data, samplerate=None, input_channels=None, input_dtype=None, """ ctx = _CallbackContext() output_frames = ctx.check_data(data, output_mapping) - if input_dtype is None: - input_dtype = data.dtype # ignore module defaults - input_frames = ctx.check_out(out, output_frames, input_channels, - input_dtype, input_mapping) + if dtype is None: + dtype = data.dtype # ignore module defaults + input_frames = ctx.check_out(out, output_frames, channels, dtype, + input_mapping) if input_frames != output_frames: raise PortAudioError("len(data) != len(out)") ctx.frames = input_frames |
