The instructions for turning off and on the lights is similar to the piano roll on a player piano. In a player piano, the keys are pneumatically operated by suction when air passes through the paper perforations. Across the width of the roll, each hole represents one key on the piano. A hole causes a note to be played. No hole means no note.
015100,04100,00008
015400,16392,00064
015700,32770,00032
016000,08193,00008
016300,04100,00064
016600,16392,00032
016900,32770,00008
The export button generates a text tile. The text file, just like the piano roll, describes when lights should turn on and off. Instead of one continuous roll, the text file only describes the times when lights should turn on or off. In this example, the times are in milliseconds. The Arduino will wait until 15.1 seconds (015100 milliseconds) into the song and set the first sixteen lights to a value of 4100, and the next sixteen lights to a value of 8. Then, the Arduino code will wait until 15.4 seconds (015400 milliseconds) into the song, and set the values 16392 and 64.
So, what do these values mean? Take 8 first. A value of 8 means the 4th bit is on, and the rest are off. A value of 4100 means the 13th bit is on, plus the 3rd is on (4096+4=4100). Any combination of the 16 lights can be represented by summing the values of their corresponding bits. Basic bitwise operations can be used to encode and decode the values of lights.
In the next blog entry, we'll work on the Arduino application to read the piano roll.
No comments:
Post a Comment