News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Custom Samples

Started by Mentlegen, December 27, 2017, 08:52:48 PM

Previous topic - Next topic

Mentlegen

I've read DSO's post about samples but im still unsure on how to replace samples. I know that i can use projectiler ( by blackfalcon ) to change beam noises by referencing different samples in libraries 1 2 and 3, but i'm interested in importing my own .WAV . I think i can convert it to a certain format but im not sure how i would go about doing that.

I'm actually really lost here. Any help is appreciated.

DSO

https://www.romhacking.net/utilities/681/

This is what I use for changing .wav files to .brr

One issue you might run into is most beams actually use a combination of sound samples that they share between them - editing the sound samples of spazer will also change the sound of plasma, for example.
Another issue might be the resulting .brr file could be much larger than the files used for beam sounds in the rom. The samples used are very small and high-pitched - the .wav files used for the beam sounds are recorded 2 octaves higher than the pitch they are played at in-game, to save space in the precious little memory the SPC chip has to work with. You will also have to do this with your samples as well, if you want them to fit in the allotted space.

Mentlegen

Quote from: DSO on December 28, 2017, 07:15:20 AM
https://www.romhacking.net/utilities/681/

This is what I use for changing .wav files to .brr

One issue you might run into is most beams actually use a combination of sound samples that they share between them - editing the sound samples of spazer will also change the sound of plasma, for example.
Another issue might be the resulting .brr file could be much larger than the files used for beam sounds in the rom. The samples used are very small and high-pitched - the .wav files used for the beam sounds are recorded 2 octaves higher than the pitch they are played at in-game, to save space in the precious little memory the SPC chip has to work with. You will also have to do this with your samples as well, if you want them to fit in the allotted space.

Thanks man! I have this program, and i think it only works from command prompt. But i'm unsure how to apply .brr files to my ROM

DSO

The gist of it is I use a hex editor and paste/overwrite the file into the rom at the right location, but it involves some complicated work if your sample is bigger in size than the one you're replacing. It'd be a complicated post, so I'll probably record a youtube video instead. Hopefully it'll be up in a few days.

Moehr

That would be great! The hack I am working on isn't gonna be super impressive but I would love.to be able to contribute some tracks for others here to use if they like. If it's able to be done via hex edit, I can handle trying to compose things to a specific length.

I mean, nothing i put up I gonna be great anyhow, but I have been really hoping to figure out how to replace songs. I have a couple stuck in my head that I came up with while doing tiling.

Mentlegen

Quote from: DSO on December 29, 2017, 11:54:51 AM
The gist of it is I use a hex editor and paste/overwrite the file into the rom at the right location, but it involves some complicated work if your sample is bigger in size than the one you're replacing. It'd be a complicated post, so I'll probably record a youtube video instead. Hopefully it'll be up in a few days.

Thanks so much for your support! I'd love to see that once it's up! I'll credit you in my hack for being helpfull

DSO

Unfortunately, I'm having trouble with the BRR encoder myself when trying to create loop points and I was hoping to include that in the video. I don't know how long it'll take me to figure out what's going wrong, so here's a post with some info.

Every sample is made of 9 byte blocks, so each .brr file will be a multiple of 9 bytes.
Every sample in the .brr format in the ROM will begin with a particular string of 9 bytes, making the beginning of a sample easily identifiable as it is almost always one of these two chunks:
00 00 00 00 00 00 00 00 00 - non looping sample
02 00 00 00 00 00 00 00 00 - sample that is looped


The following is a table of the permanently loaded sound samples in the game, containing Sample #, ROM location, ARAM location, and sample length. Due to the transfer method from ROM to ARAM, it is possible to transcend the boundaries of a bank.

Sample #
|   ROM location: SNES address - PC address
| | ARAM location
|       | | Sample length
|      |   |               |
|       | |               |
00: CF:D029 - 27D029 6E00 > 73C4 5C4 < sound for beginning a shot,
01: CF:D5ED - 27D5ED 73C4 > 7988 5C4 < also sound for a shot, first part of grapple sound
02: CF:DBB1 - 27DBB1 7988 > 79AC 318 < Second part of grapple sound, part of doors
03: CF:DEC9 - 27DEC9 7CA0 > 7DF6 156 < Item selecting, Samus landing
04: CF:E01F - 27E01F 7DF6 > 82F4 4FE < Last part of beam firing for non-ice
05: CF:E51D - 27E51D 82F4 > 8318 3DE < Is used in powerbombs
06: CF:E8FB - 27E8FB 86D2 > 86ED 1EF < Xray/elevator
07: CF:EAEA - 27EAEA 88C1 > 88DC 30F < spinjump/spacejump noise
08: CF:EDF9 - 27EDF9 8BD0 > 91CA 5FA < Bombs
09: CF:F3F3 - 27F3F3 91CA > 91E5 120 < Samus's footsteps
0A: CF:F513 - 27F513 92EA > 964A D65 < item theme string
0B: CF:F513 - 27F513 92EA > 964A D65 < repeat item theme string
0C: D0:8029 - 280278 A04F > A06A 5A < Simple tone, used for "beeping notes" in elevator music
0D: D0:82D2 - 2802D2 A0A9 > A15D B4 < chozo hand grabbing Samus, crocomire bones crumbling
0E: D0:8386 - 280386 A15D > A2E9 18C < Underwater breathing noise
0F: D0:8512 - 280512 A2E9 > A6BE 3D9 < entering/exiting water
10: D0:88EB - 2808EB A6BE > A6E2 2B5 < Final part of ice beam noise
11: D0:8BA0 - 280BA0 A973 > A98E 3F < Static
12: D0:8BA0 - 280BA0 A973 > A98E 3F < ^
13: D0:8BDF - 280BDF A9B2 > ACB8 306 < Samus hurt noise
14: D0:8EE5 - 280EE5 ACB8 > AF5B 2A3 < Common enemy hurt noise
15: D0:9118 - 281118 AF5B > AF7F 2B5 < Health pickup noise
16: D0:943D - 28143D B210 > B516 306 < unused, but sounds like it could be an alternate enemy sound


So you will have to replace one or more of these sounds with your new sample after you have converted it to .brr format.

At CF:CF85 (27CF85 in a hex editor), there is a table of pointers that the music engine uses for the locations of these samples.  There are two pointers per sample, two bytes per pointer. The start point for the sample and the loop point for looping samples. This is what the ARAM location I included in the table is for. Let's say you use sample 00 for your new shot sound sample, but your shot sound sample is longer by 0x18C bytes. You could shift all the samples after sample #00 by 0x18C bytes and eat into the unused sample, but then you'd also have to go into this sample table at 27CF85 and add 0x18C to all the 2 byte pointers after sample 0x00 up to sample 0x16 so the pointers will match the new locations.



Sorry this isn't a video with a demonstration of how to do this, but I want to do a complete video and I need to figure out why the BRR encoder isn't quite working for me when it comes to creating loop points before I do that. Hope this at least lets you get started.

Moehr

Thanks, every little bit helps!

Mentlegen

Quote from: DSO on January 04, 2018, 07:14:26 AM
Unfortunately, I'm having trouble with the BRR encoder myself when trying to create loop points and I was hoping to include that in the video. I don't know how long it'll take me to figure out what's going wrong, so here's a post with some info.

Every sample is made of 9 byte blocks, so each .brr file will be a multiple of 9 bytes.
Every sample in the .brr format in the ROM will begin with a particular string of 9 bytes, making the beginning of a sample easily identifiable as it is almost always one of these two chunks:
00 00 00 00 00 00 00 00 00 - non looping sample
02 00 00 00 00 00 00 00 00 - sample that is looped


The following is a table of the permanently loaded sound samples in the game, containing Sample #, ROM location, ARAM location, and sample length. Due to the transfer method from ROM to ARAM, it is possible to transcend the boundaries of a bank.

Sample #
|   ROM location: SNES address - PC address
| | ARAM location
|       | | Sample length
|      |   |               |
|       | |               |
00: CF:D029 - 27D029 6E00 > 73C4 5C4 < sound for beginning a shot,
01: CF:D5ED - 27D5ED 73C4 > 7988 5C4 < also sound for a shot, first part of grapple sound
02: CF:DBB1 - 27DBB1 7988 > 79AC 318 < Second part of grapple sound, part of doors
03: CF:DEC9 - 27DEC9 7CA0 > 7DF6 156 < Item selecting, Samus landing
04: CF:E01F - 27E01F 7DF6 > 82F4 4FE < Last part of beam firing for non-ice
05: CF:E51D - 27E51D 82F4 > 8318 3DE < Is used in powerbombs
06: CF:E8FB - 27E8FB 86D2 > 86ED 1EF < Xray/elevator
07: CF:EAEA - 27EAEA 88C1 > 88DC 30F < spinjump/spacejump noise
08: CF:EDF9 - 27EDF9 8BD0 > 91CA 5FA < Bombs
09: CF:F3F3 - 27F3F3 91CA > 91E5 120 < Samus's footsteps
0A: CF:F513 - 27F513 92EA > 964A D65 < item theme string
0B: CF:F513 - 27F513 92EA > 964A D65 < repeat item theme string
0C: D0:8029 - 280278 A04F > A06A 5A < Simple tone, used for "beeping notes" in elevator music
0D: D0:82D2 - 2802D2 A0A9 > A15D B4 < chozo hand grabbing Samus, crocomire bones crumbling
0E: D0:8386 - 280386 A15D > A2E9 18C < Underwater breathing noise
0F: D0:8512 - 280512 A2E9 > A6BE 3D9 < entering/exiting water
10: D0:88EB - 2808EB A6BE > A6E2 2B5 < Final part of ice beam noise
11: D0:8BA0 - 280BA0 A973 > A98E 3F < Static
12: D0:8BA0 - 280BA0 A973 > A98E 3F < ^
13: D0:8BDF - 280BDF A9B2 > ACB8 306 < Samus hurt noise
14: D0:8EE5 - 280EE5 ACB8 > AF5B 2A3 < Common enemy hurt noise
15: D0:9118 - 281118 AF5B > AF7F 2B5 < Health pickup noise
16: D0:943D - 28143D B210 > B516 306 < unused, but sounds like it could be an alternate enemy sound


So you will have to replace one or more of these sounds with your new sample after you have converted it to .brr format.

At CF:CF85 (27CF85 in a hex editor), there is a table of pointers that the music engine uses for the locations of these samples.  There are two pointers per sample, two bytes per pointer. The start point for the sample and the loop point for looping samples. This is what the ARAM location I included in the table is for. Let's say you use sample 00 for your new shot sound sample, but your shot sound sample is longer by 0x18C bytes. You could shift all the samples after sample #00 by 0x18C bytes and eat into the unused sample, but then you'd also have to go into this sample table at 27CF85 and add 0x18C to all the 2 byte pointers after sample 0x00 up to sample 0x16 so the pointers will match the new locations.



Sorry this isn't a video with a demonstration of how to do this, but I want to do a complete video and I need to figure out why the BRR encoder isn't quite working for me when it comes to creating loop points before I do that. Hope this at least lets you get started.

Thanks d00d! i can chew on this until the video is out. Ya i have to say the encoder is finnicky that's why i looked here for some help.

Moehr

How hard would it be to convert something simple like this from the online sequencer I mess around in?

https://onlinesequencer.net/719177

Mentlegen

Quote from: Moehr on January 28, 2018, 08:27:34 PM
How hard would it be to convert something simple like this from the online sequencer I mess around in?

https://onlinesequencer.net/719177

you would need to export your composition to .wav, and then maybe you could begin to work with DSO's new tutorial coming out soon.

DSO

I would recommend checking out our discord. Total is working on a tool to import samples and note data from impulse tracker and is posting updates there. Since we have a functional music tool in development now, I've been less focused on making a tutorial, though I still intend on making one in the future.

Quote from: Moehr on January 28, 2018, 08:27:34 PM
How hard would it be to convert something simple like this from the online sequencer I mess around in?

https://onlinesequencer.net/719177

Looks pretty easy

Moehr

Thanks DSO, I literally joined the discord to follow the music discussion. Pretty excited about it!