Golden Sun Hacking Community
October 20, 2018, 05:51:29 PM *
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 17353 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: 4568

« 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: 4568

« 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: 1760

« 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
October 13, 2018, 03:23:06 AM
Salanewt: Updated it to provide more info that I forgot to mention.
October 13, 2018, 03:16:48 AM
Salanewt: I'm still trying to iron out IQ 2 but I'm pretty sure it's entirely random targeting.
October 13, 2018, 03:16:29 AM
Salanewt: Oh yeah, I posted some more info about enemy IQ.
October 12, 2018, 09:51:27 PM
FoxThe HTML5 project is too small to count
October 12, 2018, 06:19:48 AM
Luna_blade: there is jjppof's html5 project...
October 12, 2018, 06:19:17 AM
Luna_blade: Though Momo rings a bell it seems I came here after you left
October 11, 2018, 12:49:41 AM
Fox: (If that makes sense.)
October 11, 2018, 12:48:33 AM
Fox: Yeah, I guess so.  More just saying that's a good place to get answers to GS related questions at the moment.
October 11, 2018, 12:42:28 AM
Crystal Sonata: I did before, but I guess I could try it again
October 11, 2018, 12:41:32 AM
Fox: Not much at the moment. This forum seems pretty quiet. Perhaps you'd be interested in joining the Discord for GSHC that seems to have more activity?
October 10, 2018, 11:16:53 PM
Crystal Sonata: Any projects going on? I need a distraction from the daily grind and I'm interested in hacking GS again.
October 10, 2018, 10:02:53 PM
Fox: Thanks, and good to see you too!
October 10, 2018, 10:02:10 PM
Fox: A few people I'm sure... Most likely the regulars of the past. Such as Atrius, Charon, Role, Salanewt....
October 10, 2018, 03:11:17 AM
Crystal Sonata: I find myself wondering who still remembers me here. Obvs you do (Good to see ya Tea)
October 10, 2018, 12:46:11 AM
Fox: On second thought, it might be because you haven't posted much as Crystal Sonata.
October 10, 2018, 12:41:12 AM
Fox: And your intro isn't that bad. - I imagine most people would say the same about theirs?
October 10, 2018, 12:39:39 AM
Fox: :O - You've been gone so long, I think I forgot you were Momo.  Interesting.
October 09, 2018, 10:23:39 PM
Crystal Sonata: I just revisited my dark past on here and ouch. Someone delete that introduction thread please, the cringe.
October 09, 2018, 08:26:11 AM
Crystal Sonata: Aaaaand, she re-appears yet again. My life keeps dragging me away from the internet sadly.
October 01, 2018, 01:27:50 PM
Luna_blade: haha oof.

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.114 seconds with 22 queries.