40 #include <px4_platform_common/log.h>    45 #define TUNE_CONTINUE 1    49 #define BEAT_TIME_CONVERSION_MS (60 * 1000 * 4)    50 #define BEAT_TIME_CONVERSION_US BEAT_TIME_CONVERSION_MS * 1000    51 #define BEAT_TIME_CONVERSION    BEAT_TIME_CONVERSION_US    57          unsigned default_octave, 
unsigned default_tempo):
    58     _default_note_length(default_note_length),
    59     _default_note_mode(default_note_mode),
    60     _default_octave(default_octave),
    61     _default_tempo(default_tempo)
    93     if (
_tune == 
nullptr ||        
    98         if (tune_control.
tune_id != static_cast<int>(TuneID::CUSTOM) &&
   110         if (tune_control.
volume <= tune_control_s::VOLUME_LEVEL_MAX) {
   114             _volume = tune_control_s::VOLUME_LEVEL_MAX;
   119         if (tune_control.
tune_id == static_cast<int>(TuneID::CUSTOM)) {
   132         _current_tune_id = tune_control.
tune_id;
   141     if (
_tune == 
nullptr) {
   147         if (volume <= tune_control_s::VOLUME_LEVEL_MAX) {
   151             _volume = tune_control_s::VOLUME_LEVEL_MAX;
   157              unsigned &silence, uint8_t &volume)
   162     if (frequency == 0 || duration == 0) {
   282                 if ((nt >= 32) && (nt <= 255)) {
   337             if (note_length == 0) {
   381     return (
unsigned)(880.0f * powf(2.0
f, ((
int)note - 46) / 12.0
f));
   388     if (note_length == 0) {
   392     unsigned note_period = whole_note_period / note_length;
   396         silence = note_period / 8;
   400         silence = note_period / 4;
   409     note_period -= silence;
   411     unsigned dot_extension = note_period / 2;
   414         note_period += dot_extension;
   425     if (rest_length == 0) {
   429     unsigned rest_period = whole_note_period / rest_length;
   431     unsigned dot_extension = rest_period / 2;
   434         rest_period += dot_extension;
   458         if (!isdigit(next_character)) {
   463         number = (number * 10) + (next_character - 
'0');
 
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. 
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. 
static const bool _default_tunes_interruptable[]
const char * _tune_start_ptr
pointer to repeat tune 
void reset(bool repeat_flag)
Reset the tune parameters. 
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
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
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. 
#define BEAT_TIME_CONVERSION
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