Server(sr=44100, nchnls=2, buffersize=256, duplex=1, audio="portaudio", jackname="pyo")
Main processing audio loop callback handler.
The Server object handles all communications with Portaudio and Portmidi. It keeps track of all audio streams created as well as connections between them.
An instance of the Server must be booted before defining any signal processing chain.
Parameters:
sr : int, optional Sampling rate used by Portaudio and the Server to compute samples. Defaults to 44100. nchnls : int, optional Number of input and output channels. Defaults to 2. buffersize : int, optional Number of samples that Portaudio will request from the callback loop. This value has an impact on CPU use (a small buffer size is harder to compute) and on the latency of the system. Latency is `buffer size / sampling rate` in seconds. Defaults to 256. duplex : int {0, 1}, optional Input - output mode. 0 is output only and 1 is both ways. Defaults to 1. audio : string {'portaudio', 'pa', 'jack', 'coreaudio'}, optional Audio backend to use. 'pa' is equivalent to 'portaudio'. Default is 'portaudio'. jackname : string, optional Name of jack client. Defaults to 'pyo'
Methods:
setAmp(x) : Set the overall amplitude. boot() : Boot the server. Must be called before defining any signal processing chain. shutdown() : Shut down and clear the server. setStartOffset(x) : Set the starting time of the real-time processing. start() : Start the audio callback loop. stop() : Stop the audio callback loop. gui(locals, meter, timer) : Show the server's user interface. recordOptions(dur, filename, fileformat, sampletype) : Rendering settings. recstart(str) : Begins recording of the sound sent to output. This method creates a file called `pyo_rec.aif` in the user's home directory if a path is not supplied. recstop() : Stops previously started recording. getSamplingRate() : Returns the current sampling rate. getNchnls() : Returns the current number of channels. getBufferSize() : Returns the current buffer size. getIsStarted() : Returns 1 if the server is started, otherwise returns 0. The next methods must be called before booting the server setInOutDevice(x) : Set both input and output devices. See `pa_list_devices()`. setInputDevice(x) : Set the audio input device number. See `pa_list_devices()`. setOutputDevice(x) : Set the audio output device number. See `pa_list_devices()`. setMidiInputDevice(x) : Set the MIDI input device number. See `pm_list_devices()`. setSamplingRate(x) : Set the sampling rate used by the server. setBufferSize(x) : Set the buffer size used by the server. setNchnls(x) : Set the number of channels used by the server. setDuplex(x) : Set the duplex mode used by the server. setVerbosity(x) : Set the server's verbosity.
Attributes:
amp : Overall amplitude of the Server. This value is applied on any stream sent to the soundcard. verbosity : Control the messages printed by the server. It is a sum of values to display different levels: 1 = error, 2 = message, 4 = warning , 8 = debug. startoffset : Starting time of the real-time processing.
Examples:
>>> # For an 8 channels server in duplex mode with >>> # a sampling rate of 48000 Hz and buffer size of 512 >>> s = Server(sr=48000, nchnls=8, buffersize=512, duplex=1).boot() >>> s.start()
Methods details:
Server.setAmp(x): Set the overall amplitude. Parameters: x : float New amplitude. Server.boot(self): Boot the server. Must be called before defining any signal processing chain. Server's parameters like `samplingrate`, `buffersize` or `nchnls` will be effective after a call to this method. Server.shutdown(self): Shut down and clear the server. This method will erase all objects from the callback loop. This method need to be called before changing server's parameters like `samplingrate`, `buffersize`, `nchnls`, ... Server.setStartOffset(x): Set the server's starting time offset. First `x` seconds will be rendered offline as fast as possible. Parameters: x : float Starting time of the real-time processing. Server.start(self): Start the audio callback loop and begin processing. Server.stop(self): Stop the audio callback loop. Server.gui(locals=None, meter=True, timer=True): Show the server's user interface. Parameters: locals : locals namespace {locals(), None}, optional If locals() is given, the interface will show an interpreter extension, giving a way to interact with the running script. Defaults to None. meter : boolean, optinal If True, the interface will show a vumeter of the global output signal. Defaults to True. timer : boolean, optional If True, the interface will show a clock of the current time. Defaults to True. Server.recordOptions(dur=-1, filename=None, fileformat=0, sampletype=0): Sets options for soundfile created by offline rendering or global recording. Parameters: dur : float Duration, in seconds, of the recorded file. Only used by offline rendering. Must be positive. Defaults to -1. filename : string Full path of the file to create. If None, a file called `pyo_rec.wav` will be created in the user's home directory. Defaults to None. fileformat : int, optional Format type of the audio file. This function will first try to set the format from the filename extension. If it's not possible, it uses the fileformat parameter. Defaults to 0. Supported formats are: 0 : WAV - Microsoft WAV format (little endian) {.wav, .wave} 1 : AIFF - Apple/SGI AIFF format (big endian) {.aif, .aiff} sampletype : int, optional Bit depth encoding of the audio file. Defaults to 0. Supported types are: 0 : 16 bits int 1 : 24 bits int 2 : 32 bits int 3 : 32 bits float 4 : 64 bits float Server.recstart(filename=None): Begins a default recording of the sound that is sent to the soundcard. This will create a file called `pyo_rec.wav` in the user's home directory if no path is supplied or defined with recordOptions method. Uses file format and sample type defined with recordOptions method. Parameters: filename : string, optional Name of the file to be created. Defaults to None. Server.recstop(self): Stop the previously started recording. Server.getSamplingRate(self): Return the current sampling rate. Server.getNchnls(self): Return the current number of channels. Server.getBufferSize(self): Return the current buffer size. Server.getIsStarted(self): Returns 1 if the server is started, otherwise returns 0. Server.setInOutDevice(x): Set both input and output audio devices. See `pa_list_devices()`. Parameters: x : int Number of the audio input and output devices. Server.setInputDevice(x): Set the audio input device number. See `pa_list_devices()`. Parameters: x : int Number of the audio device listed by Portaudio. Server.setOutputDevice(x): Set the audio output device number. See `pa_list_devices()`. Parameters: x : int Number of the audio device listed by Portaudio. Server.setMidiInputDevice(x): Set the Midi input device number. See `pm_list_devices()`. Parameters: x : int Number of the Midi device listed by Portmidi. Server.setSamplingRate(x): Set the sampling rate used by the server. Parameters: x : int New sampling rate, must be supported by the soundcard. Server.setBufferSize(x): Set the buffer size used by the server. Parameters: x : int New buffer size. Server.setNchnls(x): Set the number of channels used by the server. Parameters: x : int New number of channels. Server.setDuplex(x): Set the duplex mode used by the server. Parameters: x : int {0 or 1} New mode. 0 is output only, 1 is both ways. Server.setVerbosity(x): Set the server's verbosity. Parameters: x : int A sum of values to display different levels: 1 = error, 2 = message, 4 = warning , 8 = debug.