- The Instrument Table™
- SFX Making
Hello, if you are here, then that means you want to make your own sound effects. If that’s the case and you didn’t get lost in the forums (again), then let’s get started!!!
The tools we will be using are:
- AddmusicK, which I suppose you already have.
The Instrument Table™
In reality, SMW uses two instrument tables: one for music (which is subdivided into a melodic instruments table and a percussion instruments table) and one for sound effects, both of these can be found in InstrumentData.asm inside AMK's asm folder. The instrument table used for SFX is different, so your experience with music ports won’t help you here!
The instrument table for SFX works like this:
; Byte 0: Left volume
; Byte 1: Right volume
; Byte 2: Starting pitch 1
; Byte 3: Starting pitch 2
; Byte 4: Sample (SRCN) number
; Byte 5: ADSR 1 / GAIN
; Byte 6: ADSR 2
; Byte 7: GAIN
; Byte 8: Tuning
$70, $70, $00, $10, $06, $DF, $E0, $B8, $02
As you can see, it’s similar to the #instruments syntax, but with 4 extra bytes (ignoring Sample Number, which is present in every instrument table). These are “default” values in case you don’t specify volume or (somehow) pitch, which are inserted directly into the DSP registers. On the SNES SPC700 Player, you can view the DSP registers by pressing the right arrow key on your keyboard twice. Unlike #instruments, however, there’s only one byte for tuning. You can change these bytes if you want to, or even add new instruments, but vanilla sound effects will be affected, so do so with caution.
To elaborate on the Sample (SRCN) Number, this number represents the order in which every sample is inserted through sample groups:
"default/00 SMW @0.brr"!
"default/01 SMW @1.brr"!
"default/02 SMW @2.brr"!
"default/03 SMW @3.brr"!
"default/04 SMW @4.brr"!
"default/05 SMW @8.brr"!
"default/06 SMW @22.brr"!
"default/07 SMW @5.brr"!
"default/08 SMW @6.brr"!
"default/09 SMW @7.brr"!
"default/0A SMW @9.brr"!
"default/0B SMW @10.brr"!
"default/0C SMW @13.brr"!
"default/0D SMW @14.brr"
"default/0E SMW @29.brr"!
"default/0F SMW @21.brr"
"default/10 SMW @12.brr"!
"default/11 SMW @17.brr"
"default/12 SMW @15.brr"!
"default/13 SMW Thunder.brr"!
In this case, @0’s Sample Number is 00, @1’s is 01, @2’s is 02 and so on. These samples were named with the Sample Numbers in mind, as they are prefaced with their respective sample number given the default ordering of the sample group. If you were to insert a new sample at the end of the list, it would be sample 14, then 15, 16 and so on, but only until 7F. Sample numbers 80-9F are noise.
In short, sample numbers can only go from 00 to 7F, while 80 to 9F is noise.
Here’s the SFX Instrument Table as if we were using #instruments, for convenience. You can click on the commented line to play an example SPC.
@22 $DF $E0 $B8 $02 $00 ;00/@0
@0 $FE $0A $B8 $03 $00 ;01/@1
@3 $FE $11 $B8 $03 $00 ;02/@2
@4 $FE $6A $B8 $03 $00 ;03/@3
@0 $FE $11 $B8 $03 $00 ;04/@4
@6 $FE $6A $B8 $03 $00 ;05/@5
@2 $FE $6A $B8 $06 $00 ;06/@6
@22 $FE $6A $B8 $05 $00 ;07/@7
@0 $CA $D7 $B8 $03 $00 ;08/@8
@12 $0E $6A $7F $04 $00 ;09/@9
@10 $FE $6A $B8 $02 $00 ;0A/@10
@10 $FF $E0 $B8 $05 $00 ;0B/@11
@29 $FE $00 $7F $06 $00 ;0C/@12
@0 $B6 $30 $30 $06 $00 ;0D/@13
@15 $0E $6A $70 $03 $00 ;0E/@14
@1 $FA $6A $70 $03 $00 ;0F/@15
@2 $FE $16 $70 $03 $00 ;10/@16
"default/13 SMW Thunder.brr" $0E $16 $7F $03 $00 ;11/@17
@2 $FE $33 $7F $03 $00 ;12/@18
To start off, SFX commands are VERY limited, as you only have a handful to work with. The most important thing you need to know about how sound effects behave is that there is no tempo, no staccato, no ties, and no rests. With this, I’m referring to the fact that sound effects play at a fixed speed (t56), there’s 0 silence between notes compared to music, you can’t tie notes (^ or C6 in HEX), and you can’t do traditional rests (r or C7 in HEX). Ties and rests will cause the last note to repeat.
AMK allows normal syntax like @0, vXXX, yXX, etc., but it gets buggy sometimes, so I really, really, REALLY recommend you type commands directly in HEX instead. Here’s how it works:
$XX = Notes
$DA $XX $YY = Instrument
$XX is the instrument number in HEX. Check the #instruments table I put above and look for whatever instrument you want to use. Goes from 00 to 7F.
If you specify a value from 80 to 9F, then this will be noise. When you use noise, you can set an extra argument “$YY” to specify an instrument to get ADSR values from.
$DD $WW $XX $YY $ZZ = Pitch Bend (Extended)
$WW is the starting note, $XX is the delay, $YY is the duration, and $ZZ is the final note. This one is pretty similar to the one used when porting music but it has an extra “starting note” byte. It can only be used as a starting or one-shot pitch bend.
$EB $XX $YY $ZZ = Pitch Bend
$XX is the delay, $YY is the duration, and $ZZ is the final note. Must be put after $DD or other $EB commands for subsequent bends without resetting a note.
This command needs no arguments. It will repeat the last note indefinitely.
This command needs no arguments. It will repeat the SFX indefinitely.
$XX = Note Length
This can be any byte ranging from 00 to 7F, and can be put before a note or a pitch bend of any kind ($DD or $EB). If followed by another byte that is also in the 00 to 7F range, then that will be volume (see below). If a sound effect starts with a pitch bend ($DD), then the note length should be specified before it to last for as long as the pitch bend does ($XX + $YY arguments).
$XX $YY = Volume
This is volume; it can consist of one or two arguments. A channel has two DSP values for volume: left and right. If you specify only one value “$XX”, it will be copied into both left and right, which will result in the sound being centered. If you specify two values “$XX $YY”, the first one ($XX) will be left volume and the second one ($YY) will be right volume; this is used for panning. Surround is not allowed, as the command can only go from 00 to 7F (surround is 80 - FF, but those are notes and commands).
Even without ties, you can change the volume mid-note if you put it between pitch bends (after $DD and before/after $EB), the note length command should last for as long as the pitch bend does ($XX + $YY arguments).
VOLUME CAN ONLY BE PUT AFTER A NOTE LENGTH COMMAND.
This will stop the SFX.
$NoteLength $00 $AnyNote = Rest
Not an actual command, but a technique to simulate rests, what we are doing here is setting the volume to 00 for as long as the note lasts, then setting it back to normal when another note should play
I will do some breakdowns of vanilla SMW sound effects here:
, Note Length
, Pitch Bend ($EB)
, Extended Pitch Bend ($DD)
0D Get cape.txt
$DA $05 ;we start by setting our instrument
$08 $54 ;we specify starting note length and volume
$DD $9F $00 $08 $A3 ;starting pitch bend
$12 ;note length, used by the next pitch bend
$EB $00 $12 $AB ;pitch bend, this one keeps going up
$06 $3F ;we use this to change volume mid-note
$EB $00 $06 $A8 ;this pitch bend and subsequent ones are used to do “vibrato”
$11 $31 ;we change volume mid-note again
$EB $00 $11 $AB
$08 $23 ;and again
$EB $00 $08 $A8
$0F $15 ;and again
$EB $00 $0C $AB
$DA $03 ;we start by setting our instrument
$0C $15 $07 ;we specify starting note length and volume (panned to the left)
$DD $95 $00 $0C $A4 ;starting pitch bend, goes up
$06 ;note length, used by the next pitch bend
$EB $00 $06 $97 ;pitch bend, goes down
$0C $07 $1C ;note length and volume (panned to the right)
$DD $99 $00 $0C $A8 ;note resets, pitch bend, goes even more up
$06 ;note length, used by the next pitch bend
$EB $00 $06 $9A ;goes down
$0C $23 $0E ;note length and volume (panned to the left)
$DD $9D $00 $0C $AD ;note resets, pitch bend, goes even more up, and so on...
$06 ;the cycle continues and the pitch will go higher and higher...
$EB $00 $06 $9D ;until the sfx ends
$0C $0E $31
$DD $A1 $00 $0C $B0
$EB $00 $06 $A0
$0C $38 $15
$DD $A5 $00 $0C $B4
$EB $00 $06 $A3
$0C $15 $3F
$DD $A9 $00 $0C $B9
$EB $00 $06 $AD
07 Dry bones collapse.txt
$DA $02 ;we set the instrument
$08 $59 ;note length and volume
$B4 $B7 $C0 $BC $BE $0C $C3 ;notes
21 Valley of Bowser appears.txt
$DA $02 ;we set the instrument
$09 $1C $1C ;note length and volume (whoever programmed this set it twice??)
$08 $19 $1F ;note length and volume (panned to the right)
$07 $1F $19 ;note length and volume (panned to the left)
$AC ;and so on, with each note going lower and stronger panning...
$06 $15 $23
$05 $23 $15
$04 $0E $2A
This one is interesting because it’s a rumbling effect and it seems to be stopped by the game because the last note repeats indefinitely.
19 Clap + pop.txt
$DA $11 ;we set the instrument (thunder)
$0C $00 $54 ;we set the note length and panning
$8C ;we play a note in a very low pitch
$08 $1C $0E ;note length and panning
$0C $46 $38 ;note length and panning
$12 $38 $54 ;note length and panning
$8D ;another note
$0C $0E $1C ;and so on...
$12 $2A $1C
$18 $1C $0E
$08 $0E $1C
$0C $1C $0E
$06 $2A $15
$08 $0E $1C
$30 $1C $1C
$FF ;this ends the sfx by making the last note repeat forever
$DA $0C ;set instrument
$04 $46 ;note length and volume
$DA $9C $10 ;set noise and use instrument 10’s adsr values for it
$18 $2A ;note length and volume