FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::audio::TonePlay Class Reference

This struct is the unit data manipulated by TonePlayer: it describes one Tone along with its duration in milliseconds. More...

#include <fastarduino/devices/tone_player.h>

Public Member Functions

 TonePlay ()=default
 Default constructor, used only to declare an uninitialized TonePlay variable. More...
 
constexpr TonePlay (Tone tone, Duration duration)
 Construct a tone play with the provided tone and duration. More...
 
constexpr TonePlay (Tone tone, uint8_t value=0)
 Construct a "special" tone play with the provided value. More...
 

Friends

template<board::Timer , board::PWMPin , typename >
class AbstractTonePlayer
 

Detailed Description

This struct is the unit data manipulated by TonePlayer: it describes one Tone along with its duration in milliseconds.

It can also hold special tones as defined in SpecialTone namespace.

Note that, although it is quite easy to define melodies with TonePlay, it is less efficient in terms of code size and performance (this is due to the need to convert tone frequencies to Timer prescaler and counter). It is advised, to use TonePlayer::QTonePlay optimized structure instead.

See also
Tone
TonePlayer
SpecialTone
QTonePlay

Definition at line 161 of file tone_player.h.

Constructor & Destructor Documentation

◆ TonePlay() [1/3]

devices::audio::TonePlay::TonePlay ( )
default

Default constructor, used only to declare an uninitialized TonePlay variable.

You should always ensure you replace such a variable with one constructed with the next constructor.

See also
TonePlay(Tone, uint8_t)

◆ TonePlay() [2/3]

constexpr devices::audio::TonePlay::TonePlay ( Tone  tone,
Duration  duration 
)
inlineconstexpr

Construct a tone play with the provided tone and duration.

Parameters
tonethe Tone for this TonePlay; it will be automatically converted (at compile-time if t is a constant) to the proper timer prescaler and counter.
durationthe duration of this note.

Definition at line 186 of file tone_player.h.

◆ TonePlay() [3/3]

constexpr devices::audio::TonePlay::TonePlay ( Tone  tone,
uint8_t  value = 0 
)
inlineconstexpr

Construct a "special" tone play with the provided value.

Parameters
tonethe special tone (as defined in SpecialTone namespace)
valueadditional value which meaning depends on actual tone: number of repeats for SpecialTone::REPEAT_END, number of ties or slurs between successive notes for SpecialTone::TIE.

Definition at line 196 of file tone_player.h.

Friends And Related Function Documentation

◆ AbstractTonePlayer

template<board::Timer , board::PWMPin , typename >
friend class AbstractTonePlayer
friend

Definition at line 250 of file tone_player.h.

Member Data Documentation

◆ duration_

Duration devices::audio::TonePlay::duration_

Definition at line 245 of file tone_player.h.

◆ repeats_

uint8_t devices::audio::TonePlay::repeats_

Definition at line 246 of file tone_player.h.

◆ ties_

uint8_t devices::audio::TonePlay::ties_

Definition at line 247 of file tone_player.h.


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