plotter¶
This module contains the following classes:
Plotter, for plotting waveforms and labels to image files;PlotterColors, enumerating colors;PlotElement, representing a generic plot element;PlotTimeScale, representing a time scale;PlotLabelset, representing a set of labels (annotations);PlotWaveform, representing a waveform.
Note
This module requires Python module PIL (pip install Pillow).
Warning
This module is likely to be refactored in a future version
New in version 1.5.0.
-
class
aeneas.plotter.PlotElement(label=None, rconf=None, logger=None)[source]¶ A generic element of a Plot.
Parameters: - rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
-
FONT_PATH= '/home/alberto/projects/rb/aeneas/aeneas/res/LiberationMono-Regular.ttf'¶ Path of the font to be used for drawing
-
TEXT_MARGIN= 2¶ Margin between text and anchor point, in pixels
-
TICK_WIDTH= 2¶ A tick will be drawn with (1 + 2 times this value) pixels
-
height¶ The height of this element, in modules.
Return type: int
-
text_bounding_box(size_pt, text)[source]¶ Return the bounding box of the given text at the given font size.
Parameters: - size_pt (int) – the font size in points
- text (string) – the text
Return type:
-
width¶ The width of this element, in modules.
Return type: int
- rconf (
-
class
aeneas.plotter.PlotLabelset(labelset, label=None, parameters=None, rconf=None, logger=None)[source]¶ A set of labels.
Parameters: - labelset (list) – a list of triples
(begin, end, label)of type(float, float, string), times in seconds - label (string) – a label for this set
- parameters (dict) – a dictionary holding drawing parameters
- rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
- labelset (list) – a list of triples
-
class
aeneas.plotter.PlotTimeScale(max_time, time_step=1, rconf=None, logger=None)[source]¶ A time scale.
Parameters: - max_time (float) – the maximum length of the time scale
- time_step (int) – the step of the time scale numbers
- rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
-
class
aeneas.plotter.PlotWaveform(audio_file, label=None, fast=False, rconf=None, logger=None)[source]¶ An audio file waveform.
Parameters: - audio_file (
AudioFile) – the audio file from which the waveform must be drawn - label (string) – a label for this waveform
- fast (bool) – if
True, plot fast (only max, mirrored) - rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
- audio_file (
-
class
aeneas.plotter.Plotter(rconf=None, logger=None)[source]¶ Plot waveforms and labels to image files.
Parameters: - rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
-
add_labelset(labelset)[source]¶ Add a set of labels to the plot.
Parameters: labelset ( PlotLabelset) – the set of labels to be addedRaises: TypeError: if labelsetis not an instance ofPlotLabelset
-
add_timescale(timescale)[source]¶ Add a time scale to the plot.
Parameters: timescale ( PlotTimeScale) – the timescale to be addedRaises: TypeError: if timescaleis not an instance ofPlotTimeScale
-
add_waveform(waveform)[source]¶ Add a waveform to the plot.
Parameters: waveform ( PlotWaveform) – the waveform to be addedRaises: TypeError: if waveformis not an instance ofPlotWaveform
-
draw_png(output_file_path, h_zoom=5, v_zoom=30)[source]¶ Draw the current plot to a PNG file.
Parameters: - output_path (string) – the path of the output file to be written
- h_zoom (int) – the horizontal zoom
- v_zoom (int) – the vertical zoom
Raises: ImportError: if module
PILcannot be importedRaises: OSError: if
output_file_pathcannot be written
- rconf (
-
class
aeneas.plotter.PlotterColors[source]¶ Enumeration of colors for
Plotter.-
AUDACITY_BACKGROUND_GREY= (192, 192, 192)¶ Audacity background grey
-
AUDACITY_DARK_BLUE= (50, 50, 200)¶ Audacity dark blue
-
AUDACITY_LIGHT_BLUE= (100, 100, 220)¶ Audacity light blue
-
BLACK= (0, 0, 0)¶ Black
-
BLUE= (0, 0, 255)¶ Blue
-
GREEN= (0, 255, 0)¶ Green
-
RED= (255, 0, 0)¶ Red
-
WHITE= (255, 255, 255)¶ White
-