Gamingforce Interactive Forums
85239 35211

Go Back   Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Music and Trading > Behind the Music
Register FAQ GFWiki Community Donate Arcade ChocoJournal Calendar

Notices

Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis.
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).


Sega Saturn And .P16 Files
Reply
 
Thread Tools
TigerC10
Wark!


Member 35823

Level 1.21

May 2010


Reply With Quote
Old May 25, 2010, 05:43 AM Local time: May 25, 2010, 05:43 AM #1 of 7
Sega Saturn And .P16 (CPK/PCM?) Audio Files

Greetings, all. First of all I want to say that I have done a bunch of searching over the last few days regarding this matter and after my exhaustive search I happened across this thread:

http://www.gamingforce.org/forums/be...ame-music.html

Rather than resurrect that thread out of the depths of forum hell, I thought I'd start fresh. If you don't want to sit through my nostalgic story, skip the quote.

Quote:
Many Sega Saturn enthusiasts are familiar with Astal, and even though it is so under-appreciated the game is loved by many. After deciding that the music was so enchanting that I must have the OST for myself - I discovered no soundtrack was ever released.

Enter Ultrace:
Astal Unofficial Original Soundtrack

He's concocted an unofficial soundtrack for us all to enjoy - and those of you that knew about Astal before reading this thread have probably already downloaded this. Over the years it has lived happily in my hard drive, giving me a smile when shuffle randomly selects one of its songs from the thousands in my library.

But this is no fairy tale ending; Now that I have upgraded my computer and have a significant improvement in storage capacity, I've decided to upgrade my music library with lossless precision. I've resolved to delete all of my MP3s as I can just re-rip them as WAVs and convert them to FLAC (or if the mood strikes perhaps WMA/Apple lossless).

This is the start of the problem. Ultrace's 192kbps mp3 rips do not fit the bill. So I did what came naturally, and popped the disk into my computer to see if it could be ripped.

Exact Audio Copy found a hidden track on my game disk, a vocal version of the opening theme song. Most excellent. It is now a FLAC. However, the rest of the music in the game is not in this "redbook" style. This means, I'm going to have to rip the audio directly from the data files on the disk.
So onto my dillema. Ultrace also encountered this issue years ago...

Originally Posted by Ultrace
The music for Astal is stored on the game disc in .P16 files. I wrestled with these for several days, but was unable to get them to import correctly into an audio editing program (they read as 22khz stereo 16-bit Motorola PCM, but come with a strange warble that I could find no way of removing.)
They're PCM you say? Okay, well - I ran them through PCM2Wav and got nothing but static. Frustrating.

So with some google-fu I found out that the .p16 extension belongs to an audio tool known as ProTracker Studio 16. Many are aware that this is an Amiga program used for creating 16-track audio files not dissimilar to midis. Games like Jazz Jackrabbit use it (though I believe the extension is different, perhaps .mod was used). But I digress.

Immediately, I got myself an Amiga emulator, and loaded up ProTracker Studio 16. Alas, it was to no avail. It may just be the fact that I have no idea how to use ProTracker Studio 16, or it may just not be functional - eithe rway I couldn't get the .P16 to load. One file was rather large, ~40MB - and ProTrackerStudio 16 didn't have enough memory to load it. I tried a smaller one and it didn't complain about loading it - but from what I could tell there was no information loaded. Again, maybe I just don't know how to use it properly.

Out of desperation I changed the file extention and tried playing the audio through a variety of MOD players (WinAmp, JavaMOD Player, VLC Media Player). VLC was a surprise, it was able to load track length data - but not much else (although I did hear 1 sound effect used in the game during the playback of the large 40MB file - 1 split second surrounded by 2 minutes of silence). Still, I don't think the track length data that VLC was able to load was truely the length of the track. None the less, the sound effect I heard gave me hope.

Early on into my search, I found this site:
kingshriek's SSF/DSF page

Using some tools from that site, or tools that they mentioned - I tried converting the .p16 files into .s3m files. The new .s3ms were garbage - nothing but static. So it seems I've got to try another approach.


I've always liked using Cool Edit 2 Pro, but ever since Adobe bought the company out I've been using Audition and as of late Soundbooth. Upon trying to import unrecognized pcm audio, these programs have asked for the sample rate and the number of bits. It seems, this is no longer a part of the import process as I was not presented with this prompt when I imported the audio. So I used Audacity. Audacity couldn't play anything back either (but not for lack of trying) - it was all static.

So it seems that now I'm back at square one. If there are any audiophiles out there that might be able to help me understand about this .P16 format, please don't hesitate to reply or send me a PM. I'd really rather not have to resport to the spindown method that Ultrace used.


