Metronome

A metronome digital source unit. Emits an “on” signal at a regular pace.

Example

#include <Plaquette.h>

Metronome myMetro(0.5); // a metronome with a half-second duration

DigitalOut led(13);

void begin() {
}

void step() {
  if (myMetro)
  {
    // Change LED state.
    led.toggle();
  }
}

Reference

class Metronome : public DigitalUnit

Chronometer digital unit which emits 1/true/”on” for one frame, at a regular pace.

Public Functions

Metronome(float period = 1.0f)

Constructor.

Parameters:

period – the period of oscillation (in seconds)

inline virtual bool isOn()

Returns true iff the metronome fires.

virtual void period(float period)

Sets the period (in seconds).

Parameters:

period – the period of oscillation (in seconds)

inline virtual float period() const

Returns the period (in seconds).

virtual void frequency(float frequency)

Sets the frequency (in Hz).

Parameters:

frequency – the frequency of oscillation (in Hz)

inline virtual float frequency() const

Returns the frequency (in Hz).

virtual void bpm(float bpm)

Sets the frequency in beats-per-minute.

Parameters:

bpm – the frequency of oscillation (in BPM)

inline virtual float bpm() const

Returns the frequency (in BPM).

virtual void phase(float phase)

Sets the phase (ie.

the offset, in % of period).

Parameters:

phase – the phase (in % of period)

inline virtual float phase() const

Returns the phase (in % of period).

virtual void onBang(EventCallback callback)

Registers event callback on metronome tick event.

inline virtual bool isOff()

Returns true iff the input is “off”.

inline virtual int getInt()

Returns value as integer (0 or 1).

inline virtual float get()

Returns value as float (either 0.0 or 1.0).

See Also