libmetro
|
#include <libmetro.h>
Public Types | |
enum | FileFormat { One, Two } |
Public Member Functions | |
Measure (int num_notes) | |
Measure constructor. More... | |
Measure (const char *path, FileFormat file_format) | |
Measure constructor. More... | |
Note & | operator[] (size_t index) |
index into underlying vector of Notes. | |
const Note & | operator[] (size_t index) const |
index into underlying vector of Notes. | |
std::vector< Note > & | get_notes () |
get a reference to the underlying vector of Notes. | |
size_t | size () |
size of underlying vector of Notes. | |
Measure class.
Measures wrap a vector of Notes to represent a measure.
Unset indices of a measure will contain an empty note. As explained in the Note documentation, this is to keep the real-time audio streams "warm" by always emitting the correct amount of samples to obey timing, even in a metronome tick that doesn't have a sound.
|
inline |
Measure constructor.
Assign notes with the index operator e.g. auto measure = Measure(5); measure[0] = metro::Note();
Accesses out of range are undefined behavior (but it'll probably segfault).
[in] | num_notes | number of notes (allocates size of underlying vector) |
metro::Measure::Measure | ( | const char * | path, |
FileFormat | file_format | ||
) |
Measure constructor.
Create a measure by parsing a measure description txt file.
FileFormat::One
Lines are newline-separated. Comments start with '#'
# number of beats in the measure measure_length 4 # beats at index of the measure 0 sine,440.0,10.0 drum,73.42,100.0 drum,92.5,100.0 1 sine,440.0,10.0 drum,73.42,50.0 2 sine,440.0,10.0 drum,73.42,65.0 3 sine,440.0,10.0 drum,73.42,50.0
FileFormat::Two
Lines are newline-separated. Comments start with '#'
# every string should have the same length # the first 1 represents a downbeat # subsequent 1s represent weak beats # this is a way to visualize how polyrhythms overlay on one another 1 0 1 0 1 0 1 0 0 1 0 0
[in] | path | path to txt file |