News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Metroid Tuner - Experimentation & Miscellaneous notes

Started by Grimlock, September 28, 2014, 05:58:12 PM

Previous topic - Next topic

Grimlock

Ok, so I figured I would start a thread to share some of my experimentation and what not with Metroid Tuner.  Hopefully others will contribute their findings in the future as well. 


SQ1 and SQ2 note blending test conducted in Norfair:
[spoiler]
My findings:


"C3" playing in SQ1

Playing the following in SQ2

C#3    //+1 NOTES 
D3      //+2 NOTES  (GOOD)
D#3    //+3 NOTES
E3       //+4 NOTES  (OK)
F3       //+5 NOTES  (GOOD)
F#3     //+6 NOTES
G3       //+7 NOTES  (VERY GOOD)
G#3    //+8 NOTES
A3       //+9 NOTES
A#3     //+10 NOTES
B3       //+11 NOTES
C4       //+1 OCTAVE  (VERY GOOD)

Incorporating the triangle channel into 3 note combinations didn't work well with the TRI in the 2nd octave, I'm going to experiment more with it in the 3rd and see how it goes.  Matching the lowest of the 2 note combination from SQ1 and SQ2 seemed to enhance the sound of the combination, having the TRI higher than the lowest of SQ1 and SQ2 didn't sound very good but may have its place somewhere (in some use).
     

<Context>
[Bank:            2]
[SongTable:       BD31]
[VolumeTable:     BCB0]
[NoteTable:       BE77]
[NoteLengthTable: BEF7]


<Song>
[Song:            2]
[NoteLengthTable: 0B]
[TriangleLength:  F0]
[Sq1VolumeTable:  4]
[Sq2VolumeTable:  4]
[Repeat:          True]


<Track>
[Song:    2]
[Track:   Square1]
[Address: B000]
[MaxSize: A3]  //163
// Remove or update MaxSize tag to embiggen data (be ever so careful).

// Track length: ~ 33 seconds
// Track size: 38 ($26) bytes
30 { // --------------
    :18 C3 C3 C3 C3 C3 C3
    :18 C3 C3 C3 C3 C3 C3
    :18 C3 C3 C3 C3 C3 C3       
} //   --------------

00 // Song terminator


<Track>
[Song:    2]
[Track:   Square2]
[Address: B0A4]
[MaxSize: A3]  //163
// Remove or update MaxSize tag to embiggen data (be ever so careful).

// Track length: ~ 33 seconds
// Track size: 49 ($31) bytes

30 { // -------------- //C3

    :18 - - C#3 C#3 C#3 C#3  //+1 NOTES 
    :18 - - D3 D3 D3 D3      //+2 NOTES  (GOOD)
    :18 - - D#3 D#3 D#3 D#3  //+3 NOTES
    :18 - - E3 E3 E3 E3      //+4 NOTES  (OK)
    :18 - - F3 F3 F3 F3      //+5 NOTES  (GOOD)
    :18 - - F#3 F#3 F#3 F#3  //+6 NOTES
    :18 - - G3 G3 G3 G3      //+7 NOTES  (VERY GOOD)
    :18 - - G#3 G#3 G#3 G#3  //+8 NOTES
    :18 - - A3 A3 A3 A3      //+9 NOTES
    :18 - - A#3 A#3 A#3 A#3  //+10 NOTES
    :18 - - B3 B3 B3 B3      //+11 NOTES
    :18 - - C4 C4 C4 C4      //+1 OCTAVE  (VERY GOOD)
     
} //   --------------

<Track>
[Song:    2]
[Track:   Triangle]
[Address: B148]
[MaxSize: A3]  //163
// Remove or update MaxSize tag to embiggen data (be ever so careful).

// Track length: ~ 33 seconds
// Track size: 52 ($34) bytes


30 { // --------------
    :18 - - - - C3 C3
    //:0C G3- G3- G3-
    //:0C C3- C3- C3-
    //:18 - - - - C3 C4   
} //   --------------



<Track>
[Song:    2]
[Track:   Noise]
[Address: BE47]
[MaxSize: 30]  //48
// Remove or update MaxSize tag to embiggen data (be ever so careful).

// Track length: ~ 156 seconds
// Track size: 14 ($E) bytes

32 { // --------------
    :60
        $01 $01 $01
   
} //   --------------


[/spoiler]




Experimenting with the Noise channel:
EDIT: I organized a small list of the more "useful" sounds (In my opinion)
[spoiler]
I was attempting to recreate some Nine Inch Nails drum beats in M!, here's the results of my sampling the different sounds available:

Some useful results:
TAPS                  = $03 $08 $07 (faint to loud progression) $04 = Tap (slightly cut off at end of note)
BASS DRUM        = $45 $27 $39
SYMBOL/CRASH  = $02 $0A $64 $67 $77 (clap like)
  (Snare sound maybe)
DRUM ROLLS      = $5B drum roll, $2B = drum roll - slightly louder than $5B, $57 = low tone drum roll
COMPUTER BEEP = $49 4D
STEAM SOUNDS  = $80 quick burst $32 continuus $44 with fade off at end
THUMP SND        = $53
BOMB SND          = $79
METAL TAPPING   = $33


Full testing notes:

$01 = Silence
$02 = Trash can lid
$03 = Faint tap -01
$04 = Tap (slightly cut off at end of note)
   $05 = X   Same as $02
$06 = Hiss sound effect
$07 = Tap - Slightly more pronounced than $08
$08 = Tap - Slightly more pronounced than $04
   $09 = X   Tap same as $04
$0A = Trash Can - Wooden stick - Strong pronouncement
$0B = Static sound effect burst - Bold Mid high tone
$0C = Faint high pitched tone
$0D = Static sound effect - Muffled Mid tone
   $0E = Same as $0C Faint high pitched tone
$0F = Trash can lid (slightly cut off at end of note)
$10 = Steam jet burst (Like $0B but tone is higher)
$11 = Flame jet or quake sound - low tone
$12 = Steam jet low tone continuous - sounds oscillating
$13 = Metal tapping slightly faint
   $14 = X none
$15 = Flame jet or quake sound - low tone slightly louder than $11
$16 = Flame jet or quake sound - mid tone louder than $15
$17 = Small metal ring tapped - high pitch ding
$18 = Machine gun fire or fast blade (unlike existing in game sounds)
$19 = Explosion - similar to bomb weapon
$1A = $19
$1B = $0B - Static
$1C = $0B - Static Slightly lower tone
$1D = $19 - Slightly louder - Explosion - similar to bomb weapon
$1E = Static sound effect burst - Bold high tone
$1F = $0B - Static burst
$20 = Steam burst faint mid tone
$21 = Flame jet or quake sound - low tone - faint
$22 = Flame jet or quake sound - high tone
$23 = Spring sound - Bold
$24 = Faint high pitched tone
$25 = Short buzz spring sound - mid tone
$26 = Steam burst with a fade off at the end (Same as $44)
$27 = Stomp on floor
$28 = Steam burst - quick - mid tone
$29 = Buzz - low tone - sounds oscillating
$2A = Faint high pitched tone
$2B = drum roll - slightly louder than $5B
$2C = same as $28 - Steam burst
$2D = Buzz - low tone - sounds oscillating lower than $29
$2E = Large cannon firing automatic or machine - bold
$2F = Steam burst with fade off - slightly higher tone than $68

$32 = Steam sound continuous - similar to fade off steams
$33 = Beep high tone - harp like sound
$37 = Beep high tone - harp like sound - slightly longer note than $33)
$39 = Stomp on floor
$3B = Short buzz spring sound - mid tone (slightly longer note than $25)
$3F = Steam/Trash Can hit with fade off
$40 = Short buzz - low tone
$42 = Machine gun fire

$22 = Earth Quake sound
$33 = Metal tapping

$42 = Machine gun
$43 = Steam continuous
$44 = Steam burst with a fade off at the end ( $56 $52 same without fade off)
$45 = Stomp on ground
$49 = beep mid
$4D = beep high

$51 = Faint machine gun fire
$53 = Short rock hitting ground sound
$55 = Car horn - Bold
$57 = Distant machine gun fire
$5B = drum roll
$5F = Steam burst with a fade off at the end lower volume that $44

$60 = Clap (short)
$66 = TV Static - high tone
$65 = bomb - fade off at end
$68 = Steam burst with a fade off at the end louder volume that $44 $5F ($6A for continuous)

$77 = Trash can lid/clap
$79 = Bomb exploding with fade off
$7A = steam jet with slight oscillation
$7D = stomp on ground

$88 = low tone and volume rumble
$99 = low tone and volume rumble
$AA = Mild steam sound
$BB = High tone spring sound, like a buzzer
$CC = TV Static -  lower tone (better than $66)
$DD = same as $FF - Spring sound
$EE = Machine gun fire - BUGGY
$F1 = boot stomping on the ground
$FE = door bell buzzer
$FF = Spring sound

cans - 64 67[/spoiler]

Just a few for now, I have more that I'll post at a later time.

NARFNra

#1
I think I managed to decode the part of the diassembly that controls duty cycle and volume for things. It's just a bit field. After looking through the disassembly and the ROM Map... Let's take Norfair as an example.

So the control bytes for the two pulse channels are stored at $628 and $629 in the RAM:
   0628        SQ1DutyEnvelope         Loaded into SQ1Cntrl0 when playing music
   0629        SQ2DutyEnvelope         Loaded into SQ2Cntrl0 when playing music


So what's SQ1Cntrl0? Well, it's a byte the Audio Processing Unit uses. And according to nesdev...

Address Bitfield Description
$4000 DDlc.vvvv Pulse 1 duty, length counter halt, constant volume/envelope flag, and volume/envelope divider period (write)


Things to note here are the DD and the vvvv, these are Duty Cycle (00-03) and Volume (0-F) the NES has 4 possible duty cycles, though 01 and 03 sound identical, and that means that that data is stored in the first 2 bytes of the song.

For example, in Norfair, if you open up FCEUX and look at the memory, you'll see 34 in both $628 and $629.
HEX 34 = BINARY  00110100
In other words, both channels are using duty cycle setting 0. So theoretically, we can get all possible duty cycle settings by using either 00, 01, or 10 (2 in binary) in that memory slot.

00110100 (34 HEX)
01110100 (74 HEX ~ 34 + 40 because that's the 40s byte)
10110100 (B4 HEX ~ 34 + 80 because that's the 80s byte)
It's nice to be able to quickly change between binary and hex by memory, but you can just use a calculator. Anyway, so if we test this by changing the bytes, this does indeed work.

But this is just how to change it in the memory editor, how do we change it in the game? Well, you need to look through the disassembly. I'm still not sure how to tell which song is which, as the numbers don't seem to match up... but looking on the Norfair page, we're looking for this part;

Music00Start:
LBC77: JMP Music00Init ;($BCAA)Initialize music 00.

Music01Start:
LBC7A: JMP Music01Init ;($BCA4)Initialize music 01.

Music02Start:
LBC7D: JMP Music02Init ;($BC9A)Initialize music 02.

Msic03Start:
LBC80: JMP Music03Init ;($BC96)Initialize music 03.

Music04Start:
LBC83: JMP Music04Init ;($BC89)Initialize music 04.

Music05Start:
LBC86: JMP Music05Init ;($BC9E)Initialize music 05.

Music04Init:
LBC89: LDA #$B3 ;Duty cycle and volume data for SQ1 and SQ2.

XYMusicInit:
LBC8B:* TAX ;Duty cycle and volume data for SQ1.
LBC8C: TAY ;Duty cycle and volume data for SQ2.

LBC8D:* JSR SetVolumeAndDisableSweep ;($B9E4)Set duty cycle and volume data for SQ1 and SQ2.
LBC90: JSR InitializeMusic ;($BF19)Setup music registers.
LBC93: JMP LoadCurrentMusicFrameData ;($BAA5)Load info for current frame of music data.

Music03Init:
LBC96: LDA #$34 ;Duty cycle and volume data for SQ1 and SQ2.
LBC98: BNE -- ;Branch always

Music02Init:
LBC9A: LDA #$F4 ;Duty cycle and volume data for SQ1 and SQ2.
LBC9C: BNE -- ;Branch always

Music05Init:
LBC9E: LDX #$F5 ;Duty cycle and volume data for SQ1.
LBCA0: LDY #$F6 ;Duty cycle and volume data for SQ2.
LBCA2: BNE - ;Branch always

Music01Init:
LBCA4: LDX #$B6 ;Duty cycle and volume data for SQ1.
LBCA6: LDY #$F6 ;Duty cycle and volume data for SQ2.
LBCA8: BNE - ;Branch always

Music00Init:
LBCAA: LDX #$92 ;Duty cycle and volume data for SQ1.
LBCAC: LDY #$96 ;Duty cycle and volume data for SQ2.
LBCAE: BNE - ;Branch always


There's a lot of stuff here. However, thanks to FCEUX, we know that Norfair had the same thing for both tracks; $34. That leaves us with


Music03Init:
LBC96: LDA #$34 ;Duty cycle and volume data for SQ1 and SQ2.
LBC98: BNE -- ;Branch always


So it looks like if you want to make a song that didn't originally have different duty cycle data for both channels have different duty cycle data, you might have to do some hex editing. But if we just want to make Norfair's theme play with 50% square waves instead of 12.5%, we just have to change byte BC96 in this page. I'm not totally sure how to determine which songs are which and which bank to find stuff in, but, well, changing the byte at BCA7 affects Norfair. Oddly, it also affects the Samus appearing theme... which means this is more stuff Metroid does with saving space. On the plus side, this makes a cool effect where the intro song sounds different depending where you are!

But yeah, I'll try and do more research on this later.