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?
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 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 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 preparesessionevents (
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
) – thepriority (
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 definitionpriority (
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 readchan – the channel to read, 0 to read all channels
skiptime – start reading from this time
- Return type:
int
- 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 instrumentdelay (
float
) – start timedur (
float
) – duration of the event. -1 to not set a durationargs (
Union
[dict
[str
,float
],list
[float
|str
],None
]) – a list of positional arguments, or a dict of named argumentspriority (
int
) – the priority of this eventwhenfinished (
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
- abstract schedEvents(coreevents, sessionevents=None, whenfinished=None)[source]¶
Schedule multiple events simultanously
- Parameters:
coreevents (
list
[SynthEvent
]) – the synth events to schedulesessionevents (
Optional
[list
[Event
]]) – the csound events to schedulewhenfinished (
Optional
[Callable
]) – a function to call when scheduling is finished
- Returns:
the returned value depends on the kind of renderer