libmetro
metro::Note Class Reference

Note class. More...

#include <libmetro.h>

Public Types

enum  Timbre { Sine, Drum }
 

Public Member Functions

 Note ()
 Empty Note constructor. More...
 
 Note (Timbre timbre, float frequency, float volume)
 Note constructor with timbre. More...
 
 Note (std::string triplet)
 Note constructor with convenient string represenation. More...
 
float & operator[] (size_t index)
 index into underlying vector of floats.
 
const float & operator[] (size_t index) const
 index into underlying vector of floats.
 
std::vector< float > & get_frames ()
 get a reference to the underlying vector of floats.
 
size_t size ()
 size of underlying vector of floats.
 
Note operator+ (const Note &other)
 sum underlying vectors and return new Note
 

Detailed Description

Note class.

Notes wrap a vector of floats to represent a sound. Notes are always 2*48,000 = 96,000 samples long (1 second of data per channel, 2 channels).

The actual duration of 96,000 depends on the software_latency param in libsoundio:

>Ignoring hardware latency, this is the number of seconds it takes for the last sample in a full buffer to be played.

http://libsound.io/doc-2.0.0/structSoundIoOutStream.html#a20aac1422d3cc64b679616bb8447f06d

Member Enumeration Documentation

◆ Timbre

Timbre enum

Enumerator
Sine 

generate a sine wave sound. Uses stk/SineWave.h

Drum 

generate a drum sound. Uses stk/Drummer.h

Constructor & Destructor Documentation

◆ Note() [1/3]

metro::Note::Note ( )
inline

Empty Note constructor.

Empty notes are essential to libmetro to always keep streams warm by supplying them with 0s even if no audio is being output at a tick.

◆ Note() [2/3]

metro::Note::Note ( Timbre  timbre,
float  frequency,
float  volume 
)

Note constructor with timbre.

Parameters
[in]timbreSine or Drum.
[in]frequencyfor Sine, frequency represents the frequency. For Drum, frequency represents the frequency to General MIDI percussion note number.
[in]volumeloudness in percent, i.e. 100% is max volume

◆ Note() [3/3]

metro::Note::Note ( std::string  triplet)

Note constructor with convenient string represenation.

Parameters
[in]tripletstring in format 'timbre,freq,vol'

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