Basic Voice Table Editing in Sappy

Tags: #<Tag:0x00007f55f842c4a8>

#1

Hello children. Today I’m going to teach you the basics of editing FE (and GBA) sample editing.

Here you’ll learn:

  1. All about the voice table
  2. Navigating the voice table editor in Sappy
  3. Taking existing voices from other songs in the game
  4. Creating and editing multi-instruments
  5. Creating and editing drum instruments and how to fix the “boop” sound
  6. Envelopes (Atk/Dec/Sus/Rel) and how to use them

Don’t worry, it’s all very simple and just requires a little bit of occasional maths and a decent understanding of how to use a hex editor. You’ll need a working version of Sappy and if you haven’t already, please read my explanation of the Sappy UI and if you’re using FE7 or FE8, I highly recommend patching your ROM with the 12-track patch.

We’ll start with a bit of an introduction.

Introduction


Why would you want to edit samples, anyway? Aren’t the vanilla ones enough? Well, that’s true, but the game’s sound system is not quite fully utilised by the game and it’s a crying shame, because songs could sound so much better if they did. Not to mention there are some funky octave shifts that the default samples have.

This tutorial is oriented at editing EXISTING resources within the ROM, and less so on inserting NEW resources. Still, I will teach you how to use some new resources too. Custom samples and importing samples will be taught in another tutorial.

I’ll be using the words “voice” and “instrument” interchangeably. Questions within the thread are more than welcome.


Fire Emblem: Maiden of Darkness. Check the OP for updates I do them everytime I achieve now
Music hacking help topic
The Grand Library of FEU [UNDER CONSTRUCTION]
#2

The Voice Table


A voice table is a collection of pointers to samples for a song to use. They typically consist of 127 voices, though some can be unused. Each entry is 12 bytes long, and consist of:

  • 4 bytes for the instrument type, pitch & panning settings
  • a 4-byte pointer to the instrument sample
    • Alternatively, if the instrument is a “drum”, this is a pointer to another table of samples
  • 4 bytes for attack, decay, sustain and release a.k.a. the envelope, which will be discussed later
  • Alternatively, if the instrument is a “multi”, then this is instead a pointer to a list of samples the instrument will use. More on this later.

The end result is something that looks like this:

00 3C 00 A0 55 66 77 08 FF 00 FF 80
40 00 00 A0 55 66 79 08 45 60 78 08
80 00 00 A0 55 66 74 08 FF 00 FF 80
00 3C 00 A0 55 66 73 08 FF 00 FF 80
00 3C 00 A0 55 66 7A 08 FF 00 FF 80

If this were a voicegroup, then the first line would correspond to instrument 0, typically a piano; the second to instrument 1, etc. You can imagine this would continue until there were 127 of these. It’s worth noting that FE games have a different voicetable for every song (there are various reasons for this).

I’ll talk about the first four bytes here.


The first is a byte that tells us the instrument type, which can be Direct, Multi, or Drum. Occasionally this is also set to 08, which tells the game to ignore any pitch offsets and play the sample at the original frequency, which is mostly used for drums and sound effects.

0x00: a regular Direct sound, or sample. These are normal instruments.

0x40: a “multi” sound. This is a series of two or more samples that the game will play depending on which note is playing. What I mean by this is you could have one sample set to play for notes C0-C5, and then another sample to plays notes from C5-C10. This is especially useful for instruments that have a wide pitch range and therefore need more sample types to accommodate for this. This is covered later in this tutorial.

0x80: a “drum”. This is similar to a multi, but rather than have a sample play for a range of notes, this will specifically make each note correspond to one sample. The pointer instead goes to a table of samples which are each sample in a drum. This is also covered in more detail later.


The second byte tells us the pitch at which the sample should be adjusted to. This is actually completely unused unless the sample is within a Drum table, so it won’t help to adjust the pitch of your strings or piano, and only the pitch of a hi-hat, or cymbal, etc. By default, this should be 0x3C, which is 60, which is equivalent to a middle C/C5.


The third byte is, as far as I’m aware, unused.


