FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::audio::QTonePlay< NTIMER, OUTPUT > Class Template Reference

An optimized surrogate to TonePlay structure. More...

#include <fastarduino/devices/tone_player.h>

Public Member Functions

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

Friends

class AbstractTonePlayer< NTIMER, OUTPUT, QTonePlay< NTIMER, OUTPUT > >
 

Detailed Description

template<board::Timer NTIMER, board::PWMPin OUTPUT>
class devices::audio::QTonePlay< NTIMER, OUTPUT >

An optimized surrogate to TonePlay structure.

Contrarily to TonePlay, it does not store Tone (i.e. frequency) but Timer prescaler and counter for the desired frequency. The advantage is that when you construct a QTonePlay from constant tones, each tone will be converted to timer prescaler and counter at compile-time, hence the generated code is smaller and more efficient; this can be useful when your MCU is limited in data size.

Template Parameters
NTIMERthe AVR timer to use for the underlying Timer
OUTPUTthe board::PWMPin connected to the buzzer; this must be the pin OCnA, where n is the AVR Timer number
See also
TonePlay

Definition at line 268 of file tone_player.h.

Constructor & Destructor Documentation

◆ QTonePlay() [1/3]

template<board::Timer NTIMER, board::PWMPin OUTPUT>
devices::audio::QTonePlay< NTIMER, OUTPUT >::QTonePlay ( )
default

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

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

See also
QTonePlay(Tone, uint16_t)

◆ QTonePlay() [2/3]

template<board::Timer NTIMER, board::PWMPin OUTPUT>
constexpr devices::audio::QTonePlay< NTIMER, OUTPUT >::QTonePlay ( Tone  tone,
Duration  duration 
)
inlineconstexpr

Construct an optimized tone play for the provided tone and duration.

Parameters
tonethe Tone for this QTonePlay; 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 293 of file tone_player.h.

◆ QTonePlay() [3/3]

template<board::Timer NTIMER, board::PWMPin OUTPUT>
constexpr devices::audio::QTonePlay< NTIMER, OUTPUT >::QTonePlay ( Tone  tone,
uint8_t  value = 0 
)
inlineconstexpr

Construct a "special" optimized 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 304 of file tone_player.h.

Friends And Related Function Documentation

◆ AbstractTonePlayer< NTIMER, OUTPUT, QTonePlay< NTIMER, OUTPUT > >

template<board::Timer NTIMER, board::PWMPin OUTPUT>
friend class AbstractTonePlayer< NTIMER, OUTPUT, QTonePlay< NTIMER, OUTPUT > >
friend

Definition at line 385 of file tone_player.h.

Member Data Documentation

◆ duration_

template<board::Timer NTIMER, board::PWMPin OUTPUT>
Duration devices::audio::QTonePlay< NTIMER, OUTPUT >::duration_

Definition at line 368 of file tone_player.h.

◆ repeats_

template<board::Timer NTIMER, board::PWMPin OUTPUT>
uint8_t devices::audio::QTonePlay< NTIMER, OUTPUT >::repeats_

Definition at line 369 of file tone_player.h.

◆ ties_

template<board::Timer NTIMER, board::PWMPin OUTPUT>
uint8_t devices::audio::QTonePlay< NTIMER, OUTPUT >::ties_

Definition at line 370 of file tone_player.h.


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