Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit 32fbfa7

Browse files
committed
2 parents 8d5073c + c645ed6 commit 32fbfa7

4 files changed

Lines changed: 507 additions & 1 deletion

File tree

Envision/Music/BloodyTears.ino/BloodyTears.ino.ino renamed to Envision/Music/BloodyTears.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,4 @@ void setup() {
319319

320320
void loop() {
321321
// no need to repeat the melody.
322-
}
322+
}

Envision/Music/HappyBirthDay.ino

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/*
2+
Big thanks for : robsoncouto for the code !
3+
From : Happybirth day song
4+
*/
5+
6+
/*
7+
Happy Birthday
8+
Connect a piezo buzzer or speaker to pin 11 or select a new pin.
9+
More songs available at https://github.com/robsoncouto/arduino-songs
10+
11+
Robson Couto, 2019
12+
*/
13+
14+
#define NOTE_B0 31
15+
#define NOTE_C1 33
16+
#define NOTE_CS1 35
17+
#define NOTE_D1 37
18+
#define NOTE_DS1 39
19+
#define NOTE_E1 41
20+
#define NOTE_F1 44
21+
#define NOTE_FS1 46
22+
#define NOTE_G1 49
23+
#define NOTE_GS1 52
24+
#define NOTE_A1 55
25+
#define NOTE_AS1 58
26+
#define NOTE_B1 62
27+
#define NOTE_C2 65
28+
#define NOTE_CS2 69
29+
#define NOTE_D2 73
30+
#define NOTE_DS2 78
31+
#define NOTE_E2 82
32+
#define NOTE_F2 87
33+
#define NOTE_FS2 93
34+
#define NOTE_G2 98
35+
#define NOTE_GS2 104
36+
#define NOTE_A2 110
37+
#define NOTE_AS2 117
38+
#define NOTE_B2 123
39+
#define NOTE_C3 131
40+
#define NOTE_CS3 139
41+
#define NOTE_D3 147
42+
#define NOTE_DS3 156
43+
#define NOTE_E3 165
44+
#define NOTE_F3 175
45+
#define NOTE_FS3 185
46+
#define NOTE_G3 196
47+
#define NOTE_GS3 208
48+
#define NOTE_A3 220
49+
#define NOTE_AS3 233
50+
#define NOTE_B3 247
51+
#define NOTE_C4 262
52+
#define NOTE_CS4 277
53+
#define NOTE_D4 294
54+
#define NOTE_DS4 311
55+
#define NOTE_E4 330
56+
#define NOTE_F4 349
57+
#define NOTE_FS4 370
58+
#define NOTE_G4 392
59+
#define NOTE_GS4 415
60+
#define NOTE_A4 440
61+
#define NOTE_AS4 466
62+
#define NOTE_B4 494
63+
#define NOTE_C5 523
64+
#define NOTE_CS5 554
65+
#define NOTE_D5 587
66+
#define NOTE_DS5 622
67+
#define NOTE_E5 659
68+
#define NOTE_F5 698
69+
#define NOTE_FS5 740
70+
#define NOTE_G5 784
71+
#define NOTE_GS5 831
72+
#define NOTE_A5 880
73+
#define NOTE_AS5 932
74+
#define NOTE_B5 988
75+
#define NOTE_C6 1047
76+
#define NOTE_CS6 1109
77+
#define NOTE_D6 1175
78+
#define NOTE_DS6 1245
79+
#define NOTE_E6 1319
80+
#define NOTE_F6 1397
81+
#define NOTE_FS6 1480
82+
#define NOTE_G6 1568
83+
#define NOTE_GS6 1661
84+
#define NOTE_A6 1760
85+
#define NOTE_AS6 1865
86+
#define NOTE_B6 1976
87+
#define NOTE_C7 2093
88+
#define NOTE_CS7 2217
89+
#define NOTE_D7 2349
90+
#define NOTE_DS7 2489
91+
#define NOTE_E7 2637
92+
#define NOTE_F7 2794
93+
#define NOTE_FS7 2960
94+
#define NOTE_G7 3136
95+
#define NOTE_GS7 3322
96+
#define NOTE_A7 3520
97+
#define NOTE_AS7 3729
98+
#define NOTE_B7 3951
99+
#define NOTE_C8 4186
100+
#define NOTE_CS8 4435
101+
#define NOTE_D8 4699
102+
#define NOTE_DS8 4978
103+
#define REST 0
104+
105+
106+
// change this to make the song slower or faster
107+
int tempo = 140;
108+
109+
// change this to whichever pin you want to use
110+
int buzzer = 11;
111+
112+
// notes of the moledy followed by the duration.
113+
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
114+
// !!negative numbers are used to represent dotted notes,
115+
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
116+
int melody[] = {
117+
118+
// Happy Birthday
119+
// Score available at https://musescore.com/user/8221/scores/26906
120+
121+
NOTE_C4,4, NOTE_C4,8,
122+
NOTE_D4,-4, NOTE_C4,-4, NOTE_F4,-4,
123+
NOTE_E4,-2, NOTE_C4,4, NOTE_C4,8,
124+
NOTE_D4,-4, NOTE_C4,-4, NOTE_G4,-4,
125+
NOTE_F4,-2, NOTE_C4,4, NOTE_C4,8,
126+
127+
NOTE_C5,-4, NOTE_A4,-4, NOTE_F4,-4,
128+
NOTE_E4,-4, NOTE_D4,-4, NOTE_AS4,4, NOTE_AS4,8,
129+
NOTE_A4,-4, NOTE_F4,-4, NOTE_G4,-4,
130+
NOTE_F4,-2,
131+
132+
};
133+
134+
// sizeof gives the number of bytes, each int value is composed of two bytes (16 bits)
135+
// there are two values per note (pitch and duration), so for each note there are four bytes
136+
int notes = sizeof(melody) / sizeof(melody[0]) / 2;
137+
138+
// this calculates the duration of a whole note in ms
139+
int wholenote = (60000 * 4) / tempo;
140+
141+
int divider = 0, noteDuration = 0;
142+
143+
void setup() {
144+
// iterate over the notes of the melody.
145+
// Remember, the array is twice the number of notes (notes + durations)
146+
for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) {
147+
148+
// calculates the duration of each note
149+
divider = melody[thisNote + 1];
150+
if (divider > 0) {
151+
// regular note, just proceed
152+
noteDuration = (wholenote) / divider;
153+
} else if (divider < 0) {
154+
// dotted notes are represented with negative durations!!
155+
noteDuration = (wholenote) / abs(divider);
156+
noteDuration *= 1.5; // increases the duration in half for dotted notes
157+
}
158+
159+
// we only play the note for 90% of the duration, leaving 10% as a pause
160+
tone(buzzer, melody[thisNote], noteDuration * 0.9);
161+
162+
// Wait for the specief duration before playing the next note.
163+
delay(noteDuration);
164+
165+
// stop the waveform generation before the next note.
166+
noTone(buzzer);
167+
}
168+
}
169+
170+
void loop() {
171+
// no need to repeat the melody.
172+
}

