Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
buzzer_tunes.c File Reference

Play tunes on a passive piezo buzzer (e.g. More...

#include "modules/sound/buzzer_tunes.h"
#include "modules/sound/buzzer_arch.h"
#include "mcu_periph/sys_time.h"
#include "generated/airframe.h"
Include dependency graph for buzzer_tunes.c:

Go to the source code of this file.

Data Structures

struct  buzzer_note

Macros

#define BUZZER_TUNES_EVENTS_ON   FALSE
 Optional header needed by the alert condition.
#define BUZZER_TUNES_ALERT_TUNE   BUZZER_TUNES_NONE
 Tune played in a loop while the motors are armed (optional), stopped when disarmed.
#define BUZZER_TUNES_ALERT_END_TUNE   BUZZER_TUNES_NONE
 Tune played once when BUZZER_TUNES_ALERT becomes false (stopped if the motors are disarmed).
#define BUZZER_TUNES_STARTUP_TUNE   BUZZER_TUNES_STARTUP
 Tune played at startup, BUZZER_TUNES_NONE for silence.
#define BUZZER_TUNES_GAP_MS   30
 Silence at the end of each note, so repeated notes are heard separately [ms].
#define REST   0
 Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter).
#define C4   262
#define Cs4   277
#define D4   294
#define Ds4   311
#define E4   330
#define F4   349
#define Fs4   370
#define G4   392
#define Gs4   415
#define A4   440
#define As4   466
#define B4   494
#define C5   523
#define Cs5   554
#define D5   587
#define Ds5   622
#define E5   659
#define F5   698
#define Fs5   740
#define G5   784
#define Gs5   831
#define A5   880
#define As5   932
#define B5   988
#define C6   1047
#define Cs6   1109
#define D6   1175
#define Ds6   1245
#define E6   1319
#define F6   1397
#define Fs6   1480
#define G6   1568
#define Gs6   1661
#define A6   1760
#define As6   1865
#define B6   1976
#define C7   2093
#define Cs7   2217
#define D7   2349
#define Ds7   2489
#define E7   2637
#define F7   2794
#define Fs7   2960
#define G7   3136
#define Gs7   3322
#define A7   3520
#define As7   3729
#define B7   3951
#define BEATS(_b, _bpm)
 Duration of a number of beats at a tempo [ms].
#define TUNE_END   {0, 0}
#define BUZZER_TUNES_RTTTL_1   ""
 Custom tunes (Custom 1..3) in RTTTL format ("name:d=4,o=6,b=120:c,e,g"), set in the airframe, empty for none.
#define BUZZER_TUNES_RTTTL_2   ""
#define BUZZER_TUNES_RTTTL_3   ""
#define IT_BPM   112
 Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain).
#define NL_BPM   90
 Netherlands, Wilhelmus, first verse (16th century, public domain).
#define FR_BPM   105
 France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792, public domain).

Functions

static void tune_start (uint8_t tune)
static uint16_t rtttl_number (const char **p)
static bool rtttl_start (const char *str)
 Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid.
static bool rtttl_next (struct buzzer_note *n)
 Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end.
static bool next_note (struct buzzer_note *n)
 Get the next note of the tune, false at the end.
static void start_next_note (void)
void buzzer_tunes_play (uint8_t tune)
 Start a tune (BUZZER_TUNES_NONE stops), also the settings handler.
static void event_start (uint8_t tune)
 Start a tune from an event.
void buzzer_tunes_set_events (uint8_t on)
 Settings handler: enable or disable the armed and alert tunes.
void buzzer_tunes_init (void)
static void event_update (void)
 Event tunes: alert tune in a loop while the alert condition is true, armed tune in a loop while the motors are armed.
void buzzer_tunes_periodic (void)

Variables

static const struct buzzer_note tune_startup []
 Short rising arpeggio.
static const struct buzzer_note tune_ode_to_joy []
 Beethoven, Ode to Joy, full theme (public domain).
static const struct buzzer_note tune_twinkle []
 Twinkle Twinkle Little Star, full song (public domain).
static const struct buzzer_note tune_anthem_italy []
static const struct buzzer_note tune_anthem_netherlands []
static const struct buzzer_note tune_anthem_france []
static const struct buzzer_note tune_happy_birthday []
 Happy Birthday (public domain).
static const struct buzzer_note tune_mushroom []
 Mushroom Song.
static const struct buzzer_note tune_gran_vals []
 Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain).
static const struct buzzer_note tune_fur_elise []
 Beethoven, Fur Elise, first section (public domain).
static const struct buzzer_note tune_la_cucaracha []
 La Cucaracha, chorus (traditional, public domain).
static const struct buzzer_note tune_william_tell []
 Rossini, William Tell Overture, galop opening, played twice (public domain).
static const struct buzzer_note tune_star []
 Star Song.
static const struct buzzer_note *const buzzer_tunes_list [BUZZER_TUNES_CUSTOM_1]
static const char *const buzzer_tunes_custom []
 Custom tunes, RTTTL strings.
uint8_t buzzer_tunes_tune = BUZZER_TUNES_NONE
 tune being played, BUZZER_TUNES_NONE when silent
