@@ -727,6 +727,45 @@ def __init__(self, kind, samplerate=None, blocksize=None, device=None,
727727 dither_off = None , never_drop_input = None ,
728728 prime_output_buffers_using_stream_callback = None ,
729729 userdata = None , wrap_callback = None ):
730+ """Base class for PortAudio streams.
731+
732+ This class should only be used by library authors who want to
733+ create their own custom stream classes.
734+ Most users should use the derived classes
735+ `Stream`, `InputStream`, `OutputStream`,
736+ `RawStream`, `RawInputStream` and `RawOutputStream` instead.
737+
738+ This class has the same properties and methods as `Stream`,
739+ except for `read_available`/:meth:`~Stream.read` and
740+ `write_available`/:meth:`~Stream.write`.
741+
742+ It can be created with the same parameters as `Stream`,
743+ except that there are three additional parameters
744+ and the *callback* parameter also accepts a C function pointer.
745+
746+ Parameters
747+ ----------
748+ kind : {'input', 'output', 'duplex'}
749+ The desired type of stream: for recording, playback or both.
750+ callback : Python callable or CData function pointer, optional
751+ If *wrap_callback* is ``None`` this can be a function pointer
752+ provided by CFFI.
753+ Otherwise, it has to be a Python callable.
754+ wrap_callback : {'array', 'buffer'}, optional
755+ If *callback* is a Python callable, this selects whether
756+ the audio data is provided as NumPy array (like in `Stream`)
757+ or as Python buffer object (like in `RawStream`).
758+ userdata : CData void pointer
759+ This is passed to the underlying C callback function
760+ on each call and can only be accessed from a *callback*
761+ provided as ``CData`` function pointer.
762+
763+ Examples
764+ --------
765+ A usage example of this class can be seen at
766+ https://github.com/spatialaudio/python-rtmixer.
767+
768+ """
730769 assert kind in ('input' , 'output' , 'duplex' )
731770 assert wrap_callback in ('array' , 'buffer' , None )
732771 if blocksize is None :
@@ -2613,7 +2652,12 @@ def _array(buffer, channels, dtype):
26132652
26142653
26152654def _split (value ):
2616- """Split input/output value into two values."""
2655+ """Split input/output value into two values.
2656+
2657+ This can be useful for generic code that allows using the same value
2658+ for input and output but also a pair of two separate values.
2659+
2660+ """
26172661 if isinstance (value , _basestring ):
26182662 # iterable, but not meant for splitting
26192663 return value , value
@@ -2718,9 +2762,12 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
27182762def _initialize ():
27192763 """Initialize PortAudio.
27202764
2721- This temporarily forwards messages from stderr to /dev/null
2765+ This temporarily forwards messages from stderr to `` /dev/null``
27222766 (where supported).
27232767
2768+ In most cases, this doesn't have to be called explicitly, because it
2769+ is automatically called with the ``import sounddevice`` statement.
2770+
27242771 """
27252772 old_stderr = None
27262773 try :
@@ -2748,7 +2795,11 @@ def _initialize():
27482795
27492796
27502797def _terminate ():
2751- """Terminate PortAudio."""
2798+ """Terminate PortAudio.
2799+
2800+ In most cases, this doesn't have to be called explicitly.
2801+
2802+ """
27522803 global _initialized
27532804 _check (_lib .Pa_Terminate (), 'Error terminating PortAudio' )
27542805 _initialized -= 1
0 commit comments