musicaiz.rhythm.get_subdivisions¶
- musicaiz.rhythm.get_subdivisions(total_bars: int, subdivision: str, time_sig: str = '4/4', bpm: int = 120, resolution: int = 96, absolute_timing: bool = True) List[Dict[str, Union[int, float]]] [source]¶
This method returns the grid (vertical lines) for quantizing notes of a determined number of measures given by total_bars. The lines are plotted in each beat subdivision. Each line has the format m.b.s.: m: measure b: beat s: subdivision Ex.: subdivision = 8 is an 8th note
- Parameters
- total_bars: int
the number of bars.
- subdivision: str
the note subdivision. Ex.: quarter, eight… Note that we cannot have a subdivision greater than the beat nor a non value of the beat note. If the beat corresponds to a quarter note (X/4 time sigs.), the subdivision has to be a note shorter than the quarter note but half or 4 times less than the beat (eight, sixteenth note…).
- time_sig: str
the time signature as a fraction.
- bpm: int
the tempo or bpms.
- resolution: int
the pulses o ticks per quarter note (PPQ or TPQN).
- absolute_timing: bool
default is True. This allows to initialize note time arguments in absolute (True) or relative time units (False). Relative units means that each bar will start at 0 seconds and ticks, so the note timing attributes will be relative to the bar start equals to 0.
- Returns
- beat_subdivs: List[Dict[str, Union[int, float]]]
each element in the list is a subdivision. The subdivision dict key’s are:
bar: the bar index in the total_bars of the subdivision.
piece_beat: the beat index corresponding to the subdivision in the total_bars or piece.
piece_subdivision: the subdivision index corresponding to the total number of subdivisions in the total_bars or piece.
bar_beat: the beat index corresponding to the subdivision in its bar.
bar_subdivision: the subdivision index corresponding to its bar.
ticks: the ticks value of where the subdivision starts.
sec: the secs value of where the subdivision starts.