HomeForumsWhat's newResources 
 
 
Can you Convert Aif/Wav to .ADP? (Saturn XA Adpcm)
LackofTrack - Mar 31, 2018
 LackofTrack Mar 31, 2018
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.

 XL2 Apr 1, 2018
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.

 LackofTrack Apr 1, 2018
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.

 XL2 Apr 1, 2018

LackofTrack said:

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?

 LackofTrack Apr 1, 2018
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.

 Ms. Tea Apr 1, 2018

LackofTrack said:


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.

 LackofTrack Apr 1, 2018
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.

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.

  
	
	
Three Types of File Formats
(1) AIFF format (uncompressed PCM)
(2) CD-ROM XA audio format (ADPCM compression)
(3) User-specified ADPCM format (OptImage Interactive Services AudioStack file output format)



  
	
	
Notes:
(1) The “user-specified ADPCM format” refers to the data file format output by an AIFF to ADPCM file converter utility called AudioStack by OptImage Interactive Services


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.

 vbt Apr 1, 2018
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



 XL2 Apr 1, 2018

LackofTrack said:

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!

 vbt Apr 2, 2018

XL2 said:

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


 XL2 Apr 2, 2018

vbt said:

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

 vbt Oct 7, 2018
(bump) anybody tried to play ADPCM files (best with sbl lib) on saturn ?
does it costs some speed on SH2 to decompress file ?

 Ponut Oct 7, 2018
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.