Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,415,735
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-16-24 08:50 PM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest

Main - ROM Hacking - Collabo-presto! #1: Music notation and conversion New thread | New reply


RomManic
Posted on 01-13-09 10:50 PM (rev. 6 of 01-18-09 07:58 PM) Link | Quote | ID: 98624


Spiny
I've had enough of your garbage. Get out.
Level: 53

Posts: 405/578
EXP: 1100027
Next: 57092

Since: 02-19-07

Last post: 5370 days
Last view: 4291 days
I feel this is something we can do to make this community a little bit more active. So here I am, putting an effort rather than just saying it needs to be done.

Title: Music notation and conversion

Introduction: In response to the topic linked at the bottom of this thread, we have a problem on our hands. We need to figure out musical notation, and how to properly convert music, note for note, to a sound format playable on a console. So to figure this out, we need to establish the basic principles of music, and the basic functionality of a console's sound format. For the purpose of this, I'll try to generalize where I can.

Music Notation: Musical notation is based on frequency of a sound vibrating through the air, interpreted by the ear drums. In the physics of sound, it is all composed in a structure, and for the purpose of this lesson, let's imagine that it's all basically made of 12 different blocks:

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

The most common grouping of notes on these building blocks of music is the Major scale, which means 7 of the blocks are given "Major" note importance. While they're all equally important, the Major notes are the main components of the scale, while the rest of the blocks are reserved for the Flats and Sharps of the scale. In this scale:

[1] [ ] [2] [ ] [3] [4] [ ] [5] [ ] [6] [ ] [7]

Every time you progress from block to block, it is referred to in "Steps". From block 1 to block 2 would be a half step, and so on and so forth. More commonly called "Intervals", names of intervals are divided in 2 groups: Majors and Perfects.

Majors - This group consists of blocks 2, 3, 6, and 7.
Perfects - This group consists of blocks 1, 4, 5, and 8.

The reason a perfect also consists of the 8th block is because the 8th block is the full octave, or rather it is double or half of the original note. From A, the B note is double the frequency of A, and C is half the frequency of D, and so on.

Augmenting and diminishing notes is just the sign that a note has undergone "Flattening" or "Sharpening". For example, from one of the Major notes (2, 3, 6, 7) being "Flattened", you get the Minor note to that block. From "Flattening" that Minor note, you get the Diminished note. But this is 100% bulletproof because we know which blocks are Major blocks, based on the scale of music we are using (In this case, the Major scale). To "Flatten" a perfect, you get a diminished note immediately.

To "Sharpen" either a Major or a Perfect you get an Augmented note immediately, no "Ifs", "Ands", or "Buts" about it. But just because it's important to know, in this scale, you can jump from block to block and call that transition any one of the following:

1 Block: Unison
2 Blocks: Minor 2nd
3 Blocks: Major 2nd
4 Blocks: Minor 3rd
5 Blocks: Major 3rd
6 Blocks: Perfect 4th
7 Blocks: Diminished 5th
8 Blocks: Perfect 5th
9 Blocks: Minor 6th
10 Blocks: Major 6th
11 Blocks: Minor 7th
12 Blocks: Major 7th

So WHY is this scale called the Major scale?

Block 1: Unison
Block 3: Major 2nd
Block 5: Major 3rd
Block 6: Perfect 4th
Block 8: Perfect 5th
Block 10: Major 6th
Block 12: Major 7th

And because of this:

Block 1 to Block 3: Major 2nd (1 Whole Step)
Block 3 to Block 5: Major 2nd (1 Whole Step)
Block 5 to Block 6: Minor 2nd (1 Half Step)
Block 6 to Block 8: Major 2nd (1 Whole Step)
Block 8 to Block 10: Major 2nd (1 Whole Step)
Block 10 to Block 12: Major 2nd (1 Whole Step)