The fourth byte is a panning setting. If bit 7 is set i.e. if the value is 0x80 or higher, then the game will actually use the panning setting you give it. To get a panning setting, you need to take your desired value and add 0x80 to it. So if you want the sample to play at the extreme left, then it would be 0x01 + 0x80 = 0x81. This mostly has applications within a Drum table, like if you wanted two cymbals where one played on the left and the other on the right, but could also be applied to something like a piano, or an organ. If you have no idea what any of that means, just set it to 0x00.


The next four bytes are a pointer to the actual sample/sound itself, which is to be covered a little bit later.


Finally, the last four bytes are the envelope, which is explained here.


#3

Navigating the Voice Table Editor in Sappy


Open your ROM in Sappy, find the song you want to edit, and you’ll be presented with the usual interface. Hit “Tasks”, and you’ll be presented with this.

As you can see, this looks nothing like what I showed you earlier. Why? Because Sappy shows you the same information but in a different way and with better context, allowing you to process that information easily. You could easily do all of this manually with a hex editor, but this is much simpler, no?

Yellow: This dropdown menu presents you with a list of each instrument. At the moment it’s on instrument 0.
Red: A dropdown menu that lets you specify whether you want this instrument to be a Direct, Multi or Drum voice.
Purple: The address of the sample you want to use.
Light blue: The envelope. I’ll explain this in the last chapter of my tutorial.
Grey blue: Press this every time you make a change, and when you’re done messing with it, press OK.
Dark red: What the data actually looks like in the ROM.


Ticking “Fixed Frequency” forces the game to play the sample at the game’s default frequency, which is 13379 Hz for a standard FE7 ROM. Mostly used within drumkits for drum samples.


"Reverse Playback" does nothing. I have no idea why this is here.


Ticking the “Forced Pan” box allows you to enter a value between 0-127 in the “Pan” box. This does exactly what it sounds like, and is mostly used for drumkits, like when you want two cymbals where one plays in the left and the other in the right, or when you have 3 toms and you want one to play from the right, one in the middle, and one to the left.


#4

Taking Existing Voices from other Songs in the Game


So let’s say you heard that trumpet in Precious Things, and you wanted to use that in your own song, and you weren’t sure which instrument it was in the Native Instrument Map. How else could you find out how to use it? Well, you’d have to open up the song in Sappy first.

Using the ticks you can isolate the main melody and figure out which instrument is being used for it. I’ve circled it here - it’s instrument 101. So you would go into edit voice table, and then to instrument 101, and then…

You have this. You’d then need to copy over two sets of parameters to your own voice table, namely Address1 and the Atk/Dec/Sus/Rel values, and then you can use that instrument!


#5

Creating and Editing Multi-instruments


Have you ever listened to your music and thought, “gee, if only I could get the tune to switch to this sample when it plays these notes”? Or perhaps wanted to have some note play in the left ear, and others in the right? If you have, multi-instruments are here to save the day. This is also critical if you want to import samples from DS and some other GBA games, so pay close attention.


Multi-instruments fun things to play with. As stated before, they come in a structure like this:

40 00 00 00 XX XX XX 08 YY YY YY 08

The 0x40 lets the game know it’s a multi instrument, but then the next two pointers are a little bit different from Direct instruments. The first pointer is to another table of instruments, and the second is a pointer to an array of numbers that designate each note and which of the instruments within that table to play. Confused? Don’t worry, I totally get it. Here’s a graphical representation of that information:

So the first pointer points to an array of more Direct instruments. The second pointer is to a set of data that designates which of the instruments each note should play. For your sake I have put the notes above each byte to represent what each one means. There are 10 octaves in standard MIDI notation, so you only need a maximum of 120 bytes to store this information. You can have as many different Direct instrument as you like; there is no specific limitation. Keep in mind that each Direct instrument has its own envelope, too. This can be very important, provided you know how to use it…


All of this can be edited via Sappy, which is what makes this program so bloody beautiful. Just make sure you put each set of data in free space. As soon as you change the instrument type to “Multi” you’ll be presented with this screen:

Hitting Edit on the first pointer brings you to an array of more Direct instruments, which should be very familiar to you by now.

