Language…
3 users online: Darknubs, foxypal, HotZin - Guests: 81 - Bots: 125
Users: 58,128 (2,470 active)
Latest user: maczampieri

A Comprehensive Guide to Porting

WIP

Hello dear reader and assumed porting apprentice,

This guide serves to be as complete as possible and should get you from knowing nothing about porting to being able to do everything. It was created by me, Torchkas. We will be working with a pre-prepared MIDI. Note that these are simply all of the things I've learned over the years. Although it strives to be a complete guide, be sure to always inform yourself from multiple sources (like the AddMusicK readme, RTFM). Note that this guide does not serve to teach music theory aside from the fundamentals. It also does not teach you how to port by ear.

What you'll need for this guide:
 - AddMusicK
 - SPC700 Player
 - PetiteMM
 - FIRcon
 - FL Studio or any other MIDI editing tool
 - C700
 - OpenMPT
 - Audacity
 - N64 Sound Tool (more on this later)
 - A calculator that can display in hexadecimal, like Windows Calculator
 - Your preferred text editor, like Sublime Text 2

Index:
 1. Basic Syntax
     - Music Theory
     - Notes and Octaves
     - Rests and Ties
     - Channels
     - Instruments, Volume, Panning, Global Volume and Tempo
     - The q command
     - Loops, Nested Loops and Intros
     - Vibrato and Pitch Bends
     -
     -
     -
 2. Creating a Port From a MIDI
 3. Instruments and Hex Commands
 4. Advanced Techniques
 5. Creating and Tuning Samples
 6. Formatting
 7. Sound Effects


1. Basic Syntax

To understand porting you have to at least understand the fundamentals of music theory. First we'll start with pitch. In most Western music pitch is divided into octaves, and those octaves are divided into 12 tones. This way, we can describe a note as having a tone in a certain octave. We categorize these 12 tones by using 7 tones that can either be neutral, sharp, or flat. Those tones are: A, B, C, D, E, F and G. Adding sharps would give you the full 12 tone range: A, A#, B, C, C#, D, D#, E, F, F#, G and G#. Now, you might notice that B# and E# are omitted! This is because B# and C, and E# and F are enharmonically equivalent, meaning they both produce the same pitch (in most cases). Looking at a piano makes this easier to visualize. Note that an octave starts at C.



Next is rhythm. We define rhythm in music by dividing a whole note into different lengths. The most common ones are: the whole note, the half note, the quarter note, the eighth note, the sixteenth note, the thirty-second note and the sixty-fourth note. Denoted by 1, 2, 4, 8, 16, 32 and 64 respectively. Note that these are all powers of two, but you can also divide by three, in which case you get: 1, 3, 6, 12, 24, 48 and 96. Having three of these notes in a row is called a triplet, because they can divide a regular length note into three parts. For example, three twenty-fourth notes would be 1/24 + 1/24 + 1/24 = 1/8.




You might notice that there are three grey lines in the background, dividing the whole note by four. This is because of something we call the time signature. In most Western music the time signature is 4/4, meaning that there are four beats of a fourth note (quarter note) in every measure. Once those four beats have played, a new measure starts. Conveniently, a whole note takes up four quarter notes, meaning that in 4/4 a whole note takes up the entire measure. There are many different types of time signatures, 3/4, 6/8, 5/4 and 7/8 to name a few. The tempo of a song is defined in beats per minute, or bpm. At 120bpm, a quarter note is half a second, because there are 120 beats/60 seconds.

Then there are rests and ties. Rests are when you don't want to play a note, but want silence instead. They use the same rhythmic notation as normal notes. Ties are when you want to glue two notes together. For example, a whole note doesn't divide easily into a combined quarter note and eighth note, so instead they can be tied together. When a tied note is half the length of the previous note you can use dotted notation. So a combined quarter note and eighth note can become a dotted quarter note.

Okay, so now that that's out of the way, let's move on to AddMusicK's syntax. AddMusicK uses something called Music Macro Language, or MML. For the most important command, the note, it uses the following notation:
Code
o4a4b8>c+8d8.<e-16d8