static const struct buzzer_note * tune_notes = NULL
 next note of a built-in tune
static const char * rtttl = NULL
 next note of a RTTTL tune
static uint8_t rtttl_d = 4
static uint8_t rtttl_o = 6
 RTTTL default duration and octave.
static uint16_t rtttl_bpm = 63
 RTTTL tempo.
static struct buzzer_note note
 note being played
static bool playing = false
static uint32_t note_start_ms = 0
 start time of the note
static bool note_gap = false
 in the silent gap at the end of the note
uint8_t buzzer_tunes_events_on = BUZZER_TUNES_EVENTS_ON
 armed and alert tunes enabled
static bool event_tune = false
 current tune was started by an event

Detailed Description

Play tunes on a passive piezo buzzer (e.g.

a startup tune)

Definition in file buzzer_tunes.c.


Data Structure Documentation

◆ buzzer_note

struct buzzer_note

Definition at line 118 of file buzzer_tunes.c.

Data Fields
uint16_t freq [Hz], REST for silence
uint16_t ms duration [ms]

Macro Definition Documentation

◆ A4

#define A4   440

Definition at line 75 of file buzzer_tunes.c.

◆ A5

#define A5   880

Definition at line 87 of file buzzer_tunes.c.

◆ A6

#define A6   1760

Definition at line 99 of file buzzer_tunes.c.

◆ A7

#define A7   3520

Definition at line 111 of file buzzer_tunes.c.

◆ As4

#define As4   466

Definition at line 76 of file buzzer_tunes.c.

◆ As5

#define As5   932

Definition at line 88 of file buzzer_tunes.c.

◆ As6

#define As6   1865

Definition at line 100 of file buzzer_tunes.c.

◆ As7

#define As7   3729

Definition at line 112 of file buzzer_tunes.c.

◆ B4

#define B4   494

Definition at line 77 of file buzzer_tunes.c.

◆ B5

#define B5   988

Definition at line 89 of file buzzer_tunes.c.

◆ B6

#define B6   1976

Definition at line 101 of file buzzer_tunes.c.

◆ B7

#define B7   3951

Definition at line 113 of file buzzer_tunes.c.

◆ BEATS

#define BEATS ( _b,
_bpm )
Value:
((uint16_t)((_b) * 60000.0 / (_bpm)))
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.

Duration of a number of beats at a tempo [ms].

Definition at line 116 of file buzzer_tunes.c.

◆ BUZZER_TUNES_ALERT_END_TUNE

#define BUZZER_TUNES_ALERT_END_TUNE   BUZZER_TUNES_NONE

Tune played once when BUZZER_TUNES_ALERT becomes false (stopped if the motors are disarmed).

Definition at line 53 of file buzzer_tunes.c.

Referenced by event_update().

◆ BUZZER_TUNES_ALERT_TUNE

#define BUZZER_TUNES_ALERT_TUNE   BUZZER_TUNES_NONE

Tune played in a loop while the motors are armed (optional), stopped when disarmed.

Tune played in a loop while BUZZER_TUNES_ALERT is true (optional condition)

Definition at line 48 of file buzzer_tunes.c.

Referenced by event_update().

◆ BUZZER_TUNES_EVENTS_ON

#define BUZZER_TUNES_EVENTS_ON   FALSE

Optional header needed by the alert condition.

Event tunes (armed and alert tunes) enabled at startup, off by default

Definition at line 38 of file buzzer_tunes.c.

◆ BUZZER_TUNES_GAP_MS

#define BUZZER_TUNES_GAP_MS   30

Silence at the end of each note, so repeated notes are heard separately [ms].

Definition at line 62 of file buzzer_tunes.c.

Referenced by buzzer_tunes_periodic().

◆ BUZZER_TUNES_RTTTL_1

#define BUZZER_TUNES_RTTTL_1   ""

Custom tunes (Custom 1..3) in RTTTL format ("name:d=4,o=6,b=120:c,e,g"), set in the airframe, empty for none.

Definition at line 127 of file buzzer_tunes.c.

◆ BUZZER_TUNES_RTTTL_2

#define BUZZER_TUNES_RTTTL_2   ""

Definition at line 130 of file buzzer_tunes.c.

◆ BUZZER_TUNES_RTTTL_3

#define BUZZER_TUNES_RTTTL_3   ""

Definition at line 133 of file buzzer_tunes.c.

◆ BUZZER_TUNES_STARTUP_TUNE

#define BUZZER_TUNES_STARTUP_TUNE   BUZZER_TUNES_STARTUP

Tune played at startup, BUZZER_TUNES_NONE for silence.

Definition at line 58 of file buzzer_tunes.c.

Referenced by buzzer_tunes_init().

◆ C4

#define C4   262

Definition at line 66 of file buzzer_tunes.c.

◆ C5

#define C5   523

Definition at line 78 of file buzzer_tunes.c.

◆ C6

#define C6   1047

Definition at line 90 of file buzzer_tunes.c.

◆ C7

#define C7   2093

Definition at line 102 of file buzzer_tunes.c.

◆ Cs4

