Day 21: Piano Player
The door of day 21 reveals a loudspeaker. We will use it in our experiment today to play some music. We will need a very simple setup for this.
In our experiment we will connect the speaker to one of the board’s two DAC outputs. DAC means digital/analogue converter and with this we can generate an analogue signal using digital commands. In our experiment today, we will use it to produce sounds, and to be more precise, we are talking about piano sounds. The notes, pauses and keys are sent via UDP by means of an array of numbers.
Copy the Node-RED flow of today into your environment, but before using it, you must again disable previous ones. You also need to adjust the IP of the UDP node to reflect the broadcast IP of your board. Then choose the program of today and start the flow.
You will find already predefined songs that you can play via the user interface. But of course, you also have the option to translate or compose songs yourself. There is a text box for this purpose. Just copy your composition into it.
The notes follow the simple note scheme and are entered like this:
NOTE_C1, NOTE_CS1, NOTE_D1, NOTE_DS1, NOTE_E1, NOTE_F1, NOTE_FS1, NOTE_G1, NOTE_GS1, NOTE_A1, NOTE_AS1, NOTE_B1
The number following the note is the octave. You can replace 1 using any number from 1 to 7. You can also specify the note span with the prefix BEAT to make it a half, quarter or eighth note. The BEAT attribute always refers to the preceding note. BEAT_1 is the default, so you do not need to write this before each note. The following note spans are used:
BEAT_025, BEAT_05, BEAT_075, BEAT_1, BEAT_125, BEAT_15, BEAT_175, BEAT_2, BEAT_25, BEAT_3, BEAT_4, BEAT_5
For example, if you want to play the beginning of Beethoven’s famous 5th Symphony, enter the following text into the window:
You don’t have to be a musical genius. Just try a few notes and note spans and compose your own song. Or convert a familiar song into this system.
Imagination has no limits.