Hitting Edit on the second pointer, however, brings you this:

This, my friend, is a beautiful, graphical and interactive representation of the data from the second pointer. It specifically shows you the notes that the first Direct instrument will play for… (Tip: I always click “Show all Samples” otherwise if Sappy doesn’t detect an instrument it won’t show in the dropdown menu)

And you can select other samples within your multi-sample group, too.

If you actually click on the keys it will select the notes for you, and you can hold your mouse down and drag it across the keys if you like, too.

In case it wasn’t obvious enough, this is how everything correlates:


You pretty much know how to construct a multi-instrument now. It’s quite straightforward, even if explaining it in words is a bit difficult.


Inserting Custom Sound Samples
#6

Creating and Editing Drum Instruments; Fixing the Boop


Perhaps you’ve inserted a song now using the Native Instrument Map and found that you got a lot of booping sounds, or maybe that you had a song that you wanted to use but couldn’t get the percussion just right. Or, perhaps you wanted to insert a few new sound effects, or you’re hacking FE12 music and wanted to get the guitar from Tearing Shadows working. You’ve come to the right place. Here you’ll learn the basics of the structure of a Drum instrument, and how to create and edit your own.


Drum instruments have the structure like this, as I outlined earlier in the tutorial.

80 00 00 00 XX XX XX 08 00 00 00 00

The 0x80 tells the game that it’s a Drum, and then the pointer after that points to another array of instruments that the drum uses for each note. For instance, if that XX XX XX 08 were D6 E7 A1 08, then at $A1E7D6 we’d have this:

08 3C 00 D0 YY YY YY 08 FF 00 FF CC
08 3C 00 E6 XX XX XX 08 FF 00 FF CC
00 3C 00 A2 ZZ ZZ ZZ 08 FF 00 FF CC
08 3C 00 F0 YX YX YX 08 FF 00 FF CC
00 3C 00 88 YZ YZ YZ 08 FF 00 FF CC
[and so on]

What does this data actually mean, though? Well…

08 3C 00 D0 YY YY YY 08 FF 00 FF CC // play this sample for C0
08 3C 00 E6 XX XX XX 08 FF 00 FF CC // play this sample for C#0
00 3C 00 A2 ZZ ZZ ZZ 08 FF 00 FF CC // play this sample for D0
08 3C 00 F0 YX YX YX 08 FF 00 FF CC // play this sample for D#0
00 3C 00 88 YZ YZ YZ 08 FF 00 FF CC // play this sample for E0
[and so on]

Now, you’ll have noticed that unlike typical Direct instruments, these samples can sometimes have a 0x08 at the beginning. Before, I said that this makes them play at a fixed rate of 13768 Hz, which is the game’s default playback for all samples. This is because (likely for space-saving reasons) the samples in FE7 were inserted at a high frequency and then had that frequency lowered by the game’s software, which would allow them to save on a bit of storage space. It isn’t terribly important, but do keep in mind that this is something you need to change if you want to alter the pitch of the drum samples. This is shown by the box, “Fixed Frequency” in Sappy.

The 0x3C can be very important here, as well, since it’s the only time the game pays attention to them. As I said in the beginning, 0x3C is 60, which corresponds to a middle C. This means that the game plays the sample at a (technically) unaltered pitch. However, if there is a 08 in front of it, the game will still ignore the 3C. If you change the 08 to a 00 and then change the 3C to another pitch, you’ll hear the difference. This is shown by the dropdown menu “Base Note” in Sappy.

The fourth byte in the sequence is the “Forced pan” value that you can see in Sappy. If you don’t want any forced pan at all, change this to 00. Otherwise, pan can be calculated by [desired pan between 0-127] + 0x80. If you are inputting this directly into Sappy, just put in your desired value.

Finally, there is the pointer to the sample, of course. I’m sure you worked this out on your own.


This is how the Drum editor looks in Sappy.

If you hit Edit…

Looks familiar, right?


Occasionally you will see these things. These are the offenders of the “boop” sound. This is instrument 22 in Drum instrument 127. I want you to look at this list, now:

