musicaiz.structure.Bar

class musicaiz.structure.Bar(start: Optional[Union[int, float]] = None, end: Optional[Union[int, float]] = None, time_sig: str = '4/4', bpm: int = 120, resolution: int = 96, absolute_timing: bool = True)[source]

Defines a class to group notes in bars.

Attributes
time_sig: str

If we do know the time signature in advance, we can initialize Musa object with it. This will assume that all the MIDI has the same time signature.

bpm: int

The tempo or bpm of the MIDI file. If this parameter is not initialized we suppose 120bpm with a resolution (sequencer ticks) of 960 ticks, which means that we have 500 ticks per quarter note.

resolution: int

the pulses o ticks per quarter note (PPQ or TPQN). If this parameter is not initialized we suppose a resolution (sequencer ticks) of 960 ticks.

absolute_timing: bool

selects how note timing attributes are initialized when reading a MIDI file. If absolute_timing is True, notes will be written in absolute times. If absolute_timing is False, times will be relative to the bar start.

__init__(start: Optional[Union[int, float]] = None, end: Optional[Union[int, float]] = None, time_sig: str = '4/4', bpm: int = 120, resolution: int = 96, absolute_timing: bool = True)[source]

Methods

__init__([start, end, time_sig, bpm, ...])

get_bars_durations(note_seq)

Build array of bar durations.

get_last_note(note_seq)

Get last note in note_seq.

get_total_bars(note_seq)

group_notes_in_bars(note_seq)

relative_notes_timing(bar_start)

The bar start is the value in ticks where the bar starts