As you can see, the note is defined first, followed by its length. The o indicates the octave. The > indicates going up an octave, while < indicates going down an octave. Sharps and flats are indicated by + and -. A dot after the note length indicates a dotted note.

Rests and ties look like this:
Code
o4a4b8>c+8d8.<e-16d8r8
r4..r4^8^16r8

Where the r indicates a rest and the ^ indicates a tie. Note that the double dotted rest and the tied rest have the same length.

To indicate where a note should be played we have channels 0 to 7. It is defined with a # followed by the channel number.
Code
#amk 2

#0
o4a4b8>c+8d8.<e-16d8r8
r4..r4^8^16r8

#1
o5c+4d8e8f8.<g16f8r8
r4..r4^8^16r8

#2
r1
o4d32r32d32r32>d32r16.<a32r8^32a-32r16.g32r16.f8d16f16g16

You can also see at the top of this code block that there's a line with #amk 2. This isn't a channel, rather, AddMusicK uses this to differentiate between legacy ports like AddMusicM and AddMusic4.05. In pretty much all cases, this should be at the top of your text file.

We now have a valid text file that can be inserted! Try it out. Do you feel like a master porter yet?

Next we're going to initialize our channels with an instrument, volume and panning. We're also going to add the global volume and tempo.
Code
#amk 2

#0 w220 t41
[email protected]
o4a4b8>c+8d8.<e-16d8r8
r4..r4^8^16r8

#1
[email protected]
o5c+4d8e8f8.<g16f8r8
r4..r4^8^16r8

#2
[email protected]
r1
o4d32r32d32r32>d32r16.<a32r8^32a-32r16.g32r16.f8d16f16g16

The w value sets the global volume. Meaning this command, wherever it's placed, will change the song's global volume, affecting all channels. Its value can be set from 0 to 255. I recommend setting it from around 200 to 220, so that people can always customize the song loudness to their liking.
The t value sets the tempo, but this is not defined in beats per minute. Instead, it is defined as 0.4096*bpm. So a tempo of 100bpm is approximately t41.
Next we have the y value, which sets the channel's panning; how much the instrument is played in the left ear or the right ear. A value of y0 will give you a hard pan to the right, a value of y10 will be center, and a value of y20 will give you a hard pan to the left. It is also possible to enable the surround setting, but more on this later.
Then there's the v command for channel specific volume. Values range from 0 to 255. At w255, your channel will only start producing sound when your v value is above 34 (this will result in an spc volume of 0x01). At lower w values, the v value required to produce sound is higher.
Lastly we have the instrument command @. Its value can range from 0 to 18, 21 to 29, and 30+ for custom instruments. It's handy to have a list at hand of which instruments are what whenever you're using them. So save this to your computer.



You might notice that the percussion instruments, @21 to @29, are separate. This is because these instruments work differently from normal instruments. They have a preset pitch regardless of the note pitch you used and they need to be redefined before every note you place.

Personally, I never use these, because you can manipulate them much easier using custom instruments. More on this later.

Another important parameter is the q command. This command has a double function. It can specify where the note is cut off, and it can act as another volume parameter. Its value is defined in hexadecimal, which I'll explain right now.

Normally, we describe numbers in decimal notation. Counting from 0 to 9 and then adding another digit. This is based on powers of 10. The first digit from the right describes 100, the second describes 101, the third describes 102, and so on. These values are then added together.
Hexadecimal is based on powers of 16. Using the digits 0 to 9 for 0 to 9 and A to F for 10 to 15. Here, the first digit from the right describes 160, the second describes 161, the third describes 162, and so on. A value of 0x0A would be 10 in decimal, a value of 0x10 would be 16, A value of 0x80 would be 128. If you put Windows Calculator in programmer mode, you can switch between decimal and hexadecimal quite easily. You can read more on Wikipedia.

The first parameter of the q command indicates the note length. It can use the values 0 to 7. A value of 0 cuts the note off at 1/4 the full length and a value of 7 plays the note in full.
The second parameter indicates the volume. It can use the values 0 to F, where 0 will modify the volume to 0% and F will modify it to 100%. Here's a table that specifies all values.


Note: The percentage displayed here is based on the v value that would be required to get the same SPC volume with qxF. So v255q75 would be equivalent to v130q7F.