Always remember that even if you arrange notes in a scale differently, they're always the same sonically. You could have an infinite group of blocks extending in both directions, but the difference lies in the theory and this study of intervals, now finished, shall help us in understanding how to rough out our music in Hex.

Music Programming: Essentially there are 2 ways to programming sound for a console:

1) Get the program with the compiler for said music processor,
2) Do it in the final assembly code provided for you.

Since 2 is your most likely option, one must deduce how each different set of hardware processes and interprets the Hex data into instructions, and then to sound. The basic principle of this is based on pure frequency and wave shape. On the NES, they had 4 different sets of preset wave shapes (Not sure but I think it was 2 triangle, 1 square, and a free form channel) with limited functionality. On the SNES, there is one universal form operating at much higher efficiency but still within certain limitations. I don't know what they are, but to but the process to a bare minimum you have to program the music to the functionality of the processor.

Basically in a sequence of bits (You know what bits are, and thus what a sequence of them look like) there must be certain values to each bit. If, say the first 8 bits determine the frequency of the sound you want to play, those first 8 bits MUST contain the data for the frequency. And the list AND the process go on. There are numerous documents on the formats of many sound systems, but remember that LOGIC dictates EVERYTHING in these systems. If they use a certain term, you're gonna have to wrap your head around which ones they use and why to fully grasp what they talk about when they describe the formats.

Conclusion: I hope we get more people throwing their 2 cents in and doing this multiple times for multiple topics.

Topic in reference to: Struzzdog's Thread

Extra Links:
http://www.guitargrimoire.com/
http://www.musictheory.net/
http://emureview.ztnet.com/developerscorner/SoundCPU/spc.htm

There's lots of others, but those should get you started.

messiaen
Posted on 01-13-09 11:48 PM (rev. 2 of 01-13-09 11:54 PM) Link | Quote | ID: 98625


Cheep-cheep
Level: 32

Posts: 109/193
EXP: 204282
Next: 2160

Since: 05-26-08
From: Porto Alegre, Brazil

Last post: 4433 days
Last view: 4761 days
I should add my two cents as my primary focus for the past two months was music hacking. I found the block explication for intervals a bit confusing, but then I'm too used with tradicional terminology.

I guess what RomManic was trying to explain is that for most simpler tracked music formats it all breaks to the semitone as the smallest pitch unit (except for bends, vibrato or ocasional effects that involve subtle microtonal pitch inflections).

Thinking of each possible semitone as a distinct pitch-class that repeats itself after 12, you can set an arbitrarly representation of pitch using integers:

If we want 0 to be C (as most formats do), 1 = C#, 2 = D and so on, until it starts repeating itself after 11. Modulus is the arithimetical operation that will give you the pitch class of any value:

24 % 12 = 0 = C <-- % is modulus in standard 'C' programming syntax.

So that's the most common representation of pitch you'll find in a music format. Now for the duration of a specific note, there's two ways I can think to represent it.

- As sucessive divisions of a note value. In this case, 1, 2, 4, 8 is actually 1/1, 1/2, 1/4, 1/8 and so on. If we call 1 a whole note, 2 is a half note, 4 a quarter note and etc.

- As integers representing the actual duration of the note. In this case, 1 is the shortest note, 2 is two times it, 4 four times and so on.

All of this, as RomManic hinted, could be also applied to bits instead of bytes.

MML is a very simple format you may want to look at if you want to write a music importer program for any format. It took me a few days to get a working importer for the Mario 64 format using Addmusic's MML parser (but then I know the format very well), so I defintely recommend for an easy and quick way to build a music converter.

As for locating music data, corruption is your friend. Fill an area with the same value, discover what pitch is that and then work from there. Relative searching is also very useful, say you have a sequence of notes that goes like this:

C D E F G

Let's represent this as "00 02 04 05 07". Now try inserting wildcard bytes between each of these values: "00 [wild] 02 [wild] 04 [wild] 05 [wild] 07". Found nothing? Use two wilds instead of one. Found nothing? Try another wildcard byte or add +12 to the pitch sequence in order to look for it in another octave. If you are still unsucessfull, you can begin to wonder if the game doesn't use bits to store pitchs or if 0 isn't actually pitch-class C but something else (most likely A).

