Custom Music for SNES

Discuss PoP1 for SNES here.
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Custom Music for SNES

Post by Shauing »

Shauing wrote: April 19th, 2018, 5:34 am It would be great if there was some way (tool/hex editing/something) to implement the MIDI converted to MML file into the game.

If said tool doesn't exist or cannot be created to add music/sounds, and/or things cannot be added to a ROM, perhaps finding how the music is written in the hex format and attempt to write or replace it there?

I'm just trying to come up with possibilities.
Well, months after I made these comments, and inspired by a recent discussion about custom music with Poorchop, I decided to research about the possibility of adding custom music to PoP for SNES.
After failing to find a way to implement it automatically, I decided to try HEX-Editing after remembering a reply from David:
David wrote: April 15th, 2018, 12:18 pm From what I see, they have a tool to convert MIDI to MML (tinymm), some tool to edit MML, and a tool to put it into the game (Addmusic).
This MML format seems to be quite similar to the format of PoP1 SNES songs, for example @ is for instrument selection, CDEFGAB are the notes, R is for rests, etc.
MML even has syntax for repeating the same sequence a given number of times, which is also a feature of PoP's format.
After searching for similitudes between the ripped .SPC's and the ROM, I eventually found where each music is written and how (for the most part).
Along with a music format text document shared by David, I did two attempts, one for each of the first two tracks of the game (Prologue and Menu). For the most part (again), I think I succeeded.

For the Prologue music (0:00-0:27), I only enabled audio channels 1 and 8.
Channel 8 retains the original samples and notes (drums/percussion and its 3/4 beat).
Channel 1 has the original brass sample but notes and their beat have been changed (4/4 beat); the music was slowed down for a more accurate input when writing the notes and timing.
As mentioned above, there is a syntax where sequences can repeat a number of times (I suppose for each individual channel); I imagine that there is also something that determines how many notes can be written for each sequence of each channel. These are the only things I haven't figured out where are they. I say this because, my melody seems to be longer than the original intended length of the first sequence, and as a result, it breaks down at around (0:10) when it changes to the second sequence (few notes loop and thus the beat becomes irregular, and the sound pans to the right side of the stereo image).

For comparison, on the Menu music (0:28-1:00), all audio channels are activated.
Except for channel 8 (percussion), all samples for each channel have been changed.
On Channel 4 (originally brass, now low strings sample), notes were lowered by one octave.
Channel 6 swaps trumpet and the ney(? -wind-like instrument -) of their original sections (the trumpet plays what the ney original played and vice versa).
Channel 8 it's the only channel with rewritten notes. In this case, it was written within the original length of the sequence, so it does not break down. The beat is much more simpler and pans across the stereo field.

I only need to know where are located these values/syntaxes for the length and number of repeats for each sequence of each channel, for each song; otherwise, it would be very restricting to write within the pre-written limits for each part that makes up a tune.

This can be a very tedious way to write custom music, but I feel that once you know and can play with each element, it becomes a less difficult task.

Last edited by Shauing on January 13th, 2019, 12:04 pm, edited 1 time in total.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
Poorchop
Efendi
Efendi
Posts: 7
Joined: January 8th, 2019, 8:15 am

Re: Custom Music for SNES

Post by Poorchop »

Wow, really excellent work. I'm too much of a coward to dive into the hex code and I won't have any free time for quite a while but you've already made some good progress. Seems like you've already taken a huge step forward towards being able to implement custom music.

As for writing custom tunes, I just wanna reiterate what I mentioned in your other thread. I haven't played around with it yet but it looks like it should be possible to export samples directly from OpenMPT. The samples can presumably then be used in the user's DAW of choice along with a MIDI keyboard. This should make templating songs extremely easy and way more fluid than using a tracker.

