Jump to content

Recommended Posts

Introduction


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

Here you'll learn:

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 the12-track patch.

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.

Also, this tutorial contains lots of hyperlinks to FEUniverse since it was originally formatted for FEUniverse (go figure). I really can't be bothered updating them so you'll just have to deal with it.

Edited by Agro

Share this post


Link to post
Share on other sites

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.

Edited by Agro

Share this post


Link to post
Share on other sites

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.

voice%20table%201_zpsc8ge14dw.png

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 13768 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.

Edited by Agro

Share this post


Link to post
Share on other sites

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.

precious%20things%201_zps1vaqncfz.png

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...

precious%20things%202_zpsf6qsrp0r.png

You have this. You'd then need to copy over two sets of parameters to your own voice table, namely Address1 (or Address2 if it's a Multi-instrument) and the Atk/Dec/Sus/Rel values, and then you can use that instrument!

Edited by Agro

Share this post


Link to post
Share on other sites

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:

multi%201_zps9h0fddky.png

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:

multi%202_zps4zgpscwk.png

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:

multi%205_zpsliblbwn6.png

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)

multi%203_zpsiwck7ivn.png

multi%204_zpsapzjdbxt.png

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:

multi%206_zpsckzixpdh.png

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.

Edited by Agro

Share this post


Link to post
Share on other sites

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.

drum%201_zpsdendqzgu.png

If you hit Edit...

drum%202_zps7l82vb3l.png

Looks familiar, right?

drum%203_zpsgifazjiu.png

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



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.

Edited by Agro

Share this post


Link to post
Share on other sites

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.

https://www.youtube.com/watch?v=igLigEwoBJ0

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.

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.

(continued in next post)

Edited by Agro

Share this post


Link to post
Share on other sites

Now I have this.



That's better.

(continued in next post)

Edited by Agro

Share this post


Link to post
Share on other sites

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:

https://www.youtube.com/watch?v=NRkzAnBGCkA

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.

Edited by Agro

Share this post


Link to post
Share on other sites

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 in the questions forum! 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.

Edited by Agro

Share this post


Link to post
Share on other sites

What a run, I didn't read everything, but I'll definitely go take the time to absorb all this knowledge you brought here Agro, congratulation for these awesome lessons!

Share this post


Link to post
Share on other sites

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.

Don't know what you're talking about. I haven't been sending you any message so... (What do you say? I'm not credible?)

Nice, the edit did something wierd. It posted a second post instead of just editing the first one.

Edited by Solum

Share this post


Link to post
Share on other sites

Don't worry my friend, it wasn't just you :P: I've been preaching that for a little while now

Share this post


Link to post
Share on other sites

solum he wasnt talking to you o.o

i didnt read all this because im stupid, but actually in the games if you check the bass guitars they always play a note like an octave lower than you tell it to. thats because the sample isnt at middle C. if you add a sample to the game, the quality is better on it the less you change the pitch of the original. so just keeping the bass sample a lower note is a neat way to keep it sounding better but the midis have to work with that.

blurgurgrmr i wish the thing says sustain before decay, because sustain is how long to hold the volume before the decay starts happening...

Share this post


Link to post
Share on other sites

i didnt read all this because im stupid, but actually in the games if you check the bass guitars they always play a note like an octave lower than you tell it to. thats because the sample isnt at middle C. if you add a sample to the game, the quality is better on it the less you change the pitch of the original. so just keeping the bass sample a lower note is a neat way to keep it sounding better but the midis have to work with that.

Yeah, that's right. What I find odd, though, is that there's a frequency adjustment value in the header of the samples that can easily be changed and would up the octave but isn't used this way. It's... weird.

solum he wasnt talking to you o.o

Our good friend Solum recently PM'd me for music hacking advice :P:

Edited by Agro

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...