| Mozzi version v1.1.0 sound synthesis library for Arduino |

Public Member Functions | Protected Attributes | List of all members
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:

## 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

## 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 22 of file Metronome.h.

## Constructor & Destructor Documentation

## ◆ Metronome()

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

Constructor.

Declare a Metronome object.

Parameters

  delay_milliseconds | how long between each occasion when ready() returns true.

Definition at line 31 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 75 of file Metronome.h.

## ◆ set()

void EventDelay::set | ( | unsigned int | delay_milliseconds | ) |
| inline inherited

Set the delay time.

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

Parameters

  delay_milliseconds | delay 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

  bpm | beats per minute

Definition at line 63 of file Metronome.h.

## ◆ start() [1/2]

void Metronome::start | ( |  | ) |
| inline

Start the metronome.

Definition at line 40 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_milliseconds | delay time in milliseconds.

Definition at line 51 of file Metronome.h.