#define Cs4   277

Definition at line 67 of file buzzer_tunes.c.

◆ Cs5

#define Cs5   554

Definition at line 79 of file buzzer_tunes.c.

◆ Cs6

#define Cs6   1109

Definition at line 91 of file buzzer_tunes.c.

◆ Cs7

#define Cs7   2217

Definition at line 103 of file buzzer_tunes.c.

◆ D4

#define D4   294

Definition at line 68 of file buzzer_tunes.c.

◆ D5

#define D5   587

Definition at line 80 of file buzzer_tunes.c.

◆ D6

#define D6   1175

Definition at line 92 of file buzzer_tunes.c.

◆ D7

#define D7   2349

Definition at line 104 of file buzzer_tunes.c.

◆ Ds4

#define Ds4   311

Definition at line 69 of file buzzer_tunes.c.

◆ Ds5

#define Ds5   622

Definition at line 81 of file buzzer_tunes.c.

◆ Ds6

#define Ds6   1245

Definition at line 93 of file buzzer_tunes.c.

◆ Ds7

#define Ds7   2489

Definition at line 105 of file buzzer_tunes.c.

◆ E4

#define E4   330

Definition at line 70 of file buzzer_tunes.c.

◆ E5

#define E5   659

Definition at line 82 of file buzzer_tunes.c.

◆ E6

#define E6   1319

Definition at line 94 of file buzzer_tunes.c.

Referenced by nps_flight_gear_loop(), nps_main_loop(), and nps_sensors_loop().

◆ E7

#define E7   2637

Definition at line 106 of file buzzer_tunes.c.

◆ F4

#define F4   349

Definition at line 71 of file buzzer_tunes.c.

◆ F5

#define F5   698

Definition at line 83 of file buzzer_tunes.c.

◆ F6

#define F6   1397

Definition at line 95 of file buzzer_tunes.c.

◆ F7

#define F7   2794

Definition at line 107 of file buzzer_tunes.c.

◆ FR_BPM

#define FR_BPM   105

France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792, public domain).

Definition at line 200 of file buzzer_tunes.c.

◆ Fs4

#define Fs4   370

Definition at line 72 of file buzzer_tunes.c.

◆ Fs5

#define Fs5   740

Definition at line 84 of file buzzer_tunes.c.

◆ Fs6

#define Fs6   1480

Definition at line 96 of file buzzer_tunes.c.

◆ Fs7

#define Fs7   2960

Definition at line 108 of file buzzer_tunes.c.

◆ G4

#define G4   392

Definition at line 73 of file buzzer_tunes.c.

◆ G5

#define G5   784

Definition at line 85 of file buzzer_tunes.c.

◆ G6

#define G6   1568

Definition at line 97 of file buzzer_tunes.c.

◆ G7

#define G7   3136

Definition at line 109 of file buzzer_tunes.c.

◆ Gs4

#define Gs4   415

Definition at line 74 of file buzzer_tunes.c.

◆ Gs5

#define Gs5   831

Definition at line 86 of file buzzer_tunes.c.

◆ Gs6

#define Gs6   1661

Definition at line 98 of file buzzer_tunes.c.

◆ Gs7

#define Gs7   3322

Definition at line 110 of file buzzer_tunes.c.

◆ IT_BPM

#define IT_BPM   112

Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain).

Definition at line 164 of file buzzer_tunes.c.

◆ NL_BPM

#define NL_BPM   90

Netherlands, Wilhelmus, first verse (16th century, public domain).

Definition at line 183 of file buzzer_tunes.c.

◆ REST

#define REST   0

Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter).

Definition at line 65 of file buzzer_tunes.c.

Referenced by rtttl_next().

◆ TUNE_END

#define TUNE_END   {0, 0}

Definition at line 123 of file buzzer_tunes.c.

Function Documentation

◆ buzzer_tunes_init()

void buzzer_tunes_init ( void )

Definition at line 512 of file buzzer_tunes.c.

References buzzer_arch_init(), buzzer_tunes_play(), and BUZZER_TUNES_STARTUP_TUNE.

Here is the call graph for this function:

◆ buzzer_tunes_periodic()

void buzzer_tunes_periodic ( void )

Definition at line 558 of file buzzer_tunes.c.

References buzzer_arch_tone(), BUZZER_TUNES_GAP_MS, event_update(), get_sys_time_msec(), note, note_gap, note_start_ms, playing, and start_next_note().

Here is the call graph for this function:

◆ buzzer_tunes_play()

void buzzer_tunes_play ( uint8_t tune)

Start a tune (BUZZER_TUNES_NONE stops), also the settings handler.

Definition at line 451 of file buzzer_tunes.c.

References BUZZER_TUNES_NONE, and tune_start().

Referenced by buzzer_tunes_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buzzer_tunes_set_events()

void buzzer_tunes_set_events ( uint8_t on)

Settings handler: enable or disable the armed and alert tunes.

Definition at line 472 of file buzzer_tunes.c.

References buzzer_tunes_events_on, BUZZER_TUNES_NONE, event_tune, and tune_start().

Here is the call graph for this function:

◆ event_start()