Edit: This actually gives me ideas. It would be nice to have some program that tries to find pitch sequences in any ROM using relative searching and trying different formats/representations. Could be pretty useful.

RomManic
Posted on 01-13-09 11:57 PM Link | Quote | ID: 98626


Spiny
I've had enough of your garbage. Get out.
Level: 53

Posts: 406/578
EXP: 1100027
Next: 57092

Since: 02-19-07

Last post: 5370 days
Last view: 4291 days
Applause! And yes, Semitones are the same thing as a Half Step. I'm actually kinda surprised someone actually opted-in on this...Smiles all 'round, then!

Struzzdog
Posted on 01-14-09 12:59 AM Link | Quote | ID: 98630


Micro-Goomba
Banned indefinitely for editspam and unwanted soliciting (read: HOLY SHIT CREEPY STALKER)
Level: 9

Posts: 9/10
EXP: 2361
Next: 801

Since: 01-07-09

Last post: 5570 days
Last view: 4211 days
if it's possible can we get a repost of this and just have it say



40= C
41= C#
42= D

etc.........etc...... hex number to notation

RomManic
Posted on 01-14-09 01:31 AM Link | Quote | ID: 98632


Spiny
I've had enough of your garbage. Get out.
Level: 53

Posts: 407/578
EXP: 1100027
Next: 57092

Since: 02-19-07

Last post: 5370 days
Last view: 4291 days
That's actually what messiaen said. Just a little more complex. I'm sure, though, that in the actual modification of your songs all of this should come in handy.

Sukasa
Posted on 01-14-09 08:28 PM Link | Quote | ID: 98660


Red Birdo
Level: 92

Posts: 1427/2112
EXP: 7683490
Next: 73447

Since: 02-19-07

Last post: 4438 days
Last view: 3210 days
One thing I note is that Gau's SPC700 document makes no reference at all (from what I can see) to how the sample table (sample start, loop start addresses) is constructed- and the only reference to it is the High-byte-of-address register Are there any good documents on it besides possibly the SNES dev manuals form Nintendo?

MathOnNapkins
Posted on 01-14-09 10:49 PM Link | Quote | ID: 98674


Super Koopa
Level: 62

Posts: 596/842
EXP: 1934030
Next: 50656

Since: 02-19-07
From: durff

Last post: 4478 days
Last view: 4002 days
*whistles*

http://www.romhacking.net/docs/197/
http://www.romhacking.net/docs/191/

____________________
Zelda Hacking Forum
hobbies: delectatio morosa

messiaen
Posted on 01-17-09 01:52 PM Link | Quote | ID: 98890


Cheep-cheep
Level: 32

Posts: 111/193
EXP: 204282
Next: 2160

Since: 05-26-08
From: Porto Alegre, Brazil

Last post: 4433 days
Last view: 4761 days
Posted by RomManic

In general, as a final finisher, I'd like to put it this way:





That must have been edited from the first post, but it has to be corrected. The lowest note is actually 'C', not 'A', and all flats should be replaced by sharps.

RomManic
Posted on 01-18-09 05:24 AM Link | Quote | ID: 98953


Spiny
I've had enough of your garbage. Get out.
Level: 53

Posts: 411/578
EXP: 1100027
Next: 57092

Since: 02-19-07

Last post: 5370 days
Last view: 4291 days
I suppose that is correct, but in any case I don't have the original. For the sake of simplicity, I'm just going to remove it and type out basically what it implies (And incorporate your input along with everyone elses into the original post).

Thanks for pointing that out though

Main - ROM Hacking - Collabo-presto! #1: Music notation and conversion New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.023 seconds. (347KB of memory used)
MySQL - queries: 77, rows: 105/106, time: 0.017 seconds.