From reading interviews with SNES composers, they hated writing for the SPC700. David Wise who did most of the tunes for Donkey Kong Country 1 and 2 said that he worked directly with hex code and Toshiya Yamanaka, one of the composers for PoP, had this so say about the SNES port:
Crafting sounds for the Super Famicom was very difficult process. You had to work in this special UNIX environment, it was really annoying. Once I had created the sounds there, I transferred them back to my original music editor software and worked there. I used an in-circuit emulator to playback the data I had created, then finally burned it onto a SFC ROM.
Based on this, writing tunes in your DAW of choice is still pretty faithful to how Toshiya originally crafted the songs. Just limit it to 8 tracks, one for each channel, and templating in a tracker should be fairly straightforward.

I've never used a tracker but it looks like the alternative to my suggestion would be typing in every single note and then manually specifying the length, cutoff, pitch, and so forth. I can only imagine that writing a tune from scratch this way would take several weeks, not to mention it's hard to write music that way. Also on a personal level, I want to add that it's pretty damn hard to come up with something unique and catchy to complement the existing tunes. Sometimes I think I had a good idea but a few minutes later, I realize that I've ripped off one of the original songs. That's part of the reason that I was so impressed with your original song - it was not only nice and catchy, but it was unique.
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

Poorchop wrote: January 13th, 2019, 3:41 am Wow, really excellent work. I'm too much of a coward to dive into the hex code and I won't have any free time for quite a while but you've already made some good progress. Seems like you've already taken a huge step forward towards being able to implement custom music.
Thank you; It can be scary to go into hex-editing, but taking one step at a time is the safest approach for this. Indeed it is time consuming but once everything you wanted is figured out, it becomes somewhat fun to do.
Poorchop wrote: January 13th, 2019, 3:41 am As for writing custom tunes, I just wanna reiterate what I mentioned in your other thread. I haven't played around with it yet but it looks like it should be possible to export samples directly from OpenMPT. The samples can presumably then be used in the user's DAW of choice along with a MIDI keyboard. This should make templating songs extremely easy and way more fluid than using a tracker.
Yes, you can export samples on OpenMPT. I think it is possible to import them on whichever DAW you want, depending of which format you exported the samples and which ones the DAW can accept.
Poorchop wrote: January 13th, 2019, 3:41 am From reading interviews with SNES composers, they hated writing for the SPC700. David Wise who did most of the tunes for Donkey Kong Country 1 and 2 said that he worked directly with hex code and Toshiya Yamanaka, one of the composers for PoP, had this so say about the SNES port:
Crafting sounds for the Super Famicom was very difficult process. You had to work in this special UNIX environment, it was really annoying. Once I had created the sounds there, I transferred them back to my original music editor software and worked there. I used an in-circuit emulator to playback the data I had created, then finally burned it onto a SFC ROM.
Based on this, writing tunes in your DAW of choice is still pretty faithful to how Toshiya originally crafted the songs. Just limit it to 8 tracks, one for each channel, and templating in a tracker should be fairly straightforward.
When I wrote the Queen's theme, I wrote the tune first on the music editor software, thinking about which instruments will go on each track/channel, then when I finished it, I went to manually write each channel's contents in OpenMPT. Now that I mostly know how to write the music via hex-editing, I will try to manually write again each channel's contents. I still need to know where and what are the commands for looping specific parts of each channel for each section of the tune, so I can write utilizing as very little space as possible and avoid to run out of said space.
Poorchop wrote: January 13th, 2019, 3:41 am I've never used a tracker but it looks like the alternative to my suggestion would be typing in every single note and then manually specifying the length, cutoff, pitch, and so forth. I can only imagine that writing a tune from scratch this way would take several weeks, not to mention it's hard to write music that way.
That's pretty much what you have to do via hex-editing, write each note, its length, pitch, if it has cutoff or not. If I were to compose more tunes, I will rather write the tune on the traditional way first, and when I am sure that I will not do any more major changes, that's when I would write it on the tracker, and subsequently to the rom via hex.
Poorchop wrote: January 13th, 2019, 3:41 am Also on a personal level, I want to add that it's pretty damn hard to come up with something unique and catchy to complement the existing tunes. Sometimes I think I had a good idea but a few minutes later, I realize that I've ripped off one of the original songs. That's part of the reason that I was so impressed with your original song - it was not only nice and catchy, but it was unique.
I would love to hear your compositions; perhaps they aren't really that much of a rip-off as you think. I will tell you, I thought this tune wasn't good enough but I felt that perhaps it had something, but I wouldn't know that for sure unless I released it. Thank you again. I hope I can manage to at least insert this one tune (as I wrote it or abridged) on a 2.0 version rom of The Queen Of Light.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
NITM-T
Sultan
Sultan
Posts: 182
Joined: July 29th, 2017, 12:10 am

