Skip to content

Commit 2dc7601

Browse files
committed
playrec: Rename input_channels, input_dtype -> channels, dtype
1 parent 8761c16 commit 2dc7601

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Simultaneous Playback and Recording
151151

152152
To play back an array and record at the same time, use `sounddevice.playrec()`:
153153

154-
>>> myrecording2 = sd.playrec(myarray, fs, input_channels=2)
154+
>>> myrecording2 = sd.playrec(myarray, fs, channels=2)
155155

156156
The number of output channels is obtained from ``myarray``, but the number of
157157
input channels still has to be specified.

sounddevice.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def callback(indata, frames, time, status):
357357
return ctx.out
358358

359359

360-
def playrec(data, samplerate=None, input_channels=None, input_dtype=None,
360+
def playrec(data, samplerate=None, channels=None, dtype=None,
361361
out=None, input_mapping=None, output_mapping=None, blocking=False,
362362
**kwargs):
363363
"""Simultaneous playback and recording.
@@ -366,12 +366,14 @@ def playrec(data, samplerate=None, input_channels=None, input_dtype=None,
366366
----------
367367
data : array_like
368368
Audio data to be played back. See :func:`play`.
369-
input_channels : int, sometimes optional
370-
See the parameter `channels` of :func:`rec`.
371-
input_dtype : str or numpy.dtype, optional
372-
See the parameter `dtype` of :func:`rec`.
373-
If `input_dtype` is not specified, it is taken from `data.dtype`
369+
channels : int, sometimes optional
370+
Number of input channels, see :func:`rec`.
371+
The number of output channels is obtained from `data.shape`.
372+
dtype : str or numpy.dtype, optional
373+
Input data type, see :func:`rec`.
374+
If `dtype` is not specified, it is taken from `data.dtype`
374375
(i.e. :attr:`default.dtype` is ignored).
376+
The output data type is obtained from `data.dtype` anyway.
375377
input_mapping, output_mapping : array_like, optional
376378
See the parameter `mapping` of :func:`rec` and :func:`play`,
377379
respectively.
@@ -402,10 +404,10 @@ def playrec(data, samplerate=None, input_channels=None, input_dtype=None,
402404
"""
403405
ctx = _CallbackContext()
404406
output_frames = ctx.check_data(data, output_mapping)
405-
if input_dtype is None:
406-
input_dtype = data.dtype # ignore module defaults
407-
input_frames = ctx.check_out(out, output_frames, input_channels,
408-
input_dtype, input_mapping)
407+
if dtype is None:
408+
dtype = data.dtype # ignore module defaults
409+
input_frames = ctx.check_out(out, output_frames, channels, dtype,
410+
input_mapping)
409411
if input_frames != output_frames:
410412
raise PortAudioError("len(data) != len(out)")
411413
ctx.frames = input_frames

0 commit comments

Comments
 (0)