1- """Reliable low-latency audio playback and recording."""
1+ """Reliable low-latency audio playback and recording.
22
3+ http://python-rtmixer.readthedocs.io/
4+
5+ """
36__version__ = '0.0.0'
47
58import sounddevice as _sd
@@ -45,7 +48,8 @@ def cancel(self, action, time=0, allow_belated=True):
4548 order to stop the given *action*.
4649
4750 This function typically returns before the *action* is actually
48- stopped. Use `wait()` to wait until it's done.
51+ stopped. Use `wait()` (on either one of the two actions) to
52+ wait until it's done.
4953
5054 """
5155 cancel_action = _ffi .new ('struct action*' , dict (
@@ -99,17 +103,22 @@ def _drain_result_q(self):
99103
100104
101105class Mixer (_Base ):
102- """PortAudio output stream for realtime mixing."""
106+ """PortAudio output stream for realtime mixing.
103107
104- def __init__ (self , ** kwargs ):
105- """Create a realtime mixer object.
108+ Takes the same keyword arguments as `sounddevice.OutputStream`,
109+ except *callback* (a callback function implemented in C is used
110+ internally) and *dtype* (which is always ``'float32'``).
106111
107- Takes the same keyword arguments as `sounddevice.OutputStream` ,
108- except *callback* and *dtype* .
112+ Uses default values from `sounddevice.default` (except *dtype* ,
113+ which is always ``'float32'``) .
109114
110- Uses default values from `sounddevice.default`.
115+ Has the same methods and attributes as `sounddevice.OutputStream`
116+ (except :meth:`~sounddevice.Stream.write` and
117+ :attr:`~sounddevice.Stream.write_available`), plus the following:
111118
112- """
119+ """
120+
121+ def __init__ (self , ** kwargs ):
113122 _Base .__init__ (self , kind = 'output' , ** kwargs )
114123 self ._state .output_channels = self .channels
115124
@@ -136,10 +145,10 @@ def play_buffer(self, buffer, channels, start=0, allow_belated=True):
136145
137146 def play_ringbuffer (self , ringbuffer , channels = None , start = 0 ,
138147 allow_belated = True ):
139- """Send a ring buffer to the callback to be played back.
148+ """Send a `RingBuffer` to the callback to be played back.
140149
141150 By default, the number of channels is obtained from the ring
142- buffer's * elementsize* .
151+ buffer's :attr:`~RingBuffer. elementsize` .
143152
144153 """
145154 _ , samplesize = _sd ._split (self .samplesize )
@@ -162,17 +171,21 @@ def play_ringbuffer(self, ringbuffer, channels=None, start=0,
162171
163172
164173class Recorder (_Base ):
165- """PortAudio input stream for realtime recording."""
174+ """PortAudio input stream for realtime recording.
166175
167- def __init__ (self , ** kwargs ):
168- """Create a realtime recording object.
176+ Takes the same keyword arguments as `sounddevice.InputStream`,
177+ except *callback* (a callback function implemented in C is used
178+ internally) and *dtype* (which is always ``'float32'``).
169179
170- Takes the same keyword arguments as `sounddevice.InputStream` ,
171- except *callback* and *dtype* .
180+ Uses default values from `sounddevice.default` (except *dtype* ,
181+ which is always ``'float32'``) .
172182
173- Uses default values from `sounddevice.default`.
183+ Has the same methods and attributes as `Mixer`, except that
184+ `play_buffer()` and `play_ringbuffer()` are replaced by:
174185
175- """
186+ """
187+
188+ def __init__ (self , ** kwargs ):
176189 _Base .__init__ (self , kind = 'input' , ** kwargs )
177190 self ._state .input_channels = self .channels
178191
@@ -197,10 +210,10 @@ def record_buffer(self, buffer, channels, start=0, allow_belated=True):
197210
198211 def record_ringbuffer (self , ringbuffer , channels = None , start = 0 ,
199212 allow_belated = True ):
200- """Send a ring buffer to the callback to be recorded into.
213+ """Send a `RingBuffer` to the callback to be recorded into.
201214
202215 By default, the number of channels is obtained from the ring
203- buffer's * elementsize* .
216+ buffer's :attr:`~RingBuffer. elementsize` .
204217
205218 """
206219 samplesize , _ = _sd ._split (self .samplesize )
@@ -223,17 +236,20 @@ def record_ringbuffer(self, ringbuffer, channels=None, start=0,
223236
224237
225238class MixerAndRecorder (Mixer , Recorder ):
226- """PortAudio stream for realtime mixing and recording."""
239+ """PortAudio stream for realtime mixing and recording.
227240
228- def __init__ (self , ** kwargs ):
229- """Create a realtime mixer object with recording capabilities.
241+ Takes the same keyword arguments as `sounddevice.Stream`, except
242+ *callback* (a callback function implemented in C is used internally)
243+ and *dtype* (which is always ``'float32'``).
230244
231- Takes the same keyword arguments as `sounddevice.Stream` ,
232- except *callback* and *dtype* .
245+ Uses default values from `sounddevice.default` (except *dtype* ,
246+ which is always ``'float32'``) .
233247
234- Uses default values from `sounddevice.default `.
248+ Inherits all methods and attributes from `Mixer` and `Recorder `.
235249
236- """
250+ """
251+
252+ def __init__ (self , ** kwargs ):
237253 _Base .__init__ (self , kind = 'duplex' , ** kwargs )
238254 self ._state .input_channels = self .channels [0 ]
239255 self ._state .output_channels = self .channels [1 ]
0 commit comments