EDIT:

Alrighty, so using the "Import RAW Data" feature of audacity I was able to select the following settings

Signed 16 bit PCM
Big-endian
2 Channel Stereo
Start Offset 0 bytes
Amount to import 100%
Sample Rate 22050 hz

To my surprise (and joy) it worked. Almost. I ran into the exact same issue Ultrace had in that there's a strange waver in the audio playback.

If I change the sample rate to 44100 hz and move it down to a 1 channel mono - it comes up with almost the same results.

So, being that I believe it to be 16 channels - I'm playing around with importing it this way.

I've put the file up here:
Download STAGECLR.P16 from Sendspace.com - send big files the easy way

Feel free to download and give it a go yourself.

How ya doing, buddy?
evilboris
*stare*


Member 309

Level 24.31

Mar 2006


Reply With Quote
Old May 25, 2010, 04:47 PM Local time: May 25, 2010, 10:47 PM 1 #2 of 7
The SSF tools are for synth audio, so you can ignore those (well, you can rip sound effects and Pause jingles with those). Also, ignore file extensions on console games, they can be very often game specific and have nothing to do with any other application.

I don't think I can add anything that you haven't found out by yourself.

If I had to make a wild guess, I'd say that the pcm data is stored in the same way as in the Sega FILM format (used in the CPK videos - big-endian, and stereo data is in non-interleaved chunks).

There's nowhere I can't reach.
TigerC10
Wark!


Member 35823

Level 1.21

May 2010


Reply With Quote
Old May 25, 2010, 11:14 PM Local time: May 25, 2010, 11:14 PM #3 of 7
Good call, evilboris. I owe you a beer or something.

I researched the Sega FILM format and came across:
Sega FILM - MultimediaWiki

Quote:
Audio data in a FILM file can be stored in a variety of formats which are mostly linear PCM variants.

...

If the CPK audio data is stereo (8- or 16-bit), the channel data is non-interleaved. Usually, stereo data is stored as interleaved chunks with a left channel sample followed by a right channel sample as follows:
Code:
 L | R | L | R | L | R | L | R ...
(However) In a stereo CPK file, for each audio data chunk, the first half of the chunk contains left channel samples and the second half contains right channel samples.
Therefore the data scheme is more like this:
Code:
 L R | L R | L R | L R | L R | L R | L R | L R ...
With both left and right channel data in a single chunk, THAT is what is causing this waver in the playback. This is progress.

Now, onto a solution...

I did a search for cpk2wav and came up with a hit on a japanese website. Loosely translated, I'm in the "Video Game Audio Conversion" area of the site. The utility "CPK2WAV" has the following description:

Quote:
WAV files extracted from a type of Saturn Cinepak

This software, the Sega Saturn video file "Cinepak for SEGA" (extension. CPK) just ripping sound, Windows for. WAV file is a program to convert.
Cinepak, the video compression format that is, the game is only in the sound (that is. CPK was dressed only noise) of the file exists. This program was created in order to convert the main file. Of course, audio files can be retrieved ordinary Cinepak.
So it looks like I've got the right tool.

Just to be sure, I ran the program from the command line without any parameters to see if the programmer left a friendly welcome:
Code:
C:\Users\Administrator\Music\Astal>CPK2WAV.EXE

ébéoéjéQévé`éuüDédéwéd  V0.64

 usage: cpk2wav (input file) [(output file)]

         input file : Cinepak for SEGA file (.cpk)
        output file : MS-Windows wave file  (.wav)
Awesome. Looking good so far. I run it again with the necessary parameters and it looks like it errors out with:

Code:
C:\Users\Administrator\Music\Astal>CPK2WAV.EXE STAGECLR.cpk STAGECLR.wav
STAGECLR.cpk -> STAGECLR.wav

é▒é╠âtâ@âCâïé╔é═ñë╣É║âXâgâèü[âÇé¬éáéΦé▄é╣é±.
Naturally, I wish those were japanese characters. If they were, I might be able to give them to a friend to translate. Alas, they are not - likely because I haven't set my default UI to be japanese.

If I had to venture a guess, it's complaining that there's no video data in the file. And so, I am left hanging knowing the problem, but not having the solution.

evilboris or anyone else, I need help interleaving the audio in the file... Got any suggestions?

EDIT:

So I found some more useful tools for CPK files. Specifically what was useful was ACPK2AVI. According to the usage tagline...
Code:
Another convertor from CPK to AVI. ver. 1.06 Copyright (C) 1997, GANA, Nishi
       SEGA Saturn Cinepak (*.cpk) / ADPCM (*.adp) -> MS Windows AVI (*.avi)
usage: acpk2avi [-msadpcm] [+|-DELAY] <INPUT.cpk> [INPUT.adp|wav] <OUTPUT.avi>
       acpk2avi <INPUT.adp> <OUTPUT.wav>
Well, it looks like it can take an ADPCM file and then convert it out to a wav. So I fed it through...
Code:
C:\Users\Administrator\Music\Astal>ACPK2AVI.EXE STAGECLR.adp STAGECLR.wav
Another convertor from CPK to AVI. ver. 1.06 Copyright (C) 1997, GANA, Nishi
       SEGA Saturn Cinepak (*.cpk) / ADPCM (*.adp) -> MS Windows AVI (*.avi)
STAGECLR.ADP: acpk2avi: FILM not found: this is not Cinepak.
So it says it's not a cinepak file... Yet, I clearly hear it when imported as raw data - and the wavering effect that comes through clearly shows the half left half right channel info per chunk... So now I don't know what to do.

This thing is sticky, and I don't like it. I don't appreciate it.
~TigerC10~
evilboris
*stare*


Member 309

Level 24.31

Mar 2006


Reply With Quote
Old May 26, 2010, 11:42 AM Local time: May 26, 2010, 05:42 PM #4 of 7
At this point the only thing you could do was writing your own custom pcm parser.

I am a dolphin, do you want me on your body?
TigerC10
Wark!


Member 35823

Level 1.21

May 2010


Reply With Quote
Old May 26, 2010, 04:47 PM Local time: May 26, 2010, 04:47 PM #5 of 7
Yeah, I had considered doing that. I read somewhere that FFmpeg had some saturn cpk support... Can't find anywhere that really demonstrates how though.

But you're probably right, with as much effort as I've put into looking for stuff it'd probably be easier to just write one myself. Found a nice description of the stucture of the format.

Code:
bytes 0-3    'FILM' signature
bytes 4-7    length of FILM header (including signature and length fields)
So, if I read in the length of the header from bytes 4-7, I can skip down to the FDSC chunk which contains info regarding the media. In the FDSC chunk, bytes 8-11 are usually set to 'cvid' to represent cpk video, but if there is no video they'll be set to null. My guess is that since these are audio files and not video files - there's a null present where the current decoders expect to see 'cvid' and that's why they're complaining that there's no video data. Once I'm in the FDSC chunk I can read in bytes 4-7 to get its length and skip down to the STAB data - which is what we all really care about.

Once I get in there I can reorganize the PCM data as much as I want, however it'll still require me to import the raw PCM data into something like audacity to export as a WAV... That's going to make my process for converting these files a long longer for each file. Oh well, cest la vie? No?

I was speaking idiomatically.
~TigerC10~
evilboris
*stare*


Member 309

Level 24.31

Mar 2006


Reply With Quote
Old May 27, 2010, 01:08 PM Local time: May 27, 2010, 07:08 PM #6 of 7
The p16 files are raw audio. No header, no nothing.

Perhaps you could make a dummy FILM container that holds audio only, I haven't tried that. If converters work properly and not just by bruteforcing the video, then it could work. Even if converters suck and don't work properly with stereo 16bit audio inside cpk files, you can still use mencoder, since mplayer supports FILM properly. (I've never once encountered a saturn game with that high audio quality under FMVs inside a CPK file, and it would be highly impractical since CPK does not use audio compression - stereo 16bit would only allow very low sampling rates. This is of course not counting Burning Rangers ADX and Nights into Dreams ADPCM.)

FFMpeg probably just supports Cvid, the compression used in CPK files. I've seen a directshow splitter that allowed windows to open CPK files directly, but I haven't used it in ages, and you can just open them in mplayer anyway.

What kind of toxic man-thing is happening now?
TigerC10
Wark!


Member 35823

Level 1.21

May 2010


Reply With Quote
Old May 27, 2010, 05:02 PM Local time: May 27, 2010, 05:02 PM #7 of 7
Oh. Well if has no header in it that makes my job easier.

Although, I've never tried making a dummy container for anything - it's worth a try. However, every time I try to get MPlayer or Mencoder to work, it fails miserably. I've tried on both Windows and Mac and it just doesn't like me. I don't know what I'm doing wrong with it but I don't know if I trust it.

FELIPE NO
~TigerC10~
Reply


Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Music and Trading > Behind the Music > Sega Saturn And .P16 Files

Forum Jump


All times are GMT -5. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.