Code
#amk 2

#0 w220 t41
[email protected]
o4a4b8>c+8d8.<e-16d8r8
r4..r4^8^16r8

#1
[email protected]
o5c+4d8e8f8.<g16f8r8
r4..r4^8^16r8

#2
[email protected]
r1
q2Fo4d16d16q0F>d8<a8r16a-8g8q7Ff8d16f16g16

#3
y10v200
q7F@[email protected]q7A@29c8q0C@22c16q08@23c16q7F@[email protected]q7A@29c4
q7F@[email protected]q7A@29c8q0C@22c16q08@23c16q7F@[email protected]q7A@29c4

As you can see, we got rid of most of the rests in #2. We were also able to add some volume changes to our percussion and we shortened the hi-hats (@22 and @23).

You might wonder why you would need a secondary volume command. I'll demonstrate why with the loop command. Loops are defined with [] followed by the amount of times you want that section to loop and they can be labeled with (). Label loops can be used to repeat sections that are far apart from each other and you can even use it to repeat a section in a different channel.
Code
#amk 2

#0 w220 t41
[email protected]
o4a4b8>c+8d8.<e-16d8r8
r1^1

#1
[email protected]
o5c+4d8e8f8.<g16f8r8
r1^1

#2
[email protected]
r1
q2Fo4d16d16[q0F>d8<a8r16a-8g8q7Ff8d16f16g16]
q2Fo4c16c16*

#3
y10v200
(300)[[email protected]@[email protected]@[email protected]@[email protected]@29c4]3

#4
y10v120
r16
(300)3

As you can hear, we added an echo channel that still follows the same volume changes simply by lowering the v value in #4. We also did something in #2. We put brackets around the section that remains the same and we put a * the next time it is played. * acts as a label loop shorthand. It will play the loop that was last active as if it was properly labeled. This can make your text file look a bit cleaner, but there are no other benefits to using it over a normal label loop.

Note that label loops are defined from top to bottom. Meaning a label loop must be defined before it can be played back further down the text file, otherwise AddMusicK will throw you an error.

There are also so called superloops, these allow you to nest loops into one another. They are defined with [[]]. Make sure that they're spaced properly, otherwise AddMusicK will throw you an error.
Code
#amk 2

#0 w220 t41
[email protected]
o4a4b8>c+8d8.<e-16d8r8
/
r1^1^1^1

#1
[email protected]
o5c+4d8e8f8.<g16f8r8
/
r1^1^1^1

#2
[email protected]
r1
/
q2Fo4d16d16[q0F>d8<a8r16a-8g8q7Ff8d16f16g16]
q2Fo4c16c16*
q2Fo3b16b16*
q2Fo3b-16b-16*

#3
y10v200
(300)[[email protected]@[email protected]@[email protected]@[email protected]@29c4]
/
[[(300)
(301)[[email protected]@[email protected]@29c4]2]]2

#4
y10v120
r16
[email protected]@[email protected]@[email protected]@[email protected]@29c8.
/
^16
[[(300)
(301)2]]2

We also added the intro command / in all channels. This sets the loop point for each channel. Meaning that whatever comes before / will be played once, and everything that comes after will play in a loop. Note that on #4 I had to write out the (300) and cut off a 16th note at the end. This is because this channel starts with a r16, meaning the end of the measure cuts into the last note. This is to make sure all the / are aligned. You can try putting a (300) there instead, and removing the ^16 on the following line. When this loops, the delay will disappear.

Now what if you want to modulate the pitch of a note while it's playing? For that we have vibrato, which moves the pitch up and down repeatedly, and pitch bends, which bend the pitch of a note towards the next note. Vibrato is defined by p and can have two or three parameters. When it has two parameters, the first parameter sets the speed of the vibrato, with 1 being the slowest and 255 being the fastest. The second parameter sets the strength or amplitude of the vibrato, with 1 being the smallest amplitude, and 255 being the largest. Note that if you use a very large amplitude at high pitches, your pitch might overflow, which makes the pitch restart at the lowest possible point.

[SOON TO BE MORE]
Cool, I plan to learn how to port music and I think this tutorial will be of great help.

WIP