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

ParameterTypeContents
notebyteNote number (0x81-0xFF). 0xE0-0xFF are special notes
durationbyte / ushortLength (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.

IndexNote numberNote namePitch value
00x80Rest$0000
10x81C0$0040
20x82C#0$0044
30x83D0$0048
40x84D#0$004C
50x85E0$0051
60x86F0$0055
70x87F#0$005B
80x88G0$0060
90x89G#0$0066
100x8AA0$006C
110x8BA#0$0072
120x8CB0$0079
130x8DC1$0080
140x8EC#1$0088
150x8FD1$0090
160x90D#1$0098
170x91E1$00A1
180x92F1$00AB
190x93F#1$00B5
200x94G1$00C0
210x95G#1$00CB
220x96A1$00D7
230x97A#1$00E4
240x98B1$00F2
250x99C2$0100
260x9AC#2$010F
270x9BD2$011F
280x9CD#2$0130
290x9DE2$0143
300x9EF2$0156
310x9FF#2$016A
320xA0G2$0180
330xA1G#2$0196
340xA2A2$01AF
350xA3A#2$01C8
360xA4B2$01E3
370xA5C3$0200
380xA6C#3$021E
390xA7D3$023F
400xA8D#3$0261
410xA9E3$0285
420xAAF3$02AB
430xABF#3$02D4
440xACG3$02FF
450xADG#3$032D
460xAEA3$035D
470xAFA#3$0390
480xB0B3$03C7
490xB1C4$0400
500xB2C#4$043D
510xB3D4$047D
520xB4D#4$04C2
530xB5E4$050A
540xB6F4$0557
550xB7F#4$05A8
560xB8G4$05FE
570xB9G#4$065A
580xBAA4$06BA
590xBBA#4$0721
600xBCB4$078D
610xBDC5$0800
620xBEC#5$087A
630xBFD5$08FB
640xC0D#5$0984
650xC1E5$0A14
660xC2F5$0AAE
670xC3F#5$0B50
680xC4G5$0BFD
690xC5G#5$0CB3
700xC6A5$0D74
710xC7A#5$0E41
720xC8B5$0F1A
730xC9C6$1000
740xCAC#6$10F4
750xCBD6$11F6
760xCCD#6$1307
770xCDE6$1429
780xCEF6$155C
790xCFF#6$16A1
800xD0G6$17F9
810xD1G#6$1966
820xD2A6$1AE9
830xD3A#6$1C82
840xD4B6$1E34
850xD5C7$2000
860xD6C#7$21E7
870xD7D7$23EB
880xD8D#7$260E
890xD9E7$2851
900xDAF7$2AB7
910xDBF#7$2D41
920xDCG7$2FF2
930xDDG#7$32CC
940xDEA7$35D1
950xDFA#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