libmetro
metro::Measure Class Reference

Measure class. More...

#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...
 
Noteoperator[] (size_t index)
 index into underlying vector of Notes.
 
const Noteoperator[] (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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ FileFormat

FileFormat enum

Enumerator
One 

first experimental file format

Two 

second experimental file format

Constructor & Destructor Documentation

◆ Measure() [1/2]

metro::Measure::Measure ( int  num_notes)
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).

Parameters
[in]num_notesnumber of notes (allocates size of underlying vector)

◆ Measure() [2/2]

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
Parameters
[in]pathpath to txt file

The documentation for this class was generated from the following file: