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 | Contents |
|---|---|---|
| note | byte | Note number (0x81-0xFF). 0xE0-0xFF are special notes |
| duration | byte / ushort | Length (ticks). Omitted in default duration mode. A big-endian 16-bit value in 16-bit duration mode |
Remarks
Computes the pitch from the note number and the channel settings, keys on the DSP channel, and waits for duration. On a BGM channel during an SE interrupt, it only waits, without writing to the DSP.
On key on, the following values are written to the DSP.
- Volume: the channel’s left and right volume (multiplied by the volume scale $04B6)
- Pitch: the pitch value described below
- Source number, ADSR1, ADSR2: the channel’s settings
- GAIN: $7F
At the same time, if pitch bend or vibrato is enabled, their respective counters are initialized.
Length and key off
The note’s remaining tick count decreases by 1 every tick; key off occurs 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 1 is specified as the length, no key off occurs, so there is no silence before the next note. Specifying 0 as the length behaves the same as specifying 1.
Pitch calculation
The pitch is obtained by looking up the pitch definition table ($1199) using the low 7 bits of (note number + 36 + transpose value) as the index, and correcting it with the tuning value.
For compatibility with DKC, the DKC2/3 driver shifts the entire keyboard by 3 octaves.
If you set things up so that note 0x81 is C3, it is DKC-compatible; if you set it up so that note 0x81 is C0, you can use almost the entire range of the pitch table.
The pitch value is the value of the DSP pitch register; at $1000 the sample is played at its original speed.
If the tuning value t is not 0, the pitch value P is corrected to P + P × t / 1024.
The range of the pitch definition table is indices 0-97.
The note names in the table below are for convenience, assuming note number 0x81 is C0. 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 relationship matches this table.
| Index | Note number | Note name | Pitch value |
|---|---|---|---|
| 0 | 0x80 | Rest | $0000 |
| 1 | 0x81 | C0 | $0040 |
| 2 | 0x82 | C#0 | $0044 |
| 3 | 0x83 | D0 | $0048 |
| 4 | 0x84 | D#0 | $004C |
| 5 | 0x85 | E0 | $0051 |
| 6 | 0x86 | F0 | $0055 |
| 7 | 0x87 | F#0 | $005B |
| 8 | 0x88 | G0 | $0060 |
| 9 | 0x89 | G#0 | $0066 |
| 10 | 0x8A | A0 | $006C |
| 11 | 0x8B | A#0 | $0072 |
| 12 | 0x8C | B0 | $0079 |
| 13 | 0x8D | C1 | $0080 |
| 14 | 0x8E | C#1 | $0088 |
| 15 | 0x8F | D1 | $0090 |
| 16 | 0x90 | D#1 | $0098 |
| 17 | 0x91 | E1 | $00A1 |
| 18 | 0x92 | F1 | $00AB |
| 19 | 0x93 | F#1 | $00B5 |
| 20 | 0x94 | G1 | $00C0 |
| 21 | 0x95 | G#1 | $00CB |
| 22 | 0x96 | A1 | $00D7 |
| 23 | 0x97 | A#1 | $00E4 |
| 24 | 0x98 | B1 | $00F2 |
| 25 | 0x99 | C2 | $0100 |
| 26 | 0x9A | C#2 | $010F |
| 27 | 0x9B | D2 | $011F |
| 28 | 0x9C | D#2 | $0130 |
| 29 | 0x9D | E2 | $0143 |
| 30 | 0x9E | F2 | $0156 |
| 31 | 0x9F | F#2 | $016A |
| 32 | 0xA0 | G2 | $0180 |
| 33 | 0xA1 | G#2 | $0196 |
| 34 | 0xA2 | A2 | $01AF |
| 35 | 0xA3 | A#2 | $01C8 |
| 36 | 0xA4 | B2 | $01E3 |
| 37 | 0xA5 | C3 | $0200 |
| 38 | 0xA6 | C#3 | $021E |
| 39 | 0xA7 | D3 | $023F |
| 40 | 0xA8 | D#3 | $0261 |
| 41 | 0xA9 | E3 | $0285 |
| 42 | 0xAA | F3 | $02AB |
| 43 | 0xAB | F#3 | $02D4 |
| 44 | 0xAC | G3 | $02FF |
| 45 | 0xAD | G#3 | $032D |
| 46 | 0xAE | A3 | $035D |
| 47 | 0xAF | A#3 | $0390 |
| 48 | 0xB0 | B3 | $03C7 |
| 49 | 0xB1 | C4 | $0400 |
| 50 | 0xB2 | C#4 | $043D |
| 51 | 0xB3 | D4 | $047D |
| 52 | 0xB4 | D#4 | $04C2 |
| 53 | 0xB5 | E4 | $050A |
| 54 | 0xB6 | F4 | $0557 |
| 55 | 0xB7 | F#4 | $05A8 |
| 56 | 0xB8 | G4 | $05FE |
| 57 | 0xB9 | G#4 | $065A |
| 58 | 0xBA | A4 | $06BA |
| 59 | 0xBB | A#4 | $0721 |
| 60 | 0xBC | B4 | $078D |
| 61 | 0xBD | C5 | $0800 |
| 62 | 0xBE | C#5 | $087A |
| 63 | 0xBF | D5 | $08FB |
| 64 | 0xC0 | D#5 | $0984 |
| 65 | 0xC1 | E5 | $0A14 |
| 66 | 0xC2 | F5 | $0AAE |
| 67 | 0xC3 | F#5 | $0B50 |
| 68 | 0xC4 | G5 | $0BFD |
| 69 | 0xC5 | G#5 | $0CB3 |
| 70 | 0xC6 | A5 | $0D74 |
| 71 | 0xC7 | A#5 | $0E41 |
| 72 | 0xC8 | B5 | $0F1A |
| 73 | 0xC9 | C6 | $1000 |
| 74 | 0xCA | C#6 | $10F4 |
| 75 | 0xCB | D6 | $11F6 |
| 76 | 0xCC | D#6 | $1307 |
| 77 | 0xCD | E6 | $1429 |
| 78 | 0xCE | F6 | $155C |
| 79 | 0xCF | F#6 | $16A1 |
| 80 | 0xD0 | G6 | $17F9 |
| 81 | 0xD1 | G#6 | $1966 |
| 82 | 0xD2 | A6 | $1AE9 |
| 83 | 0xD3 | A#6 | $1C82 |
| 84 | 0xD4 | B6 | $1E34 |
| 85 | 0xD5 | C7 | $2000 |
| 86 | 0xD6 | C#7 | $21E7 |
| 87 | 0xD7 | D7 | $23EB |
| 88 | 0xD8 | D#7 | $260E |
| 89 | 0xD9 | E7 | $2851 |
| 90 | 0xDA | F7 | $2AB7 |
| 91 | 0xDB | F#7 | $2D41 |
| 92 | 0xDC | G7 | $2FF2 |
| 93 | 0xDD | G#7 | $32CC |
| 94 | 0xDE | A7 | $35D1 |
| 95 | 0xDF | A#7 | $3904 |
| 96 | - | B7 | $3C68 |
| 97 | - | C8 | $3FFF |
Special notes
Note events 0xE0 and 0xE2-0xFF are treated as notes with the note number set by command 0x1C ($0C+x).
Note event 0xE1 is treated as a note with the note number set by command 0x1D ($14+x).
36 and the transpose value are added to the replaced note number as usual.
See also
Structure of sequence data
Rest event
Command 0x06
Command 0x12
Command 0x13
Command 0x2B