There is one piezoelectric speaker in the cube that plays sound. This piezoelectric speaker can play sound effects or melodies using MIDI note numbers within the cube using the following characteristic.
Sound effects on the cube can be played by writing the following configuration data. In the example, the "Mat in" sound effect is played.
|1||UInt8||Sound effect ID|
The sound effect ID is specified with values ranging between
10, and the correlation between the ID and the type of sound effect is as follows.
|Sound effect ID||Type of sound effect|
The volume can be specified with values ranging between
0 is volume 0 (off) and all the other values are the maximum volume.
A melody can be played with a MIDI note number by writing the following configuration data. In the example "C5-D5-E5" is played on repeat.
|1||UInt8||Number of repetitions|
|2||UInt8||Number of operations|
|4||UInt8||MIDI note number|
|7||UInt8||MIDI note number|
|10||UInt8||MIDI note number|
The data for this write operation has structure with a variable length as shown in the figure below.
Operation is made up of the following three elements.
- Duration played
- MIDI note number
Specifies the number of times Operation is repeated in the range from
0 means "infinite times", and Operation repetition will not end until the next write operation is performed. In the range of
255, the indicator will turn off after repeating the specified number of times.
Specifies the number of operations with values ranging between
59. If the value specified is smaller than the number of operations that follow, only the number of operations specified are repeated. If the value specified is greater than the number of operations that follow, an error occurs and the write operation is discarded.
Specifies the length of time a MIDI note number is played, with values ranging between
255. The MIDI note number is played for 10 times the specified value in milliseconds.
Specifies the MIDI note number that is played, with values ranging between
128. See MIDI note number and note name for the correlation with the note names.
[Playing sound effects] (#Playing-sound-effects) and [Playing MIDI note number] (#Playing-MIDI-note-number) can be stopped by writing the following configuration data.
The correlation between the MIDI note numbers and note names is as follows: MIDI note number = 57 creates a 440 Hz sound, and MIDI note number = 128 creates no sound.