[spoiler=Notes in decimal numbers]
1 C 0
2 C# 0
3 D 0
4 Eb 0
5 E 0
6 F 0
7 F# 0
8 G 0
9 G# 0
10 A 0
11 Bb 0
12 B 0
13 C 1
14 C# 1
15 D 1
16 Eb 1
17 E 1
18 F 1
19 F# 1
20 G 1
21 G# 1
22 A 1
23 Bb 1
24 B 1
25 C 2
26 C# 2
27 D 2
28 Eb 2
29 E 2
30 F 2
31 F# 2
32 G 2
33 G# 2
34 A 2
35 Bb 2
36 B 2
37 C 3
38 C# 3
39 D 3
40 Eb 3
41 E 3
42 F 3
43 F# 3
44 G 3
45 G# 3
46 A 3
47 Bb 3
48 B 3
49 C 4
50 C# 4
51 D 4
52 Eb 4
53 E 4
54 F 4
55 F# 4
56 G 4
57 G# 4
58 A 4
59 Bb 4
60 B 4
61 C 5
62 C# 5
63 D 5
64 Eb 5
65 E 5
66 F 5
67 F# 5
68 G 5
69 G# 5
70 A 5
71 Bb 5
72 B 5
73 C 6
74 C# 6
75 D 6
76 Eb 6
77 E 6
78 F 6
79 F# 6
80 G 6
81 G# 6
82 A 6
83 Bb 6
84 B 6
85 C 7
86 C# 7
87 D 7
88 Eb 7
89 E 7
90 F 7
91 F# 7
92 G 7
93 G# 7
94 A 7
95 Bb 7
96 B 7
97 C 8
98 C# 8
99 D 8
100 Eb 8
101 E 8
102 F 8
103 F# 8
104 G 8
105 G# 8
106 A 8
107 Bb 8
108 B 8
109 C 9
110 C# 9
111 D 9
112 Eb 9
113 E 9
114 F 9
115 F# 9
116 G 9
117 G# 9
118 A 9
119 Bb 9
120 B 9

[/spoiler]

This means that instrument 22 is equivalent to A1; therefore, if you’re getting boops, it could be because you have A1s playing in your MIDI. This list is unfortunately not standardised and thus some MIDI editors and other lists may actually list C0 as C -2 and B9 as B7, or something like that. That’s something you’ll have to figure out on your own.

Remember in a previous chapter how I showed you how to replace a Direct instrument, and transplant it from another song? The sample principle applies here. Let’s say your song has G3 Toms. Well, FE7 doesn’t have G3 toms, but it sure does have F3 toms. So you could copy over the parameters from instrument 42 to instrument 44 and that would also solve your boop problem; not to mention, you’d be rid of the problem forever.


One thing that is also fantastic is this Wikipedia page here. It’s a bit of a cheat sheet that gives you a rough guide as to which keys correspond to what drum sounds. Keep in mind that FE games don’t use the entire array and thus have some blank entries but if you need a better visual guide, this is super useful.


Music hacking help topic
#7

Envelopes


It’s finally time to talk about envelopes. I’m not exactly an expert in explaining what these are, so watch a video on YouTube which explains what they are and how the affect a sample. Envelopes can be very important in manipulating samples to get them how you want them to sound. The best way is to use worked examples.


I’m going to give you this pre-assembled MIDI of Endless Battle (as a .s file) from FE12 to use with the FE7 Native Instrument Map. Please insert that into an FE7 ROM and play it in Sappy.

This should be what you hear. As you can see, the strings are not quite there. There are several reasons for this; the sample is obviously not identical to FE12’s. But there’s more. The strings don’t quite reverberate, and they’re no staccato-y enough. You can fix a lot of this problem with - you guessed it - envelopes.

First of all, we’re going to make the strings sound more reverberant by increasing the Release value. This will increase the time it takes for the note to fade off, so to speak. Head to Edit Voice Table, go to instrument 40, and change the Rel to 204. You can change this to any value between 0-255, but I prefer around 204-224. Any more than that is excessive for most instruments and will generate a lot of noise (hissing sound) when played in-game, which isn’t pleasant.

