Differences
This shows you the differences between two versions of the page.
ff3:ff3us:tutorial:music:brr [2018/10/20 06:35] madsiur [3. Changing the Code] |
ff3:ff3us:tutorial:music:brr [2019/02/12 11:26] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Adding a new BRR Sample ===== | ||
- | |||
- | 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. | ||
- | |||
- | ==== 1. Getting the file and tool ==== | ||
- | |||
- | We'll be using the FF5 bass drum sample from our [[ff3: | ||
- | |||
- | ==== 2. File we will be importing ==== | ||
- | |||
- | Select the second download on the [[ff3: | ||
- | |||
- | ==== 3. Changing the Code ==== | ||
- | |||
- | 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, instrument 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. | ||
- | |||
- | {{ff3: | ||
- | |||
- | 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 "// | ||
- | |||
- | **Original code**\\ | ||
- | {{ff3: | ||
- | |||
- | **Modified code**\\ | ||
- | {{ff3: | ||
- | |||
- | ==== 3. Moving the Data ==== | ||
- | |||
- | 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). | ||
- | |||
- | {{ff3: | ||
- | |||
- | Redo this process for the pitch multipliers at $C53D9A and the ADSR data at $C53E18: | ||
- | |||
- | **Pitch multipliers**\\ | ||
- | {{ff3: | ||
- | |||
- | **ADSR data**\\ | ||
- | {{ff3: | ||
- | |||
- | |||
- | ==== 4. Adding the new sample 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**\\ | ||
- | {{ff3: | ||
- | |||
- | **Pitch multiplier**\\ | ||
- | {{ff3: | ||
- | |||
- | **ADSR data**\\ | ||
- | {{ff3: | ||
- | |||
- | |||
- | ==== 5. Importing the Sample ==== | ||
- | |||
- | We need after this to import the actual sample. Open // | ||
- | |||
- | **Beginning**\\ | ||
- | {{ff3: | ||
- | |||
- | **End**\\ | ||
- | {{ff3: | ||
- | |||
- | Finally we will add our new BRR pointer. Go at $C53D1C and add 00 06 F2. Note that in the screenshot below I replaced all the (now) useless sample data with FF. You can now use your new sample ($30) in the instrument data of a song (32 bytes each starting at $C53F95). | ||
- | |||
- | {{ff3: | ||
- | |||
- | 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 [link|BRR Database] are "plug and play" like the FF5 samples. Some require data modifications. | ||
- | |||
- | |||
- | ==== A. Loop Starting Position ==== | ||
- | |||
- | 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 [[ff3: | ||
- | |||
- | |||
- | ==== B. ADSR Data ==== | ||
- | |||
- | 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 [[ff3: | ||
- | |||
- | {{ff3: | ||
- | |||
- | Note that the ADSR settings on SNES are a bit different than the usual ADSR. A quick overview: | ||
- | <WRAP 600px> | ||
- | | 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 | | ||
- | </ | ||
- | ==== C. Pitch Mutiplier ==== | ||
- | |||
- | 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**\\ | ||
- | {{ff3: | ||
- | |||
- | **Formulas**\\ | ||
- | {{ff3: | ||
- | |||
- | Note that the pitch multipliers in the [[ff3: | ||