Re: Custom Music for SNES

Post by NITM-T »

Amazing, man! You really have achieved your goal. Congrats!
Custom musics and sprites are things that I really miss for SNES PoP mods when I play Castlevania, Super Mario World, Super Metroid and other mods.
May the Moon light your path.
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

NITM-T wrote: January 13th, 2019, 8:14 am Amazing, man! You really have achieved your goal. Congrats!
Custom musics and sprites are things that I really miss for SNES PoP mods when I play Castlevania, Super Mario World, Super Metroid and other mods.
Well, almost achieved it; I am still trying to figure where are and how the sequences work for each channel of each tune. Perhaps Norbert, David or someone who has better knowledge of the ROM could solve this quickly.

The ultimate dream of course, is to be able to customize sprites. I think if it ever becomes possible, there would be even more SNES mods of it, and most likely, very diverse and creative in both visuals and audio.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
NITM-T
Sultan
Sultan
Posts: 182
Joined: July 29th, 2017, 12:10 am

Re: Custom Music for SNES

Post by NITM-T »

Yep, that's right. But you did something that no one has (that I know). You asked for it, you looked for it and by yourself, you did it. You gave the first step about custom musics for that game. Or course that, you also had help from the guys here, so, you'd reach that goal. That means the obvious, you're not alone to achieve those things ^_^.

I wish you good luck on your works. Can't do nothing as an amateur about hack stuff, but, I'll play your new custom mods. That's for sure, hahaha.
May the Moon light your path.
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

NITM-T wrote: January 14th, 2019, 7:34 am Yep, that's right. But you did something that no one has (that I know). You asked for it, you looked for it and by yourself, you did it. You gave the first step about custom musics for that game. Or course that, you also had help from the guys here, so, you'd reach that goal. That means the obvious, you're not alone to achieve those things ^_^.

I wish you good luck on your works. Can't do nothing as an amateur about hack stuff, but, I'll play your new custom mods. That's for sure, hahaha.
I do have to thank David for documenting on a text his findings on the music format of PoP SNES. Said text I used it to verify my own findings and know some stuff (mainly sample effects) that I didn't figure out. I also thank all of you on this forum, that support and make suggestions for this and many of my crazy ideas.

I am not an expert but a very curious amateur. :lol: The furthest goal for custom music I can come up with, is to be able to import custom samples, but I think the unique and recognizable sound of SNES PoP will be lost, unless an entirely different game is intended.
Thank you very much again for your support and I hope you make new mods too, even if they are too hard for me to play! :mrgreen:
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
Poorchop
Efendi
Efendi
Posts: 7
Joined: January 8th, 2019, 8:15 am

Re: Custom Music for SNES

Post by Poorchop »

This summer I'll finally have some free time. I hope that you'll have stumbled upon some new insights in that time but in any case I'd like to start exploring the samples to make some new tunes. Maybe we can collaborate on some tunes as well and come up with a new soundtrack to rival the original. I think it might also be worth starting a threat to discuss the original soundtrack. I don't know if anybody else is obsessed with the songs like me but out of the hundreds of games that I've played, PoP has remained the top dog in the music department.
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

