Serial Musical Organ 1.0
Buzzer controller and musical organ
Loading...
Searching...
No Matches
pre_defined_songs.c
Go to the documentation of this file.
1
33#include "includes/CPU.h"
34#include <avr/io.h>
35#include <util/delay.h>
36#include "includes/scale16.h"
37#include "includes/organ.h"
39
83{
91 const uint16_t estrellita_notas[] = {
92 C4, C4, G4, G4, A4, A4, G4, // "Twin-kle, twin-kle, lit-tle star"
93 F4, F4, E4, E4, D4, D4, C4, // "How I won-der what you are"
94 G4, G4, F4, F4, E4, E4, D4, // "Up a-bove the world so high"
95 G4, G4, F4, F4, E4, E4, D4, // "Like a dia-mond in the sky"
96 C4, C4, G4, G4, A4, A4, G4, // "Twin-kle, twin-kle, lit-tle star"
97 F4, F4, E4, E4, D4, D4, C4 // "How I won-der what you are"
98 };
99
108 const uint16_t estrellita_duraciones[] = {
109 Q, Q, Q, Q, Q, Q, H, // Phrase 1 ending with held note
110 Q, Q, Q, Q, Q, Q, H, // Phrase 2 ending with held note
111 Q, Q, Q, Q, Q, Q, H, // Phrase 3 ending with held note
112 Q, Q, Q, Q, Q, Q, H, // Phrase 4 ending with held note
113 Q, Q, Q, Q, Q, Q, H, // Phrase 5 ending with held note
114 Q, Q, Q, Q, Q, Q, H // Phrase 6 ending with held note
115 };
116
125 for (uint8_t i = 0; i < 42; i++)
126 playNote(estrellita_notas[i], estrellita_duraciones[i]);
127}
128
191{
199 const uint16_t imperial_notas[] = {
200 // INTRO (6 notes)
201 G3, G3, G3, G3, Dx3, G3,
202 // THEME A1 (5 notes)
203 G3, G3, G3, Dx3, G3,
204 // THEME B1 (5 notes)
205 C4, C4, C4, G3, C4,
206 // BRIDGE (5 notes)
207 Ax3, Ax3, Ax3, F3, Ax3,
208 // THEME A2 (5 notes)
209 G3, G3, G3, Dx3, G3,
210 // THEME B2 (5 notes)
211 C4, C4, C4, G3, C4,
212 // BUILD-UP (3 notes)
213 D4, Dx4, E4,
214 // CLIMAX (5 notes)
215 F4, F4, F4, F4, F4,
216 // RESOLUTION (5 notes)
217 Ax3, Ax3, Ax3, F3, Ax3,
218 // CODA (6 notes)
219 G3, G3, G3, Dx3, G3, G3
220 };
221
230 const uint16_t imperial_duraciones[] = {
231 // INTRO: Holds on first three G3 notes
232 H, H, H, Q, Q, H,
233 // THEME A1: Short-short-short-short LONG pattern
234 Q, Q, Q, Q, H,
235 // THEME B1: Same rhythm pattern
236 Q, Q, Q, Q, H,
237 // BRIDGE: Same rhythm pattern
238 Q, Q, Q, Q, H,
239 // THEME A2: Repeated pattern
240 Q, Q, Q, Q, H,
241 // THEME B2: Repeated pattern
242 Q, Q, Q, Q, H,
243 // BUILD-UP: All long notes (crescendo)
244 H, H, H,
245 // CLIMAX: Long-long-short-short-LONG (dramatic)
246 H, H, Q, Q, H,
247 // RESOLUTION: Return to bridge pattern
248 Q, Q, Q, Q, H,
249 // CODA: Build-up to final held note
250 Q, Q, Q, Q, H, H
251 };
252
262#define _num_notes(x) sizeof(x) / sizeof(x[0])
263
273 for (uint8_t i = 0; i < _num_notes(imperial_notas); i++)
274 playNote(imperial_notas[i], imperial_duraciones[i]);
275}
276
CPU configuration and definitions for ATmega168.
#define Dx3
Definition scale16.h:51
#define D4
Definition scale16.h:64
#define E4
Definition scale16.h:66
#define G4
Definition scale16.h:69
#define Ax3
Definition scale16.h:46
#define F3
Definition scale16.h:53
#define F4
Definition scale16.h:67
#define A4
Definition scale16.h:59
#define G3
Definition scale16.h:55
#define H
Definition scale16.h:91
#define Q
Definition scale16.h:90
#define C4
Definition scale16.h:62
#define Dx4
Definition scale16.h:65
Organ tone generator interface.
void playNote(uint16_t half_us, uint16_t duration_ms)
Play a musical tone.
Definition organ.c:66
void play_twinkle_little_star()
Plays "Twinkle Twinkle Little Star" melody.
#define _num_notes(x)
Pre-defined songs for musical organ.
void play_imperial_march()
Plays "Imperial March" (Darth Vader's Theme) from Star Wars.
Musical note frequency lookup table (16-bit timer values)