Note event 0x81-0xFF
Represents a note.
Syntax
byte note, byte duration // normal
byte note, ushort duration // in 16-bit duration mode
byte note // in default duration mode
Parameters
| Parameter | Type | Description |
|---|---|---|
| note | byte | Note number (0x81-0xFF) |
| duration | byte / ushort | Length (ticks). Omitted in default duration mode. A big-endian 16-bit value in 16-bit duration mode |
Description
Calculates the pitch from the note number and the channel settings, keys on the DSP channel, and waits for duration. On a BGM channel under SE interrupt, it only waits without writing to the DSP.
At key-on, the following values are written to the DSP.
- Volume: the channel’s left and right volume (as is)
- Pitch: the pitch value described below
- Source number, ADSR1, ADSR2: the channel’s settings
- GAIN: $7F
At the same time, if pitch bend, vibrato or tremolo is enabled, its counters are initialized.
Length and key-off
The note’s remaining tick count decreases by 1 every tick; key-off happens when the remainder reaches 1, and the next event is read when it reaches 0. In other words, a note of length n sounds for n−1 ticks, and the last tick is silent (release).
If the length is 1, no key-off is performed, so there is no silence between it and the next note. A length of 0 behaves the same as a length of 1.
Pitch calculation
The pitch is obtained by looking up the pitch definition table ($11E1) using the low 7 bits of (note number + transpose value) as the index, then correcting it with the tuning value.
The pitch value is the value of the DSP pitch register; at $1000 the sample plays back at its original speed.
If the tuning value t is not 0, the pitch value P is corrected to P + P × t ÷ 1024.
The pitch definition table covers indexes 0-61.
The note names in the table below assume note number 0x81 is C3. The actual pitch depends on the sample.
However, as a rule it is easier to understand if you set the transpose so that the octave relationships follow this table.
| Index | Note number | Note name | Pitch value |
|---|---|---|---|
| 0 | 0x80 | Rest | $0000 |
| 1 | 0x81 | C3 | $0200 |
| 2 | 0x82 | C#3 | $021E |
| 3 | 0x83 | D3 | $023F |
| 4 | 0x84 | D#3 | $0261 |
| 5 | 0x85 | E3 | $0285 |
| 6 | 0x86 | F3 | $02AB |
| 7 | 0x87 | F#3 | $02D4 |
| 8 | 0x88 | G3 | $02FF |
| 9 | 0x89 | G#3 | $032D |
| 10 | 0x8A | A3 | $035D |
| 11 | 0x8B | A#3 | $0390 |
| 12 | 0x8C | B3 | $03C7 |
| 13 | 0x8D | C4 | $0400 |
| 14 | 0x8E | C#4 | $043D |
| 15 | 0x8F | D4 | $047D |
| 16 | 0x90 | D#4 | $04C2 |
| 17 | 0x91 | E4 | $050A |
| 18 | 0x92 | F4 | $0557 |
| 19 | 0x93 | F#4 | $05A8 |
| 20 | 0x94 | G4 | $05FE |
| 21 | 0x95 | G#4 | $065A |
| 22 | 0x96 | A4 | $06BA |
| 23 | 0x97 | A#4 | $0721 |
| 24 | 0x98 | B4 | $078D |
| 25 | 0x99 | C5 | $0800 |
| 26 | 0x9A | C#5 | $087A |
| 27 | 0x9B | D5 | $08FB |
| 28 | 0x9C | D#5 | $0984 |
| 29 | 0x9D | E5 | $0A14 |
| 30 | 0x9E | F5 | $0AAE |
| 31 | 0x9F | F#5 | $0B50 |
| 32 | 0xA0 | G5 | $0BFD |
| 33 | 0xA1 | G#5 | $0CB3 |
| 34 | 0xA2 | A5 | $0D74 |
| 35 | 0xA3 | A#5 | $0E41 |
| 36 | 0xA4 | B5 | $0F1A |
| 37 | 0xA5 | C6 | $1000 |
| 38 | 0xA6 | C#6 | $10F4 |
| 39 | 0xA7 | D6 | $11F6 |
| 40 | 0xA8 | D#6 | $1307 |
| 41 | 0xA9 | E6 | $1429 |
| 42 | 0xAA | F6 | $155C |
| 43 | 0xAB | F#6 | $16A1 |
| 44 | 0xAC | G6 | $17F9 |
| 45 | 0xAD | G#6 | $1966 |
| 46 | 0xAE | A6 | $1AE9 |
| 47 | 0xAF | A#6 | $1C82 |
| 48 | 0xB0 | B6 | $1E34 |
| 49 | 0xB1 | C7 | $2000 |
| 50 | 0xB2 | C#7 | $21E7 |
| 51 | 0xB3 | D7 | $23EB |
| 52 | 0xB4 | D#7 | $260E |
| 53 | 0xB5 | E7 | $2851 |
| 54 | 0xB6 | F7 | $2AB7 |
| 55 | 0xB7 | F#7 | $2D41 |
| 56 | 0xB8 | G7 | $2FF2 |
| 57 | 0xB9 | G#7 | $32CC |
| 58 | 0xBA | A7 | $35D1 |
| 59 | 0xBB | A#7 | $3904 |
| 60 | 0xBC | B7 | $3C68 |
| 61 | 0xBD | C8 | $3FFF |
See also
Sequence data structure
Rest event
Command 0x06
Command 0x12
Command 0x13
Command 0x2B