Poorchop wrote: January 17th, 2019, 7:36 pm This summer I'll finally have some free time.
Can't wait to hear what you can do.
Poorchop wrote: January 17th, 2019, 7:36 pm I hope that you'll have stumbled upon some new insights in that time...
I did figure out where and how the sequences work for each channel. I am now trying to figure out if I can extend each channel's content (space for writing notes), as not all of them have the same length. You only have so much space for every tune in the ROM, so you cannot really put a long song with lots of musical content. Right now, I am trying to write the Queen's theme for the title screen, but I had to cut out the intro, as I still haven't found how to expand said writing space. When I think I found the stuff minimum required for writing music via HEX-Editing, I will post a document of my findings along with information that David documented himself some time ago.
Poorchop wrote: January 17th, 2019, 7:36 pm ...but in any case I'd like to start exploring the samples to make some new tunes.
Hope your creative juices flow and you come up with good tunes.
Poorchop wrote: January 17th, 2019, 7:36 pm Maybe we can collaborate on some tunes as well and come up with a new soundtrack to rival the original.
Sure!
Poorchop wrote: January 17th, 2019, 7:36 pm I think it might also be worth starting a threat to discuss the original soundtrack. I don't know if anybody else is obsessed with the songs like me but out of the hundreds of games that I've played, PoP has remained the top dog in the music department.
Yeah, we should start a thread for that too. I have the soundtrack on my mobile devices and listen to it often; really good job Yamanaka and Nakano did. I have been always curious what tunes did each one; their compositions blend pretty well, and it is hard to distinguish differences in style/writing between the two.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

I think I figured out pretty much everything required to write music via HEX-editing. I'm posting a document I made of my findings at the end of this post. I also figured out how to extend each channel sequences and space for writing notes, but as I'm pretty insecure in writing my explanations, I left these things out for the moment.
It can be a pain to write custom tunes this way, but at least I think it's now possible. Also, this might lead to the creation of a software equivalent to AddMusicK, if someone can utilize this documentation as a starting point.
I will try to share in these days a video of my custom tune inserted on my mod, as soon as I have fully implemented it, though I think the intro of that tune will remain eliminated as I'm not sure if it will fit, even if I expand the space available for some channels and reduce others. Will see.

NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Custom Music for SNES

Post by David »

Shauing wrote: January 25th, 2019, 10:17 am I think I figured out pretty much everything required to write music via HEX-editing. I'm posting a document I made of my findings at the end of this post.
I've added the music format to the Princed Wiki page about SNES format: http://www.princed.org/wiki/SNES_format#Music
I guess I should have done this earlier...
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

David wrote: January 27th, 2019, 12:21 pm I've added the music format to the Princed Wiki page about SNES format: http://www.princed.org/wiki/SNES_format#Music
Awesome! Thank you! Glad to see clarification on the stuff I had doubts about what some hex numbers did.
David wrote: January 27th, 2019, 12:21 pm I guess I should have done this earlier...
I think that until someone that crazy and insistent to look for a way to insert custom music appeared, it wouldn't have been an important area to keep documenting.
Besides, you have been busy with SDLPoP.

Now I am on my quest for custom sprites, and I haven't quite figured out how to decompress compressed sprites and the exact location of each character or object sprites (prince, princess, Jaffar, guards, bosses, items), despite knowing the offset of where the sprites are located.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: Custom Music for SNES

Post by Norbert »

Shauing wrote: January 27th, 2019, 7:40 pm[...], and I haven't quite figured out how to decompress compressed sprites and [...]
I'm not 100% sure, but this is probably related?
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

Norbert wrote: January 27th, 2019, 8:57 pm
Shauing wrote: January 27th, 2019, 7:40 pm[...], and I haven't quite figured out how to decompress compressed sprites and [...]
I'm not 100% sure, but this is probably related?
I don't know if it extracts sprites as well.
Still, I think even if we could use this one to export sprites, it cannot import them back.
I was hoping to find them in hundreds/thousands of bits and pieces on an editor like Tile Molester or Tile Layer Pro and edit them there, but can't make out any pattern, even when seemingly using the correct palette depending of the sprites I want to edit.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
Shauing
Calif
Calif
Posts: 432
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Custom Music for SNES

Post by Shauing »

Well, I have finally implemented my composition in the game. Very minimal differences in sample configurations and the intro part being cut; I could have implemented it, but didn't fit quite well with the scenes. I also completed the arrangement of the Menu theme that I initially did as a test of changing instrument sample for each channel.
I also did a custom palette for both the Prologue and Menu screens.

Last edited by Shauing on February 7th, 2019, 1:20 am, edited 1 time in total.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
Post Reply