ff3:ff3us:tutorial:music:brr

In this tutorial we'll be using FF3us to add a new BRR sample that can be used in songs. You do not need extended musical knowledge to complete this tutorial. One thing that will help is being familiar with the hexadecimal system, the concept of offset, the difference between an absolute and HiROM offset and hex editors.

We'll be using the FF5 bass drum sample from our BRR Sample Database. The only thing that you will need is a hex editor. There are many you can choose from, but I'd suggest one that has copy selection, paste-write, and paste-insert functionalities. One good all-purpose hex editor is HxD, and this is what has been used to take the screenshots below. Finally make sure you have a 1.0 or 1.1 FF3us ROM that is expanded either to 28Mbit or 32Mbit.

Select the second download on the FF5 page, the one labeled “BRR Samples with first two bytes as sample length. Pitch, loop and ADSR data are in a text file.”. Extract the archive and you are done for now.

Since each sample has data attached to it, we need to move this data first to make some room for the new sample data. What need to be moved is loop start positions, pitch multipliers and ADSR data. The pointers to the BRR data do not need to be relocated, for the simple reason that we will free the space right after them, thus leaving room to add more.

We will put the loop starting positions at $F20000, the pitch mutipliers at $F20200 and finally the ADSR data at $F20400. This leave enough room for the maximum of 256 samples.

There are 3 ASM instruction to modify, more precisely the offset that these instruction carry. Below is the original and modified code. Open HxD and press Ctrl+G, that will open a window. Type 05041C and press “Ok”. You are not at $C5041C. You need to enter 0000F2 ($F20000 inverted). We do not touch the 1st byte of the instruction, only bytes 2,3,4. Repeat a similar process for $C5049C and $C504DE.

Original code

Modified code

Let's move first the loop starting positions. Select the data from $C53D1C to $C53D99 as shown on the left below and press Ctrl+C. Press Ctrl+G and enter 320000 ($F20000 in HiROM offset). Right click and press “paste write”. The result should be like the right screenshot:

Redo this process for the pitch multipliers at $C53D9A and the ADSR data at $C53E18:

Pitch multipliers

ADSR data

Now we will add the data for the new sample. For more info on these 3 sample data, refer to the last 3 sections of this tutorial. Open the FF5.txt file in the sample archive and look at the 1st line. You'll see the three values that we need to add. Simply append 8C0A to the loop starting positions, append C000 to the pitch multipliers and append FFE0 to the ADSR data. The 3 following screenshots show this:

Loop starting position

Pitch multiplier

ADSR data

We need after this to import the actual sample. Open 01_bass_drum.brr with HxD, select all (Ctrl+A), copy (Ctrl+C) then “paste write” at $F20600. The two screenshots below show the beginning and the end of the sample:

Beginning

End

Finally we will add our new BRR pointer. Go at $C53D1C and add 00 06 F2 ($F20600 inverted). Note that in the screenshot below I replaced all the (now) useless sample data with FF. You can now use your new sample ($40) in the instrument data of a song (32 bytes each starting at $C53F95).

This cover the mechanical part of the import. Further down will be detailed how to change ADSR data, loop starting positions and pitch multipliers. Not all samples in the BRR Sample Database are “plug and play” like the FF5 samples. Some require data modifications.

Those two bytes are a looping position. As an example, for a sample of size $0900, he could have a loop position of $0850, meaning once the read reach $0850, $0850 to $08FF will loop. That loop position would be written 5008 in the ROM. A loop position is obviously always smaller than the sample length. The loop starting positions of the samples in the BRR Sample Database are in the most case good.

The ASDR Data is a two bytes value that apply an Attack Rate, Decay Rate, Sustain Level and Sustain Rate envelope to the sample. The format is the following, high bit of 1st byte tells if ADSR is enabled, otherwise Gain is used. Attack is on 4 bits, Decay on 3 while the 2nd byte has Sustain (3 bits) and Release (5 bits). The ADSR data of the samples in the BRR Sample Database are in the most case good. As an example and ADSR value of FFE0 is Attack Rate of 15, Decay Rate of 7, Sustain Level of 7 and Sustain Rate of 0.

Note that the ADSR settings on SNES are a bit different than the usual ADSR. A quick overview:

A Attack Rate 0 to 15 higher is shorter maximum 4100ms (at 0)
D Decay Rate 0 to 7 higher is shorter maximum 1200ms (at 0)
S Sustain Level 0 to 7 higher is louder 0% to 100% of initial sound
R Sustain Rate 0 to 31 higher is shorter maximum 38,000ms (at 1); 0 is infinite

The pitch multiplier is a two bytes value that is added to the note multiplier of a note to result in the pitch of the played note (VxPITCH). The game use the following table and formulas to get the correct pitch of a note:

Note modifiers

Formulas

Note that the pitch multipliers in the BRR Sample Database are good for all the Squaresoft games except FF4, Romacing Saga 1, Seiken Densetsu 3, Super Mario RPG, Bahamut Lagoon and Treasure of the Rudras. Those game will need modifications to their pitch values.

  • ff3/ff3us/tutorial/music/brr.txt
  • Last modified: 5 years ago
  • (external edit)