Renderer

class maelzel.core.renderer.Renderer(presetManager)[source]

Bases: ABC

Abstract class for realtime and offline rendering

Parameters:

presetManager (PresetManager) – a singleton object managing all instrument templates

Methods Summary

assignBus([kind, value, persist])

Assign a bus

getInstr(instrname)

Get the Instr corresponding to the instr name

getSynth(token)

Get a synth by token/synthid

includeFile(path)

Add an #include clause to this renderer

isInstrDefined(instrname)

Is an Instr with the given name defined?

isRealtime()

Is this renderer working in real-time?

makeTable([data, size, sr, tabnum])

Create a Table to be used within this renderer

popLock()

Pop the lock of the audio engine (must be preceded by a pushLock)"

prepareEvent(event)

Prepare an event to be scheduled

prepareEvents(events[, sessionevents])

Prepare a series of events for scheduling

prepareInstr(instr, priority)

Prepare an Instr instance for the given priority

preparePreset(presetdef, priority)

Prepare a preset to be used

prepareSessionEvent(event)

Prepare a csound event for scheduling

pushLock()

Lock the audio engine

readSoundfile(soundfile[, chan, skiptime])

Read a soundfile into the renderer

registerPreset(presetdef)

Register a Preset at this renderer

releaseBus(bus)

Release a previously assigned bus

sched(instrname, delay, dur, priority[, ...])

Schedule an instrument

schedDummyEvent([dur])

Schedule a dummy synth

schedEvent(event)

Schedule a synthevent

schedEvents(coreevents[, sessionevents, ...])

Schedule multiple events simultanously

show()

If inside jupyter, force a display of this OfflineRenderer

sync()

Block until the audio engine has processed its immediate events

Methods Documentation

abstract assignBus(kind='', value=None, persist=False)[source]

Assign a bus

Return type:

Bus

abstract getInstr(instrname)[source]

Get the Instr corresponding to the instr name

Parameters:

instrname (str) – the name of the Instr

Return type:

Instr | None

Returns:

the Instr if defined and registered with this renderer, None otherwise

abstract getSynth(token)[source]

Get a synth by token/synthid

Return type:

Synth | None

abstract includeFile(path)[source]

Add an #include clause to this renderer

Return type:

None

isInstrDefined(instrname)[source]

Is an Instr with the given name defined?

Return type:

bool

abstract isRealtime()[source]

Is this renderer working in real-time?

Return type:

bool

abstract makeTable(data=None, size=0, sr=0, tabnum=0)[source]

Create a Table to be used within this renderer

Return type:

int

popLock()[source]

Pop the lock of the audio engine (must be preceded by a pushLock)”

This only makes sense for realtime rendering and is a no-op when rendering offline

Return type:

None

prepareEvent(event)[source]

Prepare an event to be scheduled

Parameters:

event (SynthEvent) – the event to schedule

Return type:

bool

Returns:

True if the operation performed some action on the audio engine

prepareEvents(events, sessionevents=None)[source]

Prepare a series of events for scheduling

All init codes which need to be compiled are compiled and synched, then all presets are prepared for the given priority. This method minimizes the number of syncs needed.

Parameters:
  • events (list[SynthEvent]) – the core events to prepare

  • sessionevents (Optional[list[Event]]) – any session events

Return type:

bool

Returns:

True if the renderer needs to be synched. The called is resposible for calling the Renderer.sync() method

abstract prepareInstr(instr, priority)[source]

Prepare an Instr instance for the given priority

Parameters:
  • instr (Instr) – the

  • priority (int)

Return type:

bool

Returns:

True if the audio engine performaed an action, False if the instrument was already prepared at the given priority

preparePreset(presetdef, priority)[source]

Prepare a preset to be used

Parameters:
  • presetdef (PresetDef) – the preset definition

  • priority (int) – the priority to use

Return type:

bool

Returns:

True if this operation performed some action on the audio engine. This can be used to sync the audio engine if needed.

abstract prepareSessionEvent(event)[source]

Prepare a csound event for scheduling

Parameters:

event (Event) – the event to preare

Return type:

bool

Returns:

True if the backend needs sync

pushLock()[source]

Lock the audio engine

This only makes sense for realtime rendering and is a no-op when rendering offline

Return type:

None

abstract readSoundfile(soundfile, chan=0, skiptime=0.0)[source]

Read a soundfile into the renderer

Parameters:
  • soundfile (str) – the soundfile to read

  • chan – the channel to read, 0 to read all channels

  • skiptime – start reading from this time

Return type:

int

abstract registerPreset(presetdef)[source]

Register a Preset at this renderer

Return type:

bool

abstract releaseBus(bus)[source]

Release a previously assigned bus

The bus must have been created with persist=True

Return type:

None

abstract sched(instrname, delay, dur, priority, args=None, whenfinished=None, **kws)[source]

Schedule an instrument

This method schedules a csound event

Parameters:
  • instrname (str) – the name of the instrument

  • delay (float) – start time

  • dur (float) – duration of the event. -1 to not set a duration

  • args (Union[dict[str, float], list[float | str], None]) – a list of positional arguments, or a dict of named arguments

  • priority (int) – the priority of this event

  • whenfinished (Optional[Callable]) – a callback to be fired when the event finishes (only valid for online rendering)

  • kws (dict[str, float]) – when args is passed as a list of positional arguments, any named argument can be given here

Returns:

the returned value depends on the renderer

schedDummyEvent(dur=0.001)[source]

Schedule a dummy synth

abstract schedEvent(event)[source]

Schedule a synthevent

abstract schedEvents(coreevents, sessionevents=None, whenfinished=None)[source]

Schedule multiple events simultanously

Parameters:
  • coreevents (list[SynthEvent]) – the synth events to schedule

  • sessionevents (Optional[list[Event]]) – the csound events to schedule

  • whenfinished (Optional[Callable]) – a function to call when scheduling is finished

Returns:

the returned value depends on the kind of renderer

show()[source]

If inside jupyter, force a display of this OfflineRenderer

Return type:

None

sync()[source]

Block until the audio engine has processed its immediate events

Return type:

None