Envision/Music/Nokia.ino

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/*
2+
Big thanks for : robsoncouto for the code !
3+
Original : Frederic Chopin
4+
From : Nokia tune
5+
*/
6+
7+
/*
8+
Nokia Tune
9+
Connect a piezo buzzer or speaker to pin 11 or select a new pin.
10+
More songs available at https://github.com/robsoncouto/arduino-songs
11+
12+
Robson Couto, 2019
13+
*/
14+
15+
#define NOTE_B0 31
16+
#define NOTE_C1 33
17+
#define NOTE_CS1 35
18+
#define NOTE_D1 37
19+
#define NOTE_DS1 39
20+
#define NOTE_E1 41
21+
#define NOTE_F1 44
22+
#define NOTE_FS1 46
23+
#define NOTE_G1 49
24+
#define NOTE_GS1 52
25+
#define NOTE_A1 55
26+
#define NOTE_AS1 58
27+
#define NOTE_B1 62
28+
#define NOTE_C2 65
29+
#define NOTE_CS2 69
30+
#define NOTE_D2 73
31+
#define NOTE_DS2 78
32+
#define NOTE_E2 82
33+
#define NOTE_F2 87
34+
#define NOTE_FS2 93
35+
#define NOTE_G2 98
36+
#define NOTE_GS2 104
37+
#define NOTE_A2 110
38+
#define NOTE_AS2 117
39+
#define NOTE_B2 123
40+
#define NOTE_C3 131
41+
#define NOTE_CS3 139
42+
#define NOTE_D3 147
43+
#define NOTE_DS3 156
44+
#define NOTE_E3 165
45+
#define NOTE_F3 175
46+
#define NOTE_FS3 185
47+
#define NOTE_G3 196
48+
#define NOTE_GS3 208
49+
#define NOTE_A3 220
50+
#define NOTE_AS3 233
51+
#define NOTE_B3 247
52+
#define NOTE_C4 262
53+
#define NOTE_CS4 277
54+
#define NOTE_D4 294
55+
#define NOTE_DS4 311
56+
#define NOTE_E4 330
57+
#define NOTE_F4 349
58+
#define NOTE_FS4 370
59+
#define NOTE_G4 392
60+
#define NOTE_GS4 415
61+
#define NOTE_A4 440
62+
#define NOTE_AS4 466
63+
#define NOTE_B4 494
64+
#define NOTE_C5 523
65+
#define NOTE_CS5 554
66+
#define NOTE_D5 587
67+
#define NOTE_DS5 622
68+
#define NOTE_E5 659
69+
#define NOTE_F5 698
70+
#define NOTE_FS5 740
71+
#define NOTE_G5 784
72+
#define NOTE_GS5 831
73+
#define NOTE_A5 880
74+
#define NOTE_AS5 932
75+
#define NOTE_B5 988
76+
#define NOTE_C6 1047
77+
#define NOTE_CS6 1109
78+
#define NOTE_D6 1175
79+
#define NOTE_DS6 1245
80+
#define NOTE_E6 1319
81+
#define NOTE_F6 1397
82+
#define NOTE_FS6 1480
83+
#define NOTE_G6 1568
84+
#define NOTE_GS6 1661
85+
#define NOTE_A6 1760
86+
#define NOTE_AS6 1865
87+
#define NOTE_B6 1976
88+
#define NOTE_C7 2093
89+
#define NOTE_CS7 2217
90+
#define NOTE_D7 2349
91+
#define NOTE_DS7 2489
92+
#define NOTE_E7 2637
93+
#define NOTE_F7 2794
94+
#define NOTE_FS7 2960
95+
#define NOTE_G7 3136
96+
#define NOTE_GS7 3322
97+
#define NOTE_A7 3520
98+
#define NOTE_AS7 3729
99+
#define NOTE_B7 3951
100+
#define NOTE_C8 4186
101+
#define NOTE_CS8 4435
102+
#define NOTE_D8 4699
103+
#define NOTE_DS8 4978
104+
#define REST 0
105+
106+
107+
// change this to make the song slower or faster
108+
int tempo = 180;
109+
110+
// change this to whichever pin you want to use
111+
int buzzer = 11;
112+
113+
// notes of the moledy followed by the duration.
114+
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
115+
// !!negative numbers are used to represent dotted notes,
116+
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
117+
int melody[] = {
118+
119+
// Nokia Ringtone
120+
// Score available at https://musescore.com/user/29944637/scores/5266155
121+
122+
NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4,
123+
NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4,
124+
NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
125+
NOTE_A4, 2,
126+
};
127+
128+
// sizeof gives the number of bytes, each int value is composed of two bytes (16 bits)
129+
// there are two values per note (pitch and duration), so for each note there are four bytes
130+
int notes = sizeof(melody) / sizeof(melody[0]) / 2;
131+
132+
// this calculates the duration of a whole note in ms
133+
int wholenote = (60000 * 4) / tempo;
134+
135+
int divider = 0, noteDuration = 0;
136+
137+
void setup() {
138+
// iterate over the notes of the melody.
139+
// Remember, the array is twice the number of notes (notes + durations)
140+
for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) {
141+
142+
// calculates the duration of each note
143+
divider = melody[thisNote + 1];
144+
if (divider > 0) {
145+
// regular note, just proceed
146+
noteDuration = (wholenote) / divider;
147+
} else if (divider < 0) {
148+
// dotted notes are represented with negative durations!!
149+
noteDuration = (wholenote) / abs(divider);
150+
noteDuration *= 1.5; // increases the duration in half for dotted notes
151+
}
152+
153+
// we only play the note for 90% of the duration, leaving 10% as a pause
154+
tone(buzzer, melody[thisNote], noteDuration * 0.9);
155+
156+
// Wait for the specief duration before playing the next note.
157+
delay(noteDuration);
158+
159+
// stop the waveform generation before the next note.
160+
noTone(buzzer);
161+
}
162+
}
163+
164+
void loop() {
165+
// no need to repeat the melody.
166+
}

0 commit comments

Comments
 (0)