Banner
Views: 778,890,646
Time:
3 users online: Golden Yoshi, MrDeePay, WhiteYoshiEgg - Guests: 38 - Bots: 193 Users: 40,835 (1,681 active)
Latest: Blugar23
Tip: Remember to remove the original SMW events, both layer 2 and layer 1, when making a new overworld.Not logged in.
MVS's Ultimate Music Tutorial
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Old Tutorials - MVS's Ultimate Music Tutorial
Pages: « 1 2 »
marioVSshadow Proudly Presents:
MVS's Ultimate Music Tutorial!


Welcome to my ULTIMATE music tutorial. A tutorial that I will continuously add to until I am satisfied that it is complete. I will be teaching you how to port for HuFlungDu's Unofficial Romi's Addmusic 4.05... Long name. We generally refer to it as AM4 (Addmusic 4).

This tutorial will eventually go over basically everything. From start to finish. So this is kinda going to end up being one for everyone (well, I'm assuming you all have basic musical knowledge).

STOP! BEFORE YOU DO ANYTHING ELSE, MAKE SURE YOU KNOW HOW TO USE AM4!

My tutorial for AM4 can be found here. If you have difficulty understanding this, or if you want to double check something, Slash Man also has a tutorial for AM4.

If you read beyond this point and still can't insert music with AM4, you may as well light a fire and throw some clocks in it in a feeble attempt to burn even more time.

Part 1: Basic Porting

Right, now that you know how to insert OTHER people's music, it's time to make and insert your own music.

What you will need

- An SMW ROM expanded to at least 2MB (if you've edited it in any way in Lunar Magic, it should already have been expanded)
- HuFlungDu's Unofficial Romi's Addmusic 4.05
- A command prompt such as cmd.exe (usually found in your system32 folder (for Windows users) otherwise Google it)
- Tinymm
- Kipernal's MML Editing Tool
- SNES SPC700 PLAYER or any other SPC player. This tutorial assumes you use this one
- A .zip file manager. My personal preference is WinRAR
- A midi editor of your choice. My personal preference is FL Studio. This tutorial will assume you use it.

Note: If I haven't linked something here, it's not in the SMWC tools section. I advise you Google it. It's probably best not to link your findings here...

Getting a midi

So you have everything you want besides the song. The most common way of porting is from midis (you can type out the music for direct input by hand if you really want to but for now, stick to this method).

If this is your first port, I'd advise going with something simple. Songs from 8-bit systems are usually a good place to start. I know how tempting CD quality music is but just trust me for now.

There are many sources for midis. You can look on sites such as VG Music and find one that somebody has made, you can rip midis from certain games and gaming systems, or you can arrange one yourself. Whichever you choose to do, just remember that you're going to be porting it, so think within reasonable targets.

Now that you've got your midi, it's time to move on to step 2!

Fixing your midi

Addmusic's code isn't very user friendly when you're first starting out so it's a good idea to fix it up as much as you can before it gets converted into this code.

Open up your midi editor and open the midi inside it. If you're using FL Studio, the screenshots I show will probably look very similar to the contents of your screen.

First off, you need to know the limitations of the SNES sound engine and be able to adjust your midi accordingly. Firstly, the SNES can only handle 8 channels, so it is wise to cut down on anything you don't need (such as double channels).





Next is that each channel can only play one note at a time, so chording has to be split over multiple channels if it is desired.





The last limitation of the SNES's sound engine you'll need to know is that the instruments can't go higher than certain notes or lower than certain others. These are refered to as octave limits. In FL Studio's piano roll screen, octaves are displayed at the side of the window on the keyboard (this applies for all but percussive piano rolls but you generally don't need to worry about them). The instrumental limitations are generally within the 6th octave and 1st octave (FL Studio displays a 0th octave which is basically a no-mans land), as a general rule of thumb, you shouldn't venture too far into these octaves.



A few tips for fixing your midis:

SPC channels can change most variables part way through so you may be able to have one channel share the barings of multiple channels if you can avoid getting the notes to overlap. A lot of SNES games do this, the 'src' number in SPC700 Player's four channel information screens represents the instrument (or sample) number. See here how the intruments change to make it sound like there's more than 8 channels.

Your song only needs to play through once. The SNES will make it so the music loops for you.

If you're adjusting the octaves of a channel, make sure to adjust the whole channel, not just the bit that goes over the octave limitation, or your music will sound funky.

Right, once you feel you've fixed up your midi a good amount, export it as a new midi file. You're getting very close to the bit you've been waiting for!

Setting up the txt

Drag and drop your midi over tinymm. You'll notice a window briefly open and close. A new file should have appeared. This is an mml file. Boot up the MML Editing Tool and load the mml file tinymm just produced in it.

Once it's open, click 'Tools' and click 'Fix MML file'. Several pop-up windows will appear. You'll be asked to input volumes for the v and w commands. You can leave these at 220. You'll also be asked to input the song's tempo in BPM. You can find out the tempo from your midi editor. You'll also be given the option of flipping the octaves. You don't want to flip them (the reason this option exists is because the old tinymm inverted the octaves. This is fixed in the newer one).

Now your code is readable by Addmusic BUT you're not ready to insert it. Firstly, save a copy of it as a txt. You don't want to overwrite the original mml, just in case you need to start again for whatever reason.

I shall briefly run through what is probably visible to you at this stage along with what it all means:

wXXX - Where XXX is a number between 0 and 255. This is the universal volume of the song defined in decimal, 255 being the loudest.

tXX - XX being a number usually between 1 and 99. This is the tempo defined in decimal in a format Addmusic understands. The MML Editing Tool's tempo conversion isn't perfect so it's best to check this one. The equivelent tempo is the tempo in BPM multiplied by 0.4 (in decimal) rounded to the nearest whole number. For whatever reason, the editor has a habit of being off by a couple.

#X - Where X is a number between 0 and 7 (defined in decimal). This represents the channel designation where #0 is channel 1, #1 is channel 2, and so on until #7 as channel 8. You can define which channel you want each part to use. #4, #6, and #7 are also used by sound effects so you should think carefully about where you want each channel to go.

qXX - Where XX is a one byte figure defined in hex. This defines how much of the note gets played and is by default set as q7f (which plays the whole note).

vXXX - Where XXX is a number between 0 and 255. This is the individual volume of the channel defined in decimal, 255 being the loudest.

c, d, e, f, g, a, b - Your notes within an octave, equivelent to their place on a keyboard.

+ - Placed after a note to make it a sharp note (i.e. c+ would be a C sharp). It will not appear in the converted MML, but '-' can be placed after a note to make it flat in the same way '+' works.

r - A special note which is actually a rest and will play nothing. Operates in the same way as regular notes.

1, 2, 4, 8, 16, 32, etc - Placed after a note and sharp (if applicable) to define note length. A '1' will make the note stretch over 4 beats, a '2' over 2 beats, a '4' over 1 beat, and so on. Think fractions. Defined in decimal.

^ - Placed after a complete note to extend it for whatever length variable is present after the command. For example c1^1 would make the note go on for 8 beats. This is called a tie.

oX - Where X is a number preferably between 1 and 6. This defines octaves. So for example, o3 would be the third octave and o5 would be the fifth octave. Defined in decimal. Note, it's wise to use this command to define octaves at the start of each channel if it's not already defined.

> - Changes notation to the next octave up. So 'o4g1>g1' would be equivelent to 'o4g1o5g1'.

< - Changes notation to the next octave up. So 'o4g1<g1' would be equivelent to 'o4g1o3g1'.

; - Makes Addmusic disregard anything on the rest of the line. Ideal for writing comments on channels.

@XX - XX defining the instrument used. A table of instruments can be found below.

------------------------------
Flute - @0
Violin - @1
Music box - @2
Marimba - @3
Cello - @4
Acoustic steel guitar - @5
Trumpet - @6
Steel drums - @7
Pick bass - @8
Piano - @9
Light snare drum - @10
Softer violin - @11
Bongos - @12
Electric piano - @13
Slap bass - @14
Orchestra hit - @15
Softer electric piano - @16
Distortion guitar - @17
Violin - @18
Kick drum - @21
Closed hi-hat - @22
Maracas - @23
Low wood block - @24
High wood block - @25
Gun shot - @26
Medium bass drum - @27
Soft bass drum - @28
Heavy snare drum - @29
------------------------------

NOTE: We will be introduced to more commands later on!

Knowing all of these is not entirely necessary for porting but is extremely helpful. You'll usually begin to memorise them as you go along. The editor has a sample player if you ever forget the @ command.

The instruments work from a set number of samples. Knowing this isn't necessary if you don't intend to start using custom samples but as this is the ULTIMATE music tutorial, it's worth noting:

------------------------------
00 - @0
01 - @1, @11, @18
02 - @2
03 - @3
04 - @4
05 - @8
06 - @22, @23
07 - @5
08 - @6
09 - @7
0A - @9
0B - @10, @26, @27, @28
0C - @13, @16
0D - @14
0E - @24, @25, @29
0F - @21
10 - @12
11 - @17
12 - @15
------------------------------

Using this guide, you should be able to get the jist of which channel is which and be able to adjust variables accordingly. You can add variables such as different t, @, v, and so on, part way through a channel if you need to. Universal commands such as t and w don't need to be defined in the same spot on every channel. Only once on one channel.

Next thing you'll need to do is set the ending of your song. The song will repeat after the shortest channel has ended, to fix this problem, simply add rests (r) to your shorter channels until they end when the longest one ends. You CAN go past where the longest channel ends with rests and it'll still loop fine as the longest channel will be the shortest channel in this scenario.

Most porters place drums on an SFX channel (such as #4), however, if a sound plays on this channel, the instrument designation gets messed up. Thankfully, the editor has an easy fix for this. Open up a new MML Editing Tool window and copy your percussive channel to there. In tools, there is an option called drum fixer, select this, and it'll ask you designate an instrumental number for each note. After you've done that, every single note will have a defined instrument number. Paste the fixed drums back into your port and they shouldn't break now.

One last thing before your first test. AM4 songs require special headers. Place one of these at the very top of the song:

For level music:

$ED $80 $6D $2B $ED $80 $7D $00 $F0

For overworld/submap music:

$ED $80 $6D $68 $ED $80 $7D $00 $F0

Note, only place one.

Now that you've done that, it's time to insert the music and test it! After testing the music, odds are you'll notice a few things you'll want to adjust. I guess it's time to introduce a few more commands:

{ and } - These are triplet brackets. Surrounding notes with these will have them played as triplets instead of what they're being played as by default. As of yet, tinymm is unable to convert triplets. You can also use notational lengths such as 3, 6, 9, and so on if you prefer.

/ - Placing this in a channel will set it so that channel loops from the point you place it. NOTE, for whatever reason, this is an individual channel command, not a universal command, meaning you'll have to define it on each channel.

Continue making adjustments and testing till you're satisfied with how your song's sounding. Now there's one last step before the big finale.

The finishing touches

As you can probably imagine, music can eat up quite a lot of space, thankfully there's an easy fix to compress the data called 'data looping'. Note, if you're planning on submitting to your port to SMWC, doing some data looping is compulsory.

The way it works is simple. You look for patterns in the music and basically make it so it repeats...

I've taken this example out of a song of mine.

>c4c16c16c16c16r4<a+4
>c4c16c16c16c16r4<a+4
>c4c16c16c16c16r4<a+4

The pattern here is very obvious.

We have '>c4c16c16c16c16r4<a+4' repeating 3 times

To data loop this, we'd take one instance of '>c4c16c16c16c16r4<a+4', surround it with [these brackets] and define, in decimal, how many times we want it to loop (in this case 3 times). So this would turn into:

[>c4c16c16c16c16r4<a+4]3

Now let's mix it up a little bit. I'll introduce you to label looping! Take this instance:

>c4c16c16c16c16r4<a+4
c2<a+8>c8d+8f8
>c4c16c16c16c16r4<a+4
c2<a+8>c8d+8f8
>c4c16c16c16c16r4<a+4
>c4c16c16c16c16r4<a+4

As you can see, we have repeating instances of '>c4c16c16c16c16r4<a+4' again, however this time we can't loop them all together. Label looping allows you to [bracket] the first instance of '>c4c16c16c16c16r4<a+4' and define a label for all instances of '>c4c16c16c16c16r4<a+4' over the channel. The solution would be this:

(1)[>c4c16c16c16c16r4<a+4]
c2<a+8>c8d+8f8
(1)
c2<a+8>c8d+8f8
(1)2

I arrived at this solution by [bracketing] the first instance. You see before the [bracket], I defined a (1). This is the label I'm using for the contents of that bracket, so every time I put (1), it plays '>c4c16c16c16c16r4<a+4'. You may have noticed in the last part. Instead of putting '(1)(1)' I put '(1)2'. You can loop labels much like you loop normal data however you do not need to surround it with [brackets]. If you want another label, simply go to the next number up in decimal (so the next label would be (2) and I'd continue going up every time I wanted a new one). I could loop the example even further with another label like this:

(1)[>c4c16c16c16c16r4<a+4]
(2)[c2<a+8>c8d+8f8]
(1)
(2)
(1)2

Kipernal's tool DOES have an automatic label looper, but personally, I don't trust it further than I can throw it. I'd advise doing all your looping manually.

The SPC

After you've looped it to a point where you're happy, test it one last time. If it's all in working order, you're ready to rip an SPC of your song. If by some chance you don't know what it is, this is basically a rip of the song which can be played in your SPC player (to sample the music before you insert it). To rip one, simply open your rom in ZSNES, enter the level where your music plays, and just before the song starts, hit F1 and save an SPC. This should've created an SPC in the directory of your rom. This is required if you intend to submit your song to SMWC.

If you're going to submit your song to SMWC, make sure you're satisfied with everything then put your completed TXT and SPC into a ZIP file.

Congratulations! You've just learned the basics of music porting. I advise you practice with what you've got before you try to port anything seriously.

Part 2: Echo

Coming soon

Part 3: ADSR

Coming soon

Part 4: Sampling with $E5

Coming soon

Part 5: Other hex commands

Coming soon
So far so good MVS. #w{=D}

I will definitely use it some time. #w{:>}

--------------------
By the Way: My English isn't really the best, but I'll try to express myself as clearly as possible. ^^"
You might say something about the = command, it's pretty handy when you have to do stuff like this:
Quote
a2^4^16^64^64 $DD $00 $03 $45

and change it to:
Quote
a=159^64$DD $00 $03 $45
Man, you learned me how to port!#w{xD}

Hope I will see soon ADSR commands tutorial, echo and other stuff...I can't wait to see them and learn more about music porting!
When I stop being a lazy ass, I'll get right on it.
SMWC's official dentist since 2011.

YouTube - Twitter - Twitch
I'm just putting everyone on notice that over the next week or so I'll be updating this tutorial. After the most recent C3, a bunch of new and updated tools were released for music porters. I feel that it'd be beneficial to incorporate these tools into my tutorial. The issue is I haven't had much of a fiddle with all these new tools yet. I'll be having more of a play with them at some point so I know exactly what I'm talking about when I write about it. It's going to be a busy week so your patience is appreciated.
SMWC's official dentist since 2011.

YouTube - Twitter - Twitch
Nice to hear. This has been my reference of choice for music stuff since I got back into hacking.

A quick question regarding music channels and sound effects... #4, #6, and #7 are used by sound effects... But what happens if you use those channels in a song port anyways? Will a sound effect not play if that channel is being used by the song or will it just stop the song from playing notes on that channel while the sound effect is active or what? In general, when is it acceptable to use one of those channels and when isn't it?

--------------------
I have a hack thread - Link (Now with a demo!)
Also a music thread - Link

C3 Projects
2013: Modern Spiny Pack
2012: MGSS v0.1
Spring 2010: SMB2 Autobomb Sprite
Originally posted by NamelessProtagonist
Nice to hear. This has been my reference of choice for music stuff since I got back into hacking.

A quick question regarding music channels and sound effects... #4, #6, and #7 are used by sound effects... But what happens if you use those channels in a song port anyways? Will a sound effect not play if that channel is being used by the song or will it just stop the song from playing notes on that channel while the sound effect is active or what? In general, when is it acceptable to use one of those channels and when isn't it?

The song's channels cut off whenever an SFX plays. It is acceptable if whatever being cutoff isn't anything noticeably major, like the main tune (melody) or a lead percussion. There isn't a definitive line to draw, but try to be reasonable when deciding which parts of the song go to what channel.
I see. So it's more or less based on the importance of individual notes then, right?

Another question, which sound effects use which channels? I would guess it's based on the sound effect port, but it would be nice to know the specifics.

--------------------
I have a hack thread - Link (Now with a demo!)
Also a music thread - Link

C3 Projects
2013: Modern Spiny Pack
2012: MGSS v0.1
Spring 2010: SMB2 Autobomb Sprite
Originally posted by NamelessProtagonist
I see. So it's more or less based on the importance of individual notes then, right?

Exactly.

Originally posted by NamelessProtagonist
Another question, which sound effects use which channels? I would guess it's based on the sound effect port, but it would be nice to know the specifics.

Channel #4: Enemies and sprite SFXs, such as koopa kicks, stomps, running chucks, bullet bills, yoshi coins etc.

Channel #6: Coins, Correct/Wrong SFX, Item Box (I think), spin jump.

Channel #7: Grinder and Mario's jumps.


Channel #7 is the unsafest channel of them all. What I consider the order you should use the channels, from safest to unsafest, is: #6, #4, #7.
It's also worth noting that if you use custom ADSR on a sound effect channel, then the sound effects will mess up the music and vice versa. Adding tuning also causes the sound effects to be tuned differently. You can fix the ADSR bug, though, as seen here.

(And I agree with MaxodeX on channel order. Channel 7 is dang near useless for anything but an echo channel or continuously repeated non-important notes. That's why, for my hack, I'm planning on disabling the jump sound effect and moving the Grinder one to a different channel so that I can have that channel free.)
Man, I hope you will update this tut. soon...I can't wait to learn new stuff from you!#w{=P}
Originally posted by Silver
Man, I hope you will update this tut. soon...I can't wait to learn new stuff from you!#w{=P}

Yeah I'm pretty lazy aren't I.

I'll put my cards out on the table and say I really don't have any plans to update it any time soon. College will be resuming shortly and it's a new course so it'll probably eat up a bunch of time.

It's basically a case of permanent hiatus until further notice. So watch this space I guess.
SMWC's official dentist since 2011.

YouTube - Twitter - Twitch
I'm afraid I'm going to need a video example of this part:
"Next thing you'll need to do is set the ending of your song. The song will repeat after the shortest channel has ended, to fix this problem, simply add rests (r) to your shorter channels until they end when the longest one ends. You CAN go past where the longest channel ends with rests and it'll still loop fine as the longest channel will be the shortest channel in this scenario."
I don't get it
A song will end if a channel ends. An example:
Code
#0
a2^4c8

#1
e8f4^16d4f3b2

Chennal #1 won't be played complet. To fix it:

Code
#0
a2^4c8
r1^4

#1
e8f4^16d4f8b2


(I hope I'm with the reset right)
And if you aren't shure:
Code
#0
a2^4c8
[r1]99

#1
e8f4^16d4f8b2


--------------------
Okay, my layout looks ugly.
I happen to have a little problem the BPM tempo for my MIDI is 1017.00. So in the MML editing tool it says "Invalid tempo" How do I fix this?
BPM in Midi = 1017.00 = Tempo in SNES = 424
BTW: If you want to convert it just look into S.N.N.'s music porting tutorial:
Originally posted by S.N.N.
Most MIDI editors display the MIDI's tempo near the top of the screen. This tempo is in BPM, or Beats Per Minute, and is not the same as SMW's tempo format. To convert it, cut the BPM in half, then mutiply it by 5/6. A BPM of 200 would be cut in half to become 100, then multiplied by 5/6 to become 83.3, which rounds to 83.

And the tempo Maximum of tempo is 255 99 (which is FF 63 in hex).

Edit: Tempo number fixed.

--------------------
Okay, my layout looks ugly.
Are you going to update this tutorial? I'm eagerly awaiting for it to be finished to learn more!
Originally posted by MVS

Next is that each channel can only play one note at a time, so chording has to be split over multiple channels if it is desired.


I'm stuck on this part and have absolutely no idea how to do this. Can you please explain it with more detail?

It feels like this part was rushed or something. What exactly should I do on FL studio to achieve this?
So, if one channel plays two notes at the same time, it's not going to work if you want to port a song to smw.

So, for example we have c-major chord, and we have to put it into separate channels.

channel 1#
plays c note from octave 5

channel 2#
plays e note from same octave

channel 3#
plays g note from same octave again.
Pages: « 1 2 »
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Old Tutorials - MVS's Ultimate Music Tutorial

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2019 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 7

Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Talkhaus
  • SMBX Community
  • GTx0
  • Super Luigi Bros
  • ROMhacking.net
  • MFGG
  • Gaming Reinvented