pydrumscore.api module¶
Contains the API for the pydrumscore exporter. All the objects and functions here are meant to be called by the user in their scoring code.
- class pydrumscore.api.Measure(*args, accent: Optional[list] = None, bass_drum: Optional[list] = None, floor_tom: Optional[list] = None, snare: Optional[list] = None, snare_ghost: Optional[list] = None, crash1: Optional[list] = None, hi_hat: Optional[list] = None, hi_hat_open: Optional[list] = None, ride: Optional[list] = None, ride_bell: Optional[list] = None, high_tom: Optional[list] = None, hi_hat_foot: Optional[list] = None, flam_snare: Optional[list] = None, mid_tom: Optional[list] = None, cross_stick: Optional[list] = None, ac: Optional[list] = None, hi_hat_closed: Optional[list] = None, bd: Optional[list] = None, ft: Optional[list] = None, sd: Optional[list] = None, sg: Optional[list] = None, c1: Optional[list] = None, hh: Optional[list] = None, ho: Optional[list] = None, rd: Optional[list] = None, rb: Optional[list] = None, ht: Optional[list] = None, hf: Optional[list] = None, fm: Optional[list] = None, mt: Optional[list] = None, cs: Optional[list] = None, has_line_break=False, tempo: Optional[float] = None, no_repeat=False, text: Optional[str] = None, dynamic: Optional[str] = None)¶
Bases:
object
Contains the time values of all the notes in a given measure, as well as any accompanying data such as time signature, text, or tempo marking.
This class is intended to be instantiated by the user. Fill in the
measures
object in a score file to define the measures that must be exported.- Raises:
RuntimeError: If assigning to a drumset piece that does not exist
- debug_print()¶
Prints the contents of the measure to the console, in a visual “ASCII” format.
- Warning:
Does not yet support subdivisions of more than 16th… This function is still experimental.
- dynamic: Optional[str]¶
Dynamics (volume) of the measure, such as forte(f), piano (p), fortissimo (ff), mezzo forte(mf), etc.
- has_line_break¶
Whether or not to add a line break at the end of this measure. Useful for drum exercises that have multiple sections.
- no_repeat¶
Tells the exporter to not replace this measure with a repeat, and to instead write it out fully even if it is identical to the previous measure.
- replace(from_notes: List[float], to_notes: List[float], times: List[float])¶
Replaces a set of notes from one list to another. Useful for introducing slight variations in a measure, such as replacing a single hi-hat note with an open hi-hat.
- Parameters:
from_notes (List[float]) – List from which to remove the times
to_notes (List[float]) – List from which to insert the times
times (List[float]) – Times that should be replaced
- tempo: Optional[float]¶
Tempo starting from this measure.
- text: Optional[str]¶
Text displayed at the beginning of the measure. Useful for lyrics or other indications.
- class pydrumscore.api.Metadata(arranger='', composer='', Copyright='', creationDate='', lyricist='', movementNumber='', movementTitle='', mscVersion='', platform='', poet='', pydrumscoreVersion='', source='', subtitle='', translator='', workNumber='', workTitle='')¶
Bases:
object
Contains all the metadata necessary for exporting a song. In a song generation file, the global metadata instance of this class must be filled with all the relevant information.
- pydrumscore.api.end()¶
Get the current numerical value of the end of a measure. Dynamically reassigned based on current time signature. Typically used in a note_range(), such as
note_range(1, end(), 0.5) -> [1, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
- pydrumscore.api.note_range(start: float, stop: float, step: float, excl: Optional[List[float]] = None) list ¶
Creates a list based on a range (start, stop) and step provided as argument. Functions the same way as python’s built-in range function, but using floats instead of ints. As such, start bound is inclusive and stop bound is exclusive.
Example for eighth notes filling a measure:
note_range(1, 5, 0.5) -> [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
- Parameters:
start – (float): First number in the range
stop – (float): Last number in the range (exclusive bound)
step – (float): Step between entries
excl(opt) – list(float): List of specific values to exclude from range.
- Returns:
list: Range of notes from ‘start’ to ‘stop’, separated by ‘step’
- pydrumscore.api.set_time_signature(time_sig: str) None ¶
Sets the time signature for all upcoming measures. By default, songs have a time signature of “4/4”.
- Parameters:
time_sig – (str): New time signature. Must be in the format “int/int”.