Hit Update, and then OK. Play it. You should have this.

Sounding better, right? We’re not quite there yet, though. I want my strings to not ring out so much. They need to fade off from the moment they strike. This is where I change the Decay value. Decay is the speed at which the note starts to quieten from the moment it is played, rather than at the end. Once again you can change this to any value between 0-255, but I’m going to try it at around 236. I’m also going to completely get rid of Sustain, which will make it so that the note doesn’t keep “holding on” in a loop after it plays, and will instead continuously fade off.

Now I have this.

That’s better.


So you see, I didn’t actually insert any new samples at all, but still managed to get an existing sample to sound similar to how the original might sound. I could even decrease the Attack, to give it a bit of a softer start.

Or, I could swap out the instrument for another one, to get a different sound, but the same envelope:


This is just one way that you can use envelopes to have a more unique sound, whilst still using FE7 samples and retaining the “flavour” of the original songs.


#8

Ending notes


That’s pretty much it for the basics of voice table editing using Sappy. After this I’ll show you how to insert your own custom samples. Hopefully sample editing is starting to come together a little bit for you. As always, if something isn’t clear enough, please post a question here! Also, think twice before you PM me - if you think it’s something that could be answered by the community, put it in the public forum so someone else has a chance to help out, too.


Sound Sample Format Explained
#9

I think I’ve completed this enough for it to go fully public. Still to do: Drum instruments.

Edit: Finished!


#10

How do I fix the hiss/harmonic buzz at the start of this song?
It uses Piano 1 (0x2A8068) from the FE8 Native Instrument map with 255/250/0/204. Reducing the Release value doesn’t help.


#11

The problem is with the sample - the loop is really short. Your best bet would be to grab a sample from another game with a better sample. The Multi piano from Mother 3 comes to mind.


#12

Does Mother 3 use Sappy? It didn’t work for me.


#13

All documentation I can find confirms this. Keep it set to zero to be safe.

13379, innit? (There’s more than one place to make this change)

I thought it used a full set of 128 values tho (and Google seems to agree).

Man, I wish that first dialog had more useful labels than “Address1” and “Address2”. :confused:

That’s a little confused/confusing. High sample frequency for the inserted sample = more samples per unit time = more storage space. The software doesn’t “lower the frequency” so much as it interpolates in the sample data as appropriate for the playback sample frequency. So if the engine is mixing the sounds and outputting at a sample rate of 13379 Hz, and the instrument sample was recorded at double that sample frequency, then it basically needs to ignore every other sample value.

To clarify, my understanding is that the actual recorded sample is assumed to be at a middle-C pitch, and the “base note” value here tells it what pitch to play at instead - so it’s used to calculate a new frequency value for resampling. A 0x08 value in the first byte overrides that, because it directly specifies the resampling frequency to use. Of course, the code can’t actually detect the pitch of the samples, so this assumption is just the convention. You could record an instrument sample at a different pitch, but then you need to correct for this either with the base note value for drums, or in the note data for direct/multi instruments.

Ewww, Discourse set up two nested scrollbars for that. :frowning:


#14

it uses a more up to date version that is fundamentally similar. you should at least be able to use the GBA musriper method to extract an sf2 file


#15

GBAMusRiper - ‘No sound engine was found.’
VGMTrans came up with… something. A bunch of samples and sequences?

It doesn’t have to be Mother 3, I just want a clean sounding piano. What other games could I try?


#16

I’m not really sure! That’s the only GBA game I can think of that has a nice piano. I think I downloaded the soundfont from some forum somewhere, now that I think about it.


#17

Bleh. I downloaded a nice sounding piano soundfont and converted the samples to 8bit mono. Now I have a proper multi piano that sounds pretty crisp in Sappy, but the emulator still makes it fuzzy. I guess it can’t be helped.


#18

I’m working with ipatix from PokeCommunity to get a nicer sound from FE7, it should be released soon-ish


#19

I found the Mother 3 soundfont, if you still wanted it.


#20

Thanks! The piano soundfont I ended up using is actually better, but the other instruments should come in handy.