• Rise from your gwave!

Can you Convert Aif/Wav to .ADP? (Saturn XA Adpcm)

Discussion in 'Saturn Dev' started by LackofTrack, Mar 31, 2018.

  1. LackofTrack

    LackofTrack New Member

    Hello!
    I'm trying to mod Sonic Jam and replace it's music for the Genesis games. The format the music is in though is .ADP. Is there a way to convert Aif or Wav files to .ADP files? From what I've gathered it seems Adp files are just AIFF files with XA audio encoded with in them but I can't find any program that can will allow me to do that. The closest I got was with the Sega Adpcm encoder for Mac but that program doesn't write a AIFF header or Fliter values, just raw xa audio which Sonic Jam does not like.
     
  2. XL2

    XL2 Member

    I'm interested in knowing too.
    What is the header like?
    Perhaps we could just write a small program to add the header to the file.
    I didn't get the tone editor to work as it doesn't seem to recognize the aif files.
    What did you use to create them?
    I know that modern aif is in little endian while old Macs and the Saturn use big endian, but I can't even try to load it.
     
  3. LackofTrack

    LackofTrack New Member

    The header of an ADP file looks to be a standard AIFF header except it has the tag "APCM". Besides that it seems to be regular XA audio. Here is a page I found about someone adding support for it to FFmpeg. https://patchwork.ffmpeg.org/patch/7100/
    I don't think writing a header only will work because when I tryed to copy a header over using a hex editor the song would play but, it would have tons of static over the actual song. Looking over different sites this seems to be a common problem with XA files that don't have any filters within them.

    For making AIFF files the process was really simple for me. I just used a program called audacity and converted wav files to Aiff. Saturn games that use AIFF files seem to work just fine with them. I don't know about the tone editor though.
     
  4. XL2

    XL2 Member

    So using audacity worked? I thought modern AIFF was always little endian.
    Did you have to use special options?
    And do you think you can try to use it with the tone editor?
     
  5. LackofTrack

    LackofTrack New Member

    No special options were used. I just set it to export a 16Bit AIFF file but, I'm pretty sure 8Bit will work too.
    I'll see if tone editor will accept the Aiff file.
     
    XL2 likes this.
  6. Ms. Tea

    Ms. Tea New Member

    That's my patch. :) Unfortunately FFmpeg doesn't have support for encoding XA ADPCM, so I haven't spent any time at looking at adding support for muxing it.
     
  7. LackofTrack

    LackofTrack New Member

    XL2 I think I know why the Sega Tone Editor wasn't accepting your files. I think it has to do with the size of the Aiff file. When I tried to put in a mono 12 second file at 22050hz it wouldn't take the file but, when I put in a mono 1 second file at 16000hz it accepted it just fine. You might have lower the sample rate of your Aiff files and make sure there VERY short.

    So you did create that patch Ms.Tea! I knew the submitter name seemed familiar:laugh:.

    As For encoding Xa audio Aiff files I found some more information about different formats of them. Here's a few quotes from the SBL Program Library User's Guide 3.
    I think this is the Program Sonic Team (and other developers too perhaps) used to convert Aiff files to XA ADPCM audio but, I can't find any information on the program.
     
  8. vbt

    vbt Staff Member

    why don't you use the sega adpcm encoder, i've just tried it and it worked well, aiff size was 1.2mb, the adpcm size is around 300kb
    upload_2018-4-2_3-16-55.

    upload_2018-4-2_3-18-41.
     
  9. XL2

    XL2 Member

    Thanks.
    I managed to read the files simply by using another Mac emulator.
    So now I got the tone editor to work, I must figure out how to generate sequences and how to read the files!
     
  10. vbt

    vbt Staff Member

    which one are you using, basilik 2 is working well, i had some bad behavior/trouble before finding the right settings :

    upload_2018-4-2_11-4-2.
     
  11. XL2

    XL2 Member

    Yes, I also switched to Basilisk and it works fine.
    I just need to figure out how to use the tone banks now.
     
  12. vbt

    vbt Staff Member

    (bump) anybody tried to play ADPCM files (best with sbl lib) on saturn ?
    does it costs some speed on SH2 to decompress file ?
     
  13. Ponut

    Ponut New Member

    In my experiments, I never managed to get SGL or SBL to play the ADPCM files.
    I could get the stream and sound system to report no errors, but no sound would play.

    I COULD get it to play the ADPCM files as uncompressed PCM, but doing so obviously produced garbage (it did not decompress it).
    I know this doesn't help you, but my understanding is that the ADP library that we have available is either broken or in dire need source code to look over and understand.

    If I had any guess for their usage, you probably need to decipher the ADP_DecMono and/or ADP_DecStereo commands to figure out where they send the decompressed audio (somewhere in sound memory). Then use SND_PCM_ON with that area of memory as the target. You could scroll through sound memory 16 KB at a time to try and find out where it is, if it even works.

    The object code for the Saturn ADP library is for the SH2s, so those are unquestionably what would handle the decompression.

    There are ADP decompression/playback libraries for M68K family processors out there, if you understood how to integrate that into the sound driver (assembly), you would probably have an easier time than deciphering the ADP library.
     
    Last edited: Oct 7, 2018

Share This Page