Atrius: I'm trying to fix the site, but it might take a while.

It seems the SQL database had grown larger than our hosting company allows.
I've cleaned out all of the unnecessary log data to get it down to an
acceptable size, but haven't received a response as to why normal
functionality hasn't been restored yet.


 Charon's New and Improved Music Hacking Tutorials
Golden Sun Hacking Community
July 19, 2018, 09:54:30 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
  Home   Forum   DC Wiki Help Search Calendar Downloads Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: Charon's New and Improved Music Hacking Tutorials  (Read 17062 times)
0 Members and 1 Guest are viewing this topic.
Salanewt
His Sexiness
Mercury Clan

Oh yeah, baby!

Prodigy
*

Coins: 32
Offline Offline

I am: A part of the organization of Cool Cats, but more of a dog person in reality.
Emblems: Have a nice day.
Posts: 4566

« Reply #15 on: July 07, 2011, 06:42:31 PM »

Cool, thanks for all of your help! Just to make sure, the song's header goes right before the actual tracks start, right?

Never mind, I misread the guide. Thanks for all of your help!
« Last Edit: July 07, 2011, 06:45:10 PM by Salanewt » Logged

Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?
View Profile WWW
Charon
On Probation
Veteran Member
*

Coins: 11
Offline Offline

Emblems: GBA Music Expert
Clan Position: Trickster Goddess of Luna
Posts: 1758

« Reply #16 on: July 07, 2011, 06:46:46 PM »

If you're curious about header structure, its just

