Mozzi  version v2.0
sound synthesis library for Arduino
Metronome Class Reference

A metronome class which is like an EventDelay which retriggers itself when the delay time is up, to produce a repeating beat. More...

#include <Metronome.h>

+ Inheritance diagram for Metronome:

Detailed Description

A metronome class which is like an EventDelay which retriggers itself when the delay time is up, to produce a repeating beat.

Metronome can be set() to a number of milliseconds, then after calling start(), ready() will return true when the time is up.
Alternatively, start(milliseconds) will call set() and start() together. This is called Metronome to avoid conflict with the Arduino Metro library.

Definition at line 23 of file Metronome.h.

Public Member Functions

 Metronome (unsigned int delay_milliseconds=0)
 Constructor. More...
 
void start ()
 Start the metronome. More...
 
void start (unsigned int delay_milliseconds)
 Set the time between beats and start the metronome. More...
 
void setBPM (float bpm)
 Set the beats per minute. More...
 
bool ready ()
 Call this in updateControl() or updateAudio() to check if it is time for a beat. More...
 
void stop ()
 
void set (unsigned int delay_milliseconds)
 Set the delay time. More...
 

Protected Attributes

unsigned long deadline
 
unsigned long ticks
 

Constructor & Destructor Documentation

◆ Metronome()

Metronome::Metronome ( unsigned int  delay_milliseconds = 0)
inline

Constructor.

Declare a Metronome object.

Parameters
delay_millisecondshow long between each occasion when ready() returns true.

Definition at line 32 of file Metronome.h.

Member Function Documentation

◆ ready()

bool Metronome::ready ( )
inline

Call this in updateControl() or updateAudio() to check if it is time for a beat.

Returns
true if the time for one is up.

Definition at line 76 of file Metronome.h.

◆ set()

void EventDelay::set ( unsigned int  delay_milliseconds)
inlineinherited

Set the delay time.

This setting is persistent, until you change it by using set() again.

Parameters
delay_millisecondsdelay time in milliseconds.
Note
timing: 12us

Definition at line 40 of file EventDelay.h.

◆ setBPM()

void Metronome::setBPM ( float  bpm)
inline

Set the beats per minute.

Parameters
bpmbeats per minute

Definition at line 64 of file Metronome.h.

◆ start() [1/2]

void Metronome::start ( )
inline

Start the metronome.

Definition at line 41 of file Metronome.h.

◆ start() [2/2]

void Metronome::start ( unsigned int  delay_milliseconds)
inline

Set the time between beats and start the metronome.

Parameters
delay_millisecondsdelay time in milliseconds.

Definition at line 52 of file Metronome.h.