getSession

maelzel.core.playback.getSession(numchannels=None, backend='', outdev='', verbose=None, buffersize=0, latency=None, numbuffers=0, ensure=False, name='')[source]

Returns / creates the audio Session

If no Session has been created already, a Session is initialized with the given parameters and returned. Otherwise the active Session is returned and any parameters passed are ignored

Note

There is one audio session, shared by all workspaces. Only the first call to this function will initialize the session to specific parameters. If you need to initialize the session to specific values, call this function before any playback related functionality is used. If any playback related function/method is called before, the session is created from default values. To configure these default values see the configuration

Parameters:
  • numchannels (Optional[int]) – the number of output channels, overrides config ‘play.numChannels’

  • backend – the audio backend used, overrides config ‘play.backend’

  • outdev – leave as None to use the backend’s default, use ‘?’ to select from a list of available devices. To list all available devices see getAudioDevices()

  • verbose (Optional[bool]) – if True, output debugging information

  • buffersize (int) – if given, use this as the buffer size. None to use a sensible default for the backend

  • latency (Optional[float]) – an added latency

  • numbuffers (int) – the number of buffers used by the csound engine

  • ensure (bool) – if True, an exception is raised if a Session already existed with parameters differing from the given

Return type:

Session

Returns:

the active Session

Raises:

SessionParametersMismatchError – if ensure was True and the given parameters do not match the existing session

See also

csoundengine.Session