void event_start ( uint8_t tune)
static

Start a tune from an event.

Definition at line 466 of file buzzer_tunes.c.

References BUZZER_TUNES_NONE, buzzer_tunes_tune, event_tune, and tune_start().

Referenced by event_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ event_update()

void event_update ( void )
static

Event tunes: alert tune in a loop while the alert condition is true, armed tune in a loop while the motors are armed.

Definition at line 521 of file buzzer_tunes.c.

References autopilot_get_motors_on(), BUZZER_TUNES_ALERT_END_TUNE, BUZZER_TUNES_ALERT_TUNE, buzzer_tunes_events_on, BUZZER_TUNES_NONE, event_start(), event_tune, playing, and tune_start().

Referenced by buzzer_tunes_periodic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_note()

bool next_note ( struct buzzer_note * n)
static

Get the next note of the tune, false at the end.

Definition at line 427 of file buzzer_tunes.c.

References rtttl, rtttl_next(), and tune_notes.

Referenced by start_next_note().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtttl_next()

bool rtttl_next ( struct buzzer_note * n)
static

Parse the next RTTTL note "[duration]note[#][.][octave][.]", false at the end.

Definition at line 390 of file buzzer_tunes.c.

References f, buzzer_note::freq, Min, buzzer_note::ms, p, REST, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.

Referenced by next_note().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtttl_number()

uint16_t rtttl_number ( const char ** p)
static

Definition at line 355 of file buzzer_tunes.c.

References p.

Referenced by rtttl_next(), and rtttl_start().

Here is the caller graph for this function:

◆ rtttl_start()

bool rtttl_start ( const char * str)
static

Parse the RTTTL header "name:d=4,o=6,b=120:", false if invalid.

Definition at line 365 of file buzzer_tunes.c.

References p, rtttl, rtttl_bpm, rtttl_d, rtttl_number(), and rtttl_o.

Referenced by tune_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_next_note()

void start_next_note ( void )
static

Definition at line 440 of file buzzer_tunes.c.

References buzzer_arch_tone(), BUZZER_TUNES_NONE, get_sys_time_msec(), next_note(), note, note_gap, note_start_ms, and tune_start().

Referenced by buzzer_tunes_periodic(), and tune_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tune_start()

void tune_start ( uint8_t tune)
static

Variable Documentation

◆ buzzer_tunes_custom

const char* const buzzer_tunes_custom[]
static
Initial value:
= {
}
#define BUZZER_TUNES_RTTTL_1
Custom tunes (Custom 1..3) in RTTTL format ("name:d=4,o=6,b=120:c,e,g"), set in the airframe,...
#define BUZZER_TUNES_RTTTL_3
#define BUZZER_TUNES_RTTTL_2

Custom tunes, RTTTL strings.

Definition at line 327 of file buzzer_tunes.c.

Referenced by tune_start().

◆ buzzer_tunes_events_on

uint8_t buzzer_tunes_events_on = BUZZER_TUNES_EVENTS_ON

armed and alert tunes enabled

Definition at line 342 of file buzzer_tunes.c.

Referenced by buzzer_tunes_set_events(), and event_update().

◆ buzzer_tunes_list

const struct buzzer_note* const buzzer_tunes_list[BUZZER_TUNES_CUSTOM_1]
static
Initial value:
= {
}
static const struct buzzer_note tune_startup[]
Short rising arpeggio.
static const struct buzzer_note tune_star[]
Star Song.
static const struct buzzer_note tune_twinkle[]
Twinkle Twinkle Little Star, full song (public domain).
static const struct buzzer_note tune_william_tell[]
Rossini, William Tell Overture, galop opening, played twice (public domain).
static const struct buzzer_note tune_anthem_netherlands[]
static const struct buzzer_note tune_la_cucaracha[]
La Cucaracha, chorus (traditional, public domain).
static const struct buzzer_note tune_ode_to_joy[]
Beethoven, Ode to Joy, full theme (public domain).
static const struct buzzer_note tune_gran_vals[]
Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain).
static const struct buzzer_note tune_mushroom[]
Mushroom Song.
static const struct buzzer_note tune_anthem_france[]
static const struct buzzer_note tune_fur_elise[]
Beethoven, Fur Elise, first section (public domain).
static const struct buzzer_note tune_anthem_italy[]
static const struct buzzer_note tune_happy_birthday[]
Happy Birthday (public domain).
@ BUZZER_TUNES_TWINKLE
@ BUZZER_TUNES_STARTUP
@ BUZZER_TUNES_STAR
@ BUZZER_TUNES_MUSHROOM
@ BUZZER_TUNES_FUR_ELISE
@ BUZZER_TUNES_ODE_TO_JOY
@ BUZZER_TUNES_WILLIAM_TELL
@ BUZZER_TUNES_ANTHEM_NETHERLANDS
@ BUZZER_TUNES_HAPPY_BIRTHDAY
@ BUZZER_TUNES_ANTHEM_ITALY
@ BUZZER_TUNES_NONE
@ BUZZER_TUNES_ANTHEM_FRANCE
@ BUZZER_TUNES_GRAN_VALS
@ BUZZER_TUNES_LA_CUCARACHA

Definition at line 309 of file buzzer_tunes.c.

Referenced by tune_start().

◆ buzzer_tunes_tune

uint8_t buzzer_tunes_tune = BUZZER_TUNES_NONE

tune being played, BUZZER_TUNES_NONE when silent

Definition at line 331 of file buzzer_tunes.c.

Referenced by event_start(), and tune_start().

◆ event_tune

bool event_tune = false
static

current tune was started by an event

Definition at line 343 of file buzzer_tunes.c.

Referenced by buzzer_tunes_set_events(), event_start(), event_update(), and tune_start().

◆ note

struct buzzer_note note
static

note being played

Definition at line 337 of file buzzer_tunes.c.

Referenced by buzzer_tunes_periodic(), and start_next_note().

◆ note_gap

bool note_gap = false
static

in the silent gap at the end of the note

Definition at line 340 of file buzzer_tunes.c.

Referenced by buzzer_tunes_periodic(), and start_next_note().

◆ note_start_ms

uint32_t note_start_ms = 0
static

start time of the note

Definition at line 339 of file buzzer_tunes.c.

Referenced by buzzer_tunes_periodic(), and start_next_note().

◆ playing

bool playing = false
static

Definition at line 338 of file buzzer_tunes.c.

Referenced by buzzer_tunes_periodic(), event_update(), and tune_start().

◆ rtttl

const char* rtttl = NULL
static

next note of a RTTTL tune

Definition at line 334 of file buzzer_tunes.c.

Referenced by next_note(), rtttl_next(), rtttl_start(), and tune_start().

◆ rtttl_bpm

uint16_t rtttl_bpm = 63
static

RTTTL tempo.

Definition at line 336 of file buzzer_tunes.c.

Referenced by rtttl_next(), and rtttl_start().

◆ rtttl_d

uint8_t rtttl_d = 4
static

Definition at line 335 of file buzzer_tunes.c.

Referenced by rtttl_next(), and rtttl_start().

◆ rtttl_o

uint8_t rtttl_o = 6
static

RTTTL default duration and octave.

Definition at line 335 of file buzzer_tunes.c.

Referenced by rtttl_next(), and rtttl_start().

◆ tune_anthem_france

