Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 |
I discovered Arduino two months ago and I'm exploring its musical applications. At this stage of learning I am using the tone function to play a two-part piece.
I made the musical arrangement in the Finale software, and then I made the MIDI file into Arduino code through http://greenlightgo.org/projects/midi-to-arduino/ Then I set up a very simple circuit with only one speaker on pin 4.
/**
Peça musical executada pela função Tone do Arduino. Execução monofônica. (Musical piece performed by Arduino Tone function. Monophonic playback.)
Título(Title): Brasileirinho.
Música (Music): Waldir Azevedo.
Arranjo (Arrangement): Glauber Santiago.
Circuito (Circuit): Autofalante de 8 ohm no pino 4 (8 ohm speaker on digital pin 8).
MIDI-Arduino Sequencing code generator
Courtesy of http://greenlightgo.org/projects/midi-to-arduino/
A peça será executada uma vez apenas. Its will be executed once only.
**/
#define msPerTick 0.4 //Andamento(Tempo)
void setup() {
pinMode(4, OUTPUT);
doPerformance();
}
void loop() {
}
void doPerformance() {
tone(4, 494);
delay(102 * msPerTick);
noTone(4);
delay(154 * msPerTick);
tone(4, 494);
delay(205 * msPerTick);
noTone(4);
delay(307 * msPerTick);
tone(4, 494);
delay(102 * msPerTick);
noTone(4);
delay(410 * msPerTick);
tone(4, 392);
delay(205 * msPerTick);
noTone(4);
delay(307 * msPerTick);
tone(4, 494);
delay(102 * msPerTick);
noTone(4);
delay(154 * msPerTick);
tone(4, 587);
delay(205 * msPerTick);
noTone(4);
delay(819 * msPerTick);
tone(4, 294);
delay(205 * msPerTick);
noTone(4);
delay(819 * msPerTick);
tone(4, 147);
delay(205 * msPerTick);
noTone(4);
delay(307 * msPerTick);
tone(4, 988);
delay(512 * msPerTick);
noTone(4);
tone(4, 988);
delay(512 * msPerTick);
noTone(4);
tone(4, 988);
delay(384 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 196);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 196);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 294);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 880);
delay(256 * msPerTick);
noTone(4);
tone(4, 831);
delay(128 * msPerTick);
tone(4, 392);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 233);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 294);
delay(256 * msPerTick);
noTone(4);
tone(4, 233);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 294);
delay(256 * msPerTick);
noTone(4);
tone(4, 233);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 294);
delay(256 * msPerTick);
noTone(4);
tone(4, 233);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 294);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 185);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 165);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 196);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(128 * msPerTick);
tone(4, 175);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 156);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 196);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 185);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 165);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 988);
delay(128 * msPerTick);
tone(4, 147);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 988);
delay(256 * msPerTick);
noTone(4);
tone(4, 932);
delay(256 * msPerTick);
noTone(4);
tone(4, 880);
delay(256 * msPerTick);
noTone(4);
tone(4, 831);
delay(128 * msPerTick);
tone(4, 98);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 247);
delay(256 * msPerTick);
noTone(4);
tone(4, 233);
delay(256 * msPerTick);
noTone(4);
tone(4, 220);
delay(256 * msPerTick);
noTone(4);
tone(4, 208);
delay(256 * msPerTick);
noTone(4);
tone(4, 196);
delay(256 * msPerTick);
noTone(4);
tone(4, 185);
delay(256 * msPerTick);
noTone(4);
tone(4, 165);
delay(256 * msPerTick);
noTone(4);
tone(4, 147);
delay(256 * msPerTick);
noTone(4);
tone(4, 98);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(128 * msPerTick);
tone(4, 294);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 740);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 220);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(256 * msPerTick);
noTone(4);
tone(4, 740);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(128 * msPerTick);
tone(4, 294);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(128 * msPerTick);
tone(4, 220);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 740);
delay(256 * msPerTick);
noTone(4);
tone(4, 698);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 294);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 740);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
noTone(4);
tone(4, 587);
delay(128 * msPerTick);
tone(4, 196);
delay(128 * msPerTick);
noTone(4);
noTone(4);
tone(4, 784);
delay(256 * msPerTick);
noTone(4);
tone(4, 740);
delay(256 * msPerTick);
noTone(4);
tone(4, 659);
delay(256 * msPerTick);
...
This file has been truncated, please download it to see its full contents.
Glauber Santiago
Posted by
GlauberSantiago

Comments
Please log in or sign up to comment.