44 #define TUNE_DEFAULT_NOTE_LENGTH 4 45 #define TUNE_DEFAULT_OCTAVE 4 46 #define TUNE_DEFAULT_TEMPO 120 48 #define TUNE_MAX_UPDATE_INTERVAL_US 100000 92 void set_string(
const char *
const string, uint8_t volume);
102 int get_next_note(
unsigned &frequency,
unsigned &duration,
unsigned &silence);
114 unsigned &silence, uint8_t &volume);
145 unsigned note_duration(
unsigned &silence,
unsigned note_length,
unsigned dots)
const;
155 unsigned rest_duration(
unsigned rest_length,
unsigned dots)
const;
183 void reset(
bool repeat_flag);
#define TUNE_DEFAULT_NOTE_LENGTH
Tunes(unsigned default_note_length=TUNE_DEFAULT_NOTE_LENGTH, NoteMode default_note_mode=NoteMode::NORMAL, unsigned default_octave=TUNE_DEFAULT_OCTAVE, unsigned default_tempo=TUNE_DEFAULT_TEMPO)
Constructor with the default parameters set to: default_tempo: TUNE_DEFAULT_TEMPO default_octave: TUN...
int get_next_note(unsigned &frequency, unsigned &duration, unsigned &silence)
Get next note in the current tune, which has been provided by either set_control or play_string...
int next_char()
Find the next character in the string, discard any whitespace.
API for the uORB lightweight object broker.
Driver for the PX4 audio .
static const uint8_t _note_tab[]
unsigned int _default_tempo
unsigned note_duration(unsigned &silence, unsigned note_length, unsigned dots) const
Calculate the duration in microseconds of play and silence for a note given the current tempo...
unsigned next_dots()
Consume dot characters from the string.
Library for parsing tunes from melody-strings or dedicated tune messages.
static const bool _default_tunes_interruptable[]
#define TUNE_DEFAULT_OCTAVE
const char * _tune_start_ptr
pointer to repeat tune
void reset(bool repeat_flag)
Reset the tune parameters.
int set_control(const tune_control_s &tune_control)
Set tune to be played using the message.
static const char *const _default_tunes[]
unsigned next_number()
Extract a number from the string, consuming all the digit characters.
const char * _tune
current tune string
NoteMode _default_note_mode
uint32_t note_to_frequency(unsigned note) const
Convert note to frequency.
unsigned int _default_octave
unsigned int _note_length
#define TUNE_MAX_UPDATE_INTERVAL_US
#define TUNE_DEFAULT_TEMPO
unsigned int _default_note_length
const char * _next_tune
next note in the string
static tune_control_s tune_control
static const unsigned int _default_tunes_size
unsigned rest_duration(unsigned rest_length, unsigned dots) const
Calculate the duration in microseconds of a rest corresponding to a given note length.
unsigned int get_default_tunes_size() const
Get the number of default tunes.
void set_string(const char *const string, uint8_t volume)
Set tune to be played using a string.
bool _repeat
if true, tune restarts at end
unsigned int get_maximum_update_interval()