scamp_extensions.engraving.note_graph.PartNoteGraph
- class scamp_extensions.engraving.note_graph.PartNoteGraph(performance_part: ~scamp.performance.PerformancePart, height_parameter: str = 'pitch', height_parameter_range: ~typing.Tuple[~numbers.Real, ~numbers.Real] = None, width_parameter: str = 'volume', width_parameter_range: ~typing.Tuple[~numbers.Real, ~numbers.Real] = None, width_range: ~typing.Tuple[~numbers.Real, ~numbers.Real] = (1, 20), color_parameter: str = None, color_parameter_range: ~typing.Tuple[~numbers.Real, ~numbers.Real] = None, color_map: ~typing.Callable[[~numbers.Real], ~typing.Tuple[~numbers.Real, ~numbers.Real, ~numbers.Real]] = <function default_color_map>, time_range: ~typing.Tuple[~numbers.Real, ~numbers.Real] = None, fill_color: str = 'black', outline_color: str = 'black', outline_width: ~numbers.Real = 1, guide_lines: ~typing.Sequence[~numbers.Real] = (), guide_line_width: ~numbers.Real = 2, guide_line_color: str = 'black', attack_only: bool = False)[source]
Bases:
objectClass that takes a performance part and a bunch of drawing/visualization settings, and can render to a class:svgDraw.Drawing.
- Parameters:
performance_part – the PerformancePart on which to base this note graph
height_parameter – the playback parameter of that governs each note’s height on the graph; defaults to pitch
height_parameter_range – range of values expected from the parameter that governs height. If the parameter is pitch, defaults to the min and max pitch found in the part. Otherwise defaults to (0, 1).
width_parameter – the playback parameter of that governs each note’s width on the graph; defaults to volume
width_parameter_range – range of values expected from the parameter that governs width. If the parameter is pitch, defaults to the min and max pitch found in the part. Otherwise defaults to (0, 1).
width_range – range of note widths mapped to in the drawing
color_parameter – the parameter governing note color, if any (overrides fill_color); inactive by default
color_parameter_range – range of values expected from the parameter that governs color. If the parameter is pitch, defaults to the min and max pitch found in the part. Otherwise defaults to (0, 1).
color_map – function from the interval [0, 1] to an RGB color tuple, where 0 represents the color parameter at the bottom of its range and 1 at the top.
time_range – time range to map horizontal space to; defaults to 0 to length of part
fill_color – the fill color of note glyphs; overridden by color parameter, if active
outline_color – note outline color
outline_width – note outline width
guide_lines – the values of the height parameter at which to draw horizontal guide lines.
guide_line_width – width of the guide lines
guide_line_color – color of the guide lines
attack_only – if true, only draw the attack of each note as a circle.
Methods
render(drawing, bottom_left, dimensions)Draw this note graph into an existing drawing, within the rectangle described by bottom_left and dimensions.
render_to_file(file_path, dimensions[, ...])Render this note graph to an SVG file of its own.
- render(drawing: Drawing, bottom_left: Tuple[Real, Real], dimensions: Tuple[Real, Real])[source]
Draw this note graph into an existing drawing, within the rectangle described by bottom_left and dimensions.
- Parameters:
drawing – the
drawsvg.Drawingto draw intobottom_left – the (x, y) coordinate of the bottom left corner of the graph
dimensions – the (width, height) of the graph
- render_to_file(file_path, dimensions, bg_color=None, h_padding=100, v_padding=100, pixel_scale=2)[source]
Render this note graph to an SVG file of its own.
- Parameters:
file_path – path of the SVG file to write
dimensions – the (width, height) of the image, padding included
bg_color – background color of the image; left transparent if None
h_padding – horizontal padding between the graph and the edge of the image
v_padding – vertical padding between the graph and the edge of the image
pixel_scale – factor by which to scale the image’s pixel dimensions, for higher resolution