Renderer¶
- class maelzel.scoring.render.Renderer(score, options)[source]¶
Bases:
ABC
Renders a quantizedscore to a given format
This is an abstract base class for different backend renderers (lilypond, musicxml, etc)
Methods Summary
musicxml
()Returns the rendered score as musicxml if supported
render
([options])Render the quantized score
show
([fmt, external, scalefactor])Display the rendered score
write
(outfile[, fmt, removeTemporaryFiles])Write the rendered score to a file
List of formats supported by this Renderer
Methods Documentation
- musicxml()[source]¶
Returns the rendered score as musicxml if supported
- Return type:
str
|None
- Returns:
either the musicxml as str, or None if not supported by this renderer
- abstract render(options=None)[source]¶
Render the quantized score
Note
The result is internally cached so calling this method multiple times only performs the rendering once as long as the options used do not change
- Parameters:
options (
Optional
[RenderOptions
]) – if given, these options override the own options- Return type:
str
- Returns:
the rendered score, as text. This will be lilypond text if the renderer is a LilypondRenderer, or musicxml text in the case of a MusicxmlRenderer
- show(fmt='png', external=False, scalefactor=1.0)[source]¶
Display the rendered score
- Parameters:
fmt – one of ‘png’, ‘pdf’
external – if True, for the use of an external app to open the rendered result. Otherwise, if running inside jupyter this command will try to display the result inline
scalefactor – a factor to scale the generated image when shown inline
- Return type:
None
- abstract write(outfile, fmt=None, removeTemporaryFiles=False)[source]¶
Write the rendered score to a file
- Parameters:
outfile (
str
) – the path to the written filefmt (
Optional
[str
]) – if given, this will be used as format for the output, independent of the extension used in outfile. The possible values depend on the formats supported by this Renderer (seeRenderer.writeFormats()
)removeTemporaryFiles – if True, removes any temporary files generated during the rendering/writing process
- Return type:
None