const struct buzzer_note tune_anthem_france[]
static
Initial value:
= {
{D5, BEATS(0.25, FR_BPM)}, {D5, BEATS(0.75, FR_BPM)}, {D5, BEATS(0.25, FR_BPM)}, {G5, BEATS(1, FR_BPM)},
{G5, BEATS(1, FR_BPM)}, {A5, BEATS(1, FR_BPM)}, {A5, BEATS(1, FR_BPM)}, {D6, BEATS(1.5, FR_BPM)},
{B5, BEATS(0.5, FR_BPM)}, {G5, BEATS(0.75, FR_BPM)}, {G5, BEATS(0.25, FR_BPM)}, {B5, BEATS(0.75, FR_BPM)},
{G5, BEATS(0.25, FR_BPM)}, {E5, BEATS(1, FR_BPM)}, {C6, BEATS(1, FR_BPM)}, {REST, BEATS(1, FR_BPM)},
{A5, BEATS(0.75, FR_BPM)}, {Fs5, BEATS(0.25, FR_BPM)}, {G5, BEATS(1, FR_BPM)}, {REST, BEATS(2, FR_BPM)},
{G5, BEATS(0.75, FR_BPM)}, {A5, BEATS(0.25, FR_BPM)}, {B5, BEATS(1, FR_BPM)}, {B5, BEATS(1, FR_BPM)},
{B5, BEATS(1, FR_BPM)}, {C6, BEATS(0.75, FR_BPM)}, {B5, BEATS(0.25, FR_BPM)}, {B5, BEATS(1, FR_BPM)},
{A5, BEATS(1, FR_BPM)}, {REST, BEATS(1, FR_BPM)}, {A5, BEATS(0.75, FR_BPM)}, {B5, BEATS(0.25, FR_BPM)},
{C6, BEATS(1, FR_BPM)}, {C6, BEATS(1, FR_BPM)}, {C6, BEATS(1, FR_BPM)}, {D6, BEATS(0.75, FR_BPM)},
{C6, BEATS(0.25, FR_BPM)}, {B5, BEATS(1, FR_BPM)}, {REST, BEATS(2, FR_BPM)}, {D6, BEATS(0.75, FR_BPM)},
{D6, BEATS(0.25, FR_BPM)}, {D6, BEATS(1, FR_BPM)}, {B5, BEATS(0.75, FR_BPM)}, {G5, BEATS(0.25, FR_BPM)},
{D6, BEATS(1, FR_BPM)}, {B5, BEATS(0.75, FR_BPM)}, {G5, BEATS(0.25, FR_BPM)}, {D5, BEATS(3, FR_BPM)}, TUNE_END
}
#define G5
#define D5
#define TUNE_END
#define C6
#define Fs5
#define FR_BPM
France, La Marseillaise, opening to "l'étendard sanglant est levé" (Rouget de Lisle 1792,...
#define A5
#define D6
#define E5
#define B5
#define BEATS(_b, _bpm)
Duration of a number of beats at a tempo [ms].
#define REST
Note frequencies [Hz], s for sharp, octaves 5 to 7 sound loudest on a piezo (octave 4 is quieter).

Definition at line 201 of file buzzer_tunes.c.

◆ tune_anthem_italy

const struct buzzer_note tune_anthem_italy[]
static
Initial value:
= {
{F5, BEATS(1, IT_BPM)}, {F5, BEATS(0.75, IT_BPM)}, {G5, BEATS(0.25, IT_BPM)}, {F5, BEATS(1, IT_BPM)},
{REST, BEATS(1, IT_BPM)}, {D6, BEATS(1, IT_BPM)}, {D6, BEATS(0.75, IT_BPM)}, {Ds6, BEATS(0.25, IT_BPM)},
{D6, BEATS(1, IT_BPM)}, {REST, BEATS(1, IT_BPM)}, {D6, BEATS(1, IT_BPM)}, {F6, BEATS(0.75, IT_BPM)},
{Ds6, BEATS(0.25, IT_BPM)}, {D6, BEATS(2, IT_BPM)}, {C6, BEATS(1, IT_BPM)}, {D6, BEATS(0.75, IT_BPM)},
{C6, BEATS(0.25, IT_BPM)}, {As5, BEATS(1, IT_BPM)}, {REST, BEATS(1, IT_BPM)}, {D6, BEATS(1, IT_BPM)},
{D6, BEATS(1, IT_BPM)}, {A5, BEATS(2, IT_BPM)}, {As5, BEATS(0.75, IT_BPM)}, {C6, BEATS(0.25, IT_BPM)},
{As5, BEATS(0.75, IT_BPM)}, {A5, BEATS(0.25, IT_BPM)}, {G5, BEATS(1, IT_BPM)}, {REST, BEATS(1, IT_BPM)},
{As5, BEATS(1, IT_BPM)}, {A5, BEATS(0.75, IT_BPM)}, {As5, BEATS(0.25, IT_BPM)}, {C6, BEATS(1, IT_BPM)},
{REST, BEATS(1, IT_BPM)}, {D5, BEATS(1, IT_BPM)}, {D6, BEATS(2, IT_BPM)}, {Ds6, BEATS(1, IT_BPM)},
{F5, BEATS(1, IT_BPM)}, {F5, BEATS(0.75, IT_BPM)}, {G5, BEATS(0.25, IT_BPM)}, {F5, BEATS(0.5, IT_BPM)},
{REST, BEATS(1.5, IT_BPM)}, {D6, BEATS(1, IT_BPM)}, {D6, BEATS(0.75, IT_BPM)}, {Ds6, BEATS(0.25, IT_BPM)},
{D6, BEATS(2, IT_BPM)}, {D6, BEATS(1, IT_BPM)}, {F6, BEATS(0.75, IT_BPM)}, {Ds6, BEATS(0.25, IT_BPM)},
{D6, BEATS(1.5, IT_BPM)}, {F6, BEATS(0.5, IT_BPM)}, {C6, BEATS(0.5, IT_BPM)}, {F6, BEATS(0.5, IT_BPM)},
}
#define F5
#define IT_BPM
Italy, Il Canto degli Italiani, first verse (Novaro 1847, public domain).
#define Ds6
#define As5
#define F6

Definition at line 165 of file buzzer_tunes.c.

◆ tune_anthem_netherlands

const struct buzzer_note tune_anthem_netherlands[]
static
Initial value:
= {
{D5, BEATS(1, NL_BPM)}, {G5, BEATS(1, NL_BPM)}, {G5, BEATS(1, NL_BPM)}, {A5, BEATS(0.5, NL_BPM)},
{B5, BEATS(0.5, NL_BPM)}, {C6, BEATS(0.5, NL_BPM)}, {A5, BEATS(0.5, NL_BPM)}, {B5, BEATS(1, NL_BPM)},
{A5, BEATS(0.5, NL_BPM)}, {B5, BEATS(0.5, NL_BPM)}, {C6, BEATS(1, NL_BPM)}, {B5, BEATS(1, NL_BPM)},
{A5, BEATS(0.5, NL_BPM)}, {G5, BEATS(0.5, NL_BPM)}, {A5, BEATS(1, NL_BPM)}, {G5, BEATS(3, NL_BPM)},
{B5, BEATS(0.5, NL_BPM)}, {C6, BEATS(0.5, NL_BPM)}, {D6, BEATS(2, NL_BPM)}, {E6, BEATS(1, NL_BPM)},
{D6, BEATS(2, NL_BPM)}, {C6, BEATS(1, NL_BPM)}, {B5, BEATS(1, NL_BPM)}, {A5, BEATS(0.5, NL_BPM)},
{B5, BEATS(0.5, NL_BPM)}, {C6, BEATS(1, NL_BPM)}, {B5, BEATS(1, NL_BPM)}, {A5, BEATS(1, NL_BPM)},
{G5, BEATS(1, NL_BPM)}, {A5, BEATS(3, NL_BPM)}, {D5, BEATS(1, NL_BPM)}, {G5, BEATS(0.5, NL_BPM)},
{Fs5, BEATS(0.5, NL_BPM)}, {G5, BEATS(0.5, NL_BPM)}, {A5, BEATS(0.5, NL_BPM)}, {B5, BEATS(1, NL_BPM)},
{A5, BEATS(2, NL_BPM)}, {G5, BEATS(1, NL_BPM)}, {Fs5, BEATS(1, NL_BPM)}, {D5, BEATS(1, NL_BPM)},
{E5, BEATS(0.5, NL_BPM)}, {Fs5, BEATS(0.5, NL_BPM)}, {G5, BEATS(1, NL_BPM)}, {G5, BEATS(1, NL_BPM)},
}
#define NL_BPM
Netherlands, Wilhelmus, first verse (16th century, public domain).
#define E6

Definition at line 184 of file buzzer_tunes.c.

◆ tune_fur_elise

const struct buzzer_note tune_fur_elise[]
static
Initial value:
= {
{E6, 150}, {Ds6, 150}, {E6, 150}, {Ds6, 150}, {E6, 150}, {B5, 150}, {D6, 150}, {C6, 150},
{A5, 300}, {REST, 150}, {C5, 150}, {E5, 150}, {A5, 150}, {B5, 300}, {REST, 150},
{E5, 150}, {Gs5, 150}, {B5, 150}, {C6, 300}, {REST, 150}, {E5, 150}, {E6, 150}, {Ds6, 150},
{E6, 150}, {Ds6, 150}, {E6, 150}, {B5, 150}, {D6, 150}, {C6, 150},
{A5, 300}, {REST, 150}, {C5, 150}, {E5, 150}, {A5, 150}, {B5, 300}, {REST, 150},
{E5, 150}, {C6, 150}, {B5, 150}, {A5, 600}, TUNE_END
}
#define C5
#define Gs5

Beethoven, Fur Elise, first section (public domain).

Definition at line 266 of file buzzer_tunes.c.

◆ tune_gran_vals

const struct buzzer_note tune_gran_vals[]
static
Initial value:
= {
{E6, 160}, {D6, 160}, {Fs5, 320}, {Gs5, 320}, {Cs6, 160}, {B5, 160}, {D5, 320}, {E5, 320},
{B5, 160}, {A5, 160}, {Cs5, 320}, {E5, 320}, {A5, 960}, TUNE_END
}
#define Cs5
#define Cs6

Tarrega, Gran Vals, the phrase known as the Nokia ringtone (public domain).

Definition at line 260 of file buzzer_tunes.c.

◆ tune_happy_birthday

const struct buzzer_note tune_happy_birthday[]
static
Initial value:
= {
{G5, 300}, {G5, 100}, {A5, 400}, {G5, 400}, {C6, 400}, {B5, 800},
{G5, 300}, {G5, 100}, {A5, 400}, {G5, 400}, {D6, 400}, {C6, 800},
{G5, 300}, {G5, 100}, {G6, 400}, {E6, 400}, {C6, 400}, {B5, 400}, {A5, 800},
{F6, 300}, {F6, 100}, {E6, 400}, {C6, 400}, {D6, 400}, {C6, 800}, TUNE_END
}
#define G6

Happy Birthday (public domain).

Definition at line 217 of file buzzer_tunes.c.

◆ tune_la_cucaracha

const struct buzzer_note tune_la_cucaracha[]
static
Initial value:
= {
{C6, 150}, {C6, 150}, {C6, 150}, {F6, 450}, {A6, 300},
{C6, 150}, {C6, 150}, {C6, 150}, {F6, 450}, {A6, 600},
{F6, 300}, {F6, 150}, {E6, 150}, {E6, 150}, {D6, 150}, {D6, 150}, {C6, 600},
{C6, 150}, {C6, 150}, {C6, 150}, {E6, 450}, {G6, 300},
{C6, 150}, {C6, 150}, {C6, 150}, {E6, 450}, {G6, 600},
{C7, 300}, {D7, 150}, {C7, 150}, {As6, 150}, {A6, 150}, {G6, 150}, {F6, 600}, TUNE_END
}
#define D7
#define A6
#define As6
#define C7

La Cucaracha, chorus (traditional, public domain).

Definition at line 276 of file buzzer_tunes.c.

◆ tune_mushroom

const struct buzzer_note tune_mushroom[]
static

Mushroom Song.

Definition at line 226 of file buzzer_tunes.c.

◆ tune_notes

const struct buzzer_note* tune_notes = NULL
static

next note of a built-in tune

Definition at line 333 of file buzzer_tunes.c.

Referenced by next_note(), and tune_start().

◆ tune_ode_to_joy

const struct buzzer_note tune_ode_to_joy[]
static
Initial value:
= {
{E6, 300}, {E6, 300}, {F6, 300}, {G6, 300}, {G6, 300}, {F6, 300}, {E6, 300}, {D6, 300},
{C6, 300}, {C6, 300}, {D6, 300}, {E6, 300}, {E6, 450}, {D6, 150}, {D6, 600},
{E6, 300}, {E6, 300}, {F6, 300}, {G6, 300}, {G6, 300}, {F6, 300}, {E6, 300}, {D6, 300},
{C6, 300}, {C6, 300}, {D6, 300}, {E6, 300}, {D6, 450}, {C6, 150}, {C6, 600},
{D6, 300}, {D6, 300}, {E6, 300}, {C6, 300}, {D6, 300}, {E6, 150}, {F6, 150}, {E6, 300}, {C6, 300},
{D6, 300}, {E6, 150}, {F6, 150}, {E6, 300}, {D6, 300}, {C6, 300}, {D6, 300}, {G5, 600},
{E6, 300}, {E6, 300}, {F6, 300}, {G6, 300}, {G6, 300}, {F6, 300}, {E6, 300}, {D6, 300},
{C6, 300}, {C6, 300}, {D6, 300}, {E6, 300}, {D6, 450}, {C6, 150}, {C6, 600}, TUNE_END
}

Beethoven, Ode to Joy, full theme (public domain).

Definition at line 142 of file buzzer_tunes.c.

◆ tune_star

const struct buzzer_note tune_star[]
static
Initial value:
= {
{C7, 150}, {REST, 50}, {C7, 150}, {REST, 50}, {C7, 150}, {REST, 150}, {C7, 150}, {REST, 50},
{C7, 150}, {REST, 150}, {C7, 80}, {REST, 20}, {C7, 80}, {REST, 20}, {C7, 150}, {REST, 50},
{B6, 150}, {REST, 50}, {B6, 150}, {REST, 50}, {B6, 150}, {REST, 150}, {B6, 150}, {REST, 50},
{B6, 150}, {REST, 150}, {B6, 150}, {REST, 50}, {B6, 150}, {REST, 50}, {C7, 150}, {REST, 50},
{C7, 150}, {REST, 50}, {C7, 150}, {REST, 150}, {C7, 150}, {REST, 50}, {C7, 150}, {REST, 150},
{C7, 150}, {REST, 50}, {C7, 150}, {REST, 50}, {B6, 150}, {REST, 50}, {B6, 150}, {REST, 50},
{B6, 150}, {REST, 150}, {B6, 150}, {REST, 50}, {B6, 150}, {REST, 150}, {B6, 150}, {REST, 50},
{B6, 150}, {REST, 50}, {C7, 150}, {REST, 50}, {C7, 150}, {REST, 50}, {C7, 150}, {REST, 150},
{C7, 150}, {REST, 50}, {C7, 150}, {REST, 150}, {C7, 150}, {REST, 50}, {C7, 150}, {REST, 50},
{B6, 150}, {REST, 50}, {B6, 150}, {REST, 50}, {B6, 150}, {REST, 150}, {B6, 150}, {REST, 50},
{B6, 150}, {REST, 150}, {B6, 150}, {REST, 50}, {B6, 150},
}
#define B6

Star Song.

Definition at line 294 of file buzzer_tunes.c.

◆ tune_startup

const struct buzzer_note tune_startup[]
static
Initial value:
= {
{C6, 120}, {E6, 120}, {G6, 120}, {C7, 360}, TUNE_END
}

Short rising arpeggio.

Definition at line 137 of file buzzer_tunes.c.

◆ tune_twinkle

const struct buzzer_note tune_twinkle[]
static
Initial value:
= {
{C6, 300}, {C6, 300}, {G6, 300}, {G6, 300}, {A6, 300}, {A6, 300}, {G6, 600},
{F6, 300}, {F6, 300}, {E6, 300}, {E6, 300}, {D6, 300}, {D6, 300}, {C6, 600},
{G6, 300}, {G6, 300}, {F6, 300}, {F6, 300}, {E6, 300}, {E6, 300}, {D6, 600},
{G6, 300}, {G6, 300}, {F6, 300}, {F6, 300}, {E6, 300}, {E6, 300}, {D6, 600},
{C6, 300}, {C6, 300}, {G6, 300}, {G6, 300}, {A6, 300}, {A6, 300}, {G6, 600},
{F6, 300}, {F6, 300}, {E6, 300}, {E6, 300}, {D6, 300}, {D6, 300}, {C6, 600}, TUNE_END
}

Twinkle Twinkle Little Star, full song (public domain).

Definition at line 154 of file buzzer_tunes.c.

◆ tune_william_tell

const struct buzzer_note tune_william_tell[]
static
Initial value:
= {
{G6, 100}, {G6, 100}, {G6, 200}, {G6, 100}, {G6, 100}, {G6, 200},
{G6, 100}, {G6, 100}, {C7, 200}, {D7, 200}, {E7, 400}, {REST, 200},
{G6, 100}, {G6, 100}, {G6, 200}, {G6, 100}, {G6, 100}, {G6, 200},
{G6, 100}, {G6, 100}, {C7, 200}, {D7, 200}, {E7, 400}, {C7, 600}, TUNE_END
}
#define E7

Rossini, William Tell Overture, galop opening, played twice (public domain).

Definition at line 286 of file buzzer_tunes.c.