[# of tracks] 00 [flag] [flag]
[pointer to instruments (which is 0x1C3714 in TLA)]
[track 1 pointer]
[track 2 pointer]
...

[track 16 pointer]

It's usually after the last track in a song, and its always located at a location ending at 0, 4, 8, or C. Also, I have no idea what the flags do, I think they are really only used during certain SFX/fanfares. This means that a header will take up at least 12 bytes, and 4 extra bytes for each extra track.
« Last Edit: July 07, 2011, 06:48:38 PM by Charon the Ferryman » Logged
View Profile
Salanewt
His Sexiness
Mercury Clan

Oh yeah, baby!

Prodigy
*

Coins: 32
Offline Offline

I am: A part of the organization of Cool Cats, but more of a dog person in reality.
Emblems: Have a nice day.
Posts: 4566

« Reply #17 on: July 07, 2011, 07:03:29 PM »

Ah, so that explains why Sappy works until I try playing that one song. Excellent, thanks for clarifying that!

And... I just messed up the track pointers, so I shall go and fix them.
Logged

Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?
View Profile WWW

New User


Coins: 0
Offline Offline

Posts: 1

« Reply #18 on: March 07, 2012, 11:20:57 PM »

So I've been diggin a bit and trying to figure what is the correct order of loading the music from rom, my goal is to play pokemon fire red music from ROM.

So first there is a Music Table.
4Bytes, Song Header Pointer ?
4Bytes, Unknown

Song Headers contain number of tracks in songs, then two pointers: VoiceGroups and Tracks.
Struct:
1Byte, Number of tracks - range from 0x00 to 0x0F
1Byte, 00
1Byte, Flag
1Byte, Flag
4Bytes, Pointer to VoiceGroups
LoopStart for < Number of Tracks >
4Bytes, Track Pointer
LoopEnd

VoiceGroups ( Up to 128 voices )
Struct:
4Bytes, Voice Type
4Bytes, WAV Sample Pointer
4Bytes, Unknown

Tracks contain track data and are based on argument/commands, they start with BC 00 end with B1.

So order of loading would be
Music Table -> Song Header -> ( VoiceGroups -> VoiceSamples ) + Tracks

Also a question, how exacly loading of tracks works? Since there is a loop in song header that can contain few tracks.
Does it play like Track1, Track2, Track3, Track4 [...] ? But then how jump commands inside tracks itself behave with few track pointers?
Or maybe it's the fact that the Tracks itself are programmed to jump between Tracks inside the track data.
Logged
View Profile
Atrius
Programmer Extraordinaire
Web Host

Fear my blades

Veteran Member
*

Coins: 1
Offline Offline

Gender: Male
Emblems: Website Founder
Clan Position: Creation God of Sol
Posts: 1758

« Reply #19 on: March 09, 2012, 10:52:17 AM »

All of the tracks are played simultaneously.  Basically each one is the sheet music that an individual member of a band would play during a song.  Also, tracks don't necessarily have to start with BC 00

Quote
So first there is a Music Table.
4Bytes, Song Header Pointer ?
4Bytes, Unknown
The last 4 bytes of each entry in the music table have to do with how the game prioritizes, and categorizes audio.

Quote
VoiceGroups ( Up to 128 voices )
Struct:
4Bytes, Voice Type
4Bytes, WAV Sample Pointer
4Bytes, Unknown
The last 4 bytes of a voice group are the ADSR envelope settings (Read second post in this topic)


As for the question on load order, you should know the GBA doesn't really "load" any of the raw audio data into RAM, it just streams it directly from the ROM as it plays.  As for the order it looks at things:

Music Table -> Song Header -> Tracks -> Voices as tracks ask for them (0xBD command in the track)
Logged

I'm shaking my head in general disapproval of everything
View Profile WWW
Charon
On Probation
Veteran Member
*

Coins: 11
Offline Offline

Emblems: GBA Music Expert
Clan Position: Trickster Goddess of Luna
Posts: 1758

« Reply #20 on: March 12, 2012, 03:32:49 PM »

So I've been diggin a bit and trying to figure what is the correct order of loading the music from rom, my goal is to play pokemon fire red music from ROM.
For this all you would really need to know is the pointer to the song table. I can't recall what it is atm but I could look it up later.

Quote
Does it play like Track1, Track2, Track3, Track4 [...] ? But then how jump commands inside tracks itself behave with few track pointers?
Or maybe it's the fact that the Tracks itself are programmed to jump between Tracks inside the track data.
By tracks we mean an individual set of notes for one instrument, for example a song with a flute, guitar and drumline would have 3 tracks playing all at the same time. Its like a MIDI editor, actually. Although technically you can change the instrument midway, I hope this helps make the concept of a track in a MIDI piece a bit easier to grasp.

Hope we cleared it up for you a bit.
Logged
View Profile
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Cbox
Yesterday at 10:49:52 PM
roger: I can post but it goes to an error page when I submit.
Yesterday at 05:24:12 PM
zman9000: Site is back WOO!
May 09, 2018, 12:35:37 AM
KyleRunner: The "Start In" field is not editable... I'll try making new shortcuts
May 08, 2018, 09:51:08 PM
Fox: If all else fails, you canmake new Shortcuts to do the same thing.
May 08, 2018, 09:49:53 PM
Fox: Export Properties > Shortcut (Tab) > Target / Start In ; Target (for Export) should be: (filename) 0 , and for Import: (filename) 1
May 08, 2018, 08:52:00 PM
KyleRunner: I can't change the path in properties menu...
May 08, 2018, 01:27:19 AM
Fox: You may need to edit something in properties, though... so it uses the exe file in the same directory.
May 08, 2018, 01:24:59 AM
Fox: It is suppose to be a shortcut, yes.
May 03, 2018, 11:48:05 PM
KyleRunner: Fox, the "export" function in your text editor is just a shortcut... Could you please fix it?
May 02, 2018, 09:53:45 PM
KyleRunner: I come here everyday. I'm working on a Portuguese translation, and the people here help me a lot.
May 02, 2018, 08:56:07 AM
Drake baku: My feel as well, I posted a little as well since my return, but silence was all that followed... At least the forum is a great source for data when hacking GS/ GS2, currently looking for something I have read a long time ago cause my PP recovery psy is not working
May 01, 2018, 09:58:04 AM
Fox: I am thinking a lot of this might be because of Discord?
May 01, 2018, 09:56:08 AM
Fox: Yeah, this forum is more dead than ever before.  February and April have 0 new topics. (All other months prior have more.) And March has lowest number of new posts. (It'd be dumb to count the very first month this site was created.)
April 25, 2018, 09:02:13 PM
Fox: Yes. The best tool is a hex editor. Well.... VBA, VBA-SDL-H, no$gba Debugger, GBATEK, and my documentation.... to use these to learn how the code/data works. Best method because it maximizes your editing ability... and then there is my program gsmagic that I was working on. Still in its early stages, though. (Even after year(s).)
April 25, 2018, 04:21:58 PM
Xendrox D: *exept tla editor.
April 25, 2018, 04:21:29 PM
Xendrox D: is there any other tool for hacking gs?
April 23, 2018, 09:26:27 PM
Atrius: Rarely, but not never.
April 23, 2018, 08:01:48 AM
Drake baku: Can it be, the god who created the editor, atrius. I heard you never came back online here anymore
April 20, 2018, 02:46:36 PM
KyleRunner: Atrius!!
April 19, 2018, 11:29:46 PM
Atrius: @Fox, I tried, but for some reason Mario Golf won't boot, and Mario Tennis crashes when you patch out the text compression, and I'm not sure why...  The normal text loading functions in them are basically the same as the ones in the Golden Sun games.

Affiliates
Temple of Kraden Golden Sunrise
Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.053 seconds with 29 queries.