Sound
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.
Property | Value |
---|---|
Characteristic UUID | 10B20104-5B3B-4571-9508-CF3EFCD7BBAE |
Properties | Write |
Descriptor | Sound Control |
Write operations
Playing sound effects
Sound effects on the cube can be played by writing the following configuration data. In the example, the "Mat in" sound effect is played.
Data location | Type | Content | Example |
---|---|---|---|
0 | UInt8 | Control type | 0x02 (Play sound effect) |
1 | UInt8 | Sound effect ID | 0x04 (Mat in) |
2 | UInt8 | Volume | 0xFF (Max) |
Sound effect ID
The sound effect ID is specified with values ranging between 0
and 10
, and the correlation between the ID and the type of sound effect is as follows.
Sound effect ID | Type of sound effect |
---|---|
0 | Enter |
1 | Selected |
2 | Cancel |
3 | Cursor |
4 | Mat in |
5 | Mat out |
6 | Get 1 |
7 | Get 2 |
8 | Get 3 |
9 | Effect 1 |
10 | Effect 2 |
Volume
The volume can be specified with values ranging between 0
and 255
, where 0
is volume 0 (off) and all the other values are the maximum volume.
Playing the MIDI note numbers
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.
Data location | Type | Content | Example |
---|---|---|---|
0 | UInt8 | Control type | 0x03 (Play MIDI note number) |
1 | UInt8 | Number of repetitions | 0x00 (Infinite) |
2 | UInt8 | Number of operations | 0x03 (Three) |
3 | UInt8 | Duration played | 0x1E (300 milliseconds) |
4 | UInt8 | MIDI note number | 0x3C (C5) |
5 | UInt8 | Volume | 0x1E (Max) |
6 | UInt8 | Duration played | 0x1E (300 milliseconds) |
7 | UInt8 | MIDI note number | 0x3E (D5) |
8 | UInt8 | Volume | 0xFF (Max) |
9 | UInt8 | Duration played | 0x1E (300 milliseconds) |
10 | UInt8 | MIDI note number | 0x40 (E5) |
11 | UInt8 | Volume | 0xFF (Max) |
Data Structure and Operation
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
- Volume
Number of iterations
Specifies the number of times Operation is repeated in the range from 0
to 255
. 0
means "infinite times", and Operation repetition will not end until the next write operation is performed. In the range of 1
to 255
, the indicator will turn off after repeating the specified number of times.
Number of Operation
Specifies the number of operations with values ranging between 1
and 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.
Duration played
Specifies the length of time a MIDI note number is played, with values ranging between 1
and 255
. The MIDI note number is played for 10 times the specified value in milliseconds.
MIDI note number
Specifies the MIDI note number that is played, with values ranging between 0
and 128
. See MIDI note number and note name for the correlation with the note names.
Stop playing
[Playing sound effects] (#Playing-sound-effects) and [Playing MIDI note number] (#Playing-MIDI-note-number) can be stopped by writing the following configuration data.
Data location | Type | Content | Example |
---|---|---|---|
0 | UInt8 | Control type | 0x01 (Stop playing) |
Additional information
MIDI note number and note name
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.
Octave | Note name | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
C | C# | D | D# | E | F | F# | G | G# | A | A# | B | |
0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
2 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
3 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
4 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
5 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
6 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
7 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
8 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |
9 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
10 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |