don't click here

Compressed Sonic 1 PCM Music

Discussion in 'Engineering & Reverse Engineering' started by Sonic 65, Feb 28, 2009.

Thread Status:
Not open for further replies.
  1. Sonic 65

    Sonic 65

    Tech Member
    You might remember the several (3) PCM demos I've posted in the past year or so, which streamed WAV files from the ROM to play as level music. The main problem with these demos was the large filesize needed to store PCM samples; however, over the past few days, I've added DPCM compression (the same type used for the Sonic 1 DAC samples) to the driver. DPCM compression compresses a sound file by storing a 4-bit deltas instead of a full byte; this results in an exact 2:1 compression ratio for an 8-bit WAV file. Even with the compression, the driver can still play WAVs at 22050Hz (and it works in Gens now!).

    Like always, here's a ROM which showcases the new driver (it uses 6 22050Hz music files):
    Link to Test ROM

    The reason the ROM is 4MB is because it uses 22050KhZ compressed files; if I had used 11025KhZ instead like in the other demos I posted, it would be <2MB.

    Also, here's the music list:

    Code (Text):
    1. GHZ: Slash Man's Stage [Mega Man VII]
    2. MZ:  Burning Heat [Gradius 2 Arcade]
    3. SYZ: Collision Chaos Present [Sonic CD Jap]
    4. LZ:  Undersea Sector [The Guardian Legend]
    5. SLZ: Stardust Speedway GF [Sonic CD Jap]
    6. SBZ: We're The Robots [Mega Man 9]
    7.  
    8. NOTE: LZ and SBZ's songs are not the original versions, but rather remastered ones.

    Also, here's the compiled Z80 driver, and the ASM source. For instructions on how to integrate this driver into the Sonic 1 ROM, see this topic, at the bottom.

    Sound files should be compressed with s1sndcomp.exe for best results. The link on jman2050's site doesn't exist anymore, so here's a mirror on my Fileden account. You probably shouldn't use 22050Hz WAVs like I did for the demo; 16000Hz would probably be better for a hack.

    Hopefully this will help people overcome the filesize limit for PCM files.
     
  2. Tweaker

    Tweaker

    Banned
    12,387
    3
    0
    You just keep making this better and better. Great work! :eng101:

    Out of curiosity though, why are the PCM streams so quiet? Is there a limit as to what volume you're able to use, or was the volume a concious choice on your part? Even the original music is louder than that; there's a good chance the sound effects playing as loud as they are can be way too overbearing and drown out the music.

    Speaking of the sound effects, they seem to be having some issues—I collected a ring, and a second or so later after being collected, it plays again in the other stereo channel with the original sound distorted. This seems to be a consistent issue with all sound effects to some degree; do you plan on fixing it?
     
  3. Sonic 65

    Sonic 65

    Tech Member
    I actually thought that was a pretty good volume; it was around the same level in the last demos, IIRC. Also, distortion from the compression is more noticeable at higher volumes. I'll keep that in mind when using it, though.

    I think I know how to fix this; is the problem fixed (or at least better) in this ROM? (Note that the PCM playback is slower because of the fix; I'll have to speed up the driver somewhere else to make up for this.)
     
  4. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    There is a problem in gens, the sound effects play only the psg channel. Also, when taking the 1-up the music is gone. These problems are in both ROMs. And will you make the songs speed up when taking the speed shoes? I think you should change the Hz of the songs when taking the speed shoes.
     
  5. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    2
    0
    Writing my own MD/Genesis sound driver :D
    This alone made me download your ROM to try out. I'm quite impressed. It works perfectly on Kega Fusion, except for some FM sound effects (like the "grab a ring" sound effect) aren't properly done. Genesis Plus emulates the sound effects badly. Generator works extremely perfectly, with only semi-rare instances of minor sound effects issues (which is ironic, since Generator isn't a complete emulator).

    In your new ROM, Generator doesn't have that perfection. Not only is the song slower, but it is also tuned down. And the sound effects work right only half the time (once I heard a random sound effect that isn't related to anything). Genesis Plus acts the same as in the first ROM. Kega works similarly to Generator, except instead of random sound effects, most sound effects don't finish playing.

    I wonder how/why the DAC could/does affect the FM channels.

    But this is really impressive! Also, why not use bank switching or some other algorithm to store the audio in a way that won't choke the Genesis?
     
  6. muteKi

    muteKi

    Fuck it Member
    7,929
    165
    43
    It's presumably more that it's related to the fact that the sound driver proper has been altered a bit in order to support such long audio files; hence some things blew up in that release.

    My big issue is that pausing the game kills the music and it doesn't come back afterward. (Same with anything that interrupts the sound, as well.)
     
  7. Shibunoa

    Shibunoa

    Banned
    329
    0
    0
    Italy
    What you've done is very nice, Sonic 65.
    I would like seeing the bugs that it has (which were also in the non compressed version) fixed, though, because that will make it usable in general hacks.

    @Andlabs: Bank switching is not an algorithm, it's simply a way to get around addressing limits.
    What bank switching could be used to, is to access data on the cartridge further than the 4 Megabytes limit.
    But that would require additional hardware (and a modified emulator) unless one uses the bankswitching scheme of the few Megadrive titles that have it.
     
  8. Just a bug report but the music disappears when you get speed shoes and doesn't reappear after they go away. It also gets garbled when you die. Very impressive though. I've got a quick question though, the music seems a little low but is that the fault of the driver or just the encoded samples you used?
     
  9. Sonic 65

    Sonic 65

    Tech Member
    Which emulator are you using? Neither of those happen in Fusion (I'm testing with the original ROM, btw). The music being low also doesn't happen on Fusion (unless you're testing with the new ROM).

    muteKi: I can't think of an actual fix for the pausing bug, but you could just make the game not stop the music when pausing. The sound driver being altered to support long audio files probably doesn't have anything to do with it affecting the FM channels.

    I think I've partly fixed the sound effect issues without slowing down playback, but the quality has suffered a little. (At the very least, sound effects don't only play on PSG in Gens anymore.) Link to ROM

    Also, doesn't bank switching require special hardware?
     
  10. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    10
    0
    being an asshole =P
    Yes, though the mapper used in SSF2 is emulated (though up to 6MB in Gens and Fusion and up to 5MB in Regen which has it hard-coded to SSF2). Also using the mapper with the Z80... Well... It's unreliable, period =P
     
  11. I'm using PicoDrive 1.40b on a PSP.
     
Thread Status:
Not open for further replies.