Raw PCM to Wave PCM manual

Codecs, formats, encoding/decoding of game audio, video and music
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Raw PCM to Wave PCM manual

Post by spider91 »

Is there any manual of restoring raw pcm headers on files? I've found a lot info about wave headers, but nothing that can help to restore headers on raw data. Also i'd like to make a raw pcm scanner for game files to rip raw data from them, but dunno how to recognize it without headers.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Raw PCM to Wave PCM manual

Post by aluigi »

Without information about frequency, channels and bits, you cannot retrieve them from the raw stream.
The only thing you can guess with some big luck are the bits, 8 or 16.
And regarding the scanner, same problem. There is not a single signature to search for a scanning, to get both beginning and end of the raw data.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Raw PCM to Wave PCM manual

Post by spider91 »

So how does this tool work? It's for compression, but it searches raw data by 2 differenet ways and adds headers to compress it with TAK. I've tried to cut headers on two files, compressed them with this tool and than extracted .tak files from archieve. Files have different crc, but sound is the same.

https://mega.co.nz/#!hoQAEC7Q!LyOLXMSZh ... SAohBosSh0
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Raw PCM to Wave PCM manual

Post by aluigi »

In fact it doesn't work.
I took a PCM WAV file, removed the header ("data" + 4) and then added one file before and after it.
It found nothing and this is correct because normally it searches for DDS, WAV, BMP and MP3, and if you enable the -raw option (1 and 2) it will just dump the file from the beginning.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Raw PCM to Wave PCM manual

Post by spider91 »

It dumps whole file because its a compressor. Search for TAK header (tBaK) on dumped file and yo'll see that raw blocks were compressed with TAK (that cant compress files without headers) and if you rip it from there you can listen that sound. Also tool is not perfect and sometimes finds false-positive raw blocks, but the most important that it finds good blocks and restrores their headers.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Raw PCM to Wave PCM manual

Post by spider91 »

aluigi wrote:I made a test and that tool didn't work with me.
The reason is logic, go on Linux and make: cat /dev/urandom > /tmp/audio_data.raw

The generated file can be a sequence of random bytes or just a "noisy" PCM 8 or 16bit raw audio file, nobody can tell or maybe a valid PCM raw in the middle of other non-audio data.

That's the reason why it's not possible to find headerless raw PCM audio data (no RIFF, no other magic signatures to search) in a file, and I already tested the tool and it failed.

I want to be sure that we are in sync on the correct terms, with PCM raw data I mean just the sequence of audio without headers.
If the data has an header then it's a format (RIFF WAV for example) and, yes, in that case it's possible to search the files, but it's a format scanner and not a "raw" scanner.

Hope it's clear now.


Ok, lets forget abou scanner and talk about already extracted and splitted raw pcm from the game. this tool restores headers and compresses that files with TAK. for now i need to compress each raw file with that tool, than cut first bytes until tBaK (magic of TAK format) and decode it to normal wave pcm. not very comfortable algo.... so i'd like to discover tha way that tool restores headers on raw files. Any suggestions?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Raw PCM to Wave PCM manual

Post by aluigi »

That's easy.
Basically you need only to know the frequency, the channels and the bits.
Usually they are 44100, 2 and 16.

Exist various ways to add the RIFF WAV header, many years ago I wrote a simple tool for the job:
http://aluigi.altervista.org/testz.htm#wavehead

Example:

Code: Select all

wavehead input.raw output.wav 44100 2 16 1

There are also various quickbms scripts online to "play" with raw data and headers, AlphaTwentyThree made many of them.
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Raw PCM to Wave PCM manual

Post by spider91 »

Hmm you was right. That tool adds standard frequency and files are too quick or too slow if its different from 44100. But, somehow, that tool detects number of channels by scanning raw data. Which is the way to detect them?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Raw PCM to Wave PCM manual

Post by aluigi »

Isn't more simple to make these questions to the author of MSC?
http://krinkels.org/threads/msc-media-s ... ssor.1587/
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: Raw PCM to Wave PCM manual

Post by spider91 »

He's busy and not responding.
ARA-JediMaster1138
Posts: 9
Joined: Thu Jan 22, 2015 12:24 am

Re: Raw PCM to Wave PCM manual

Post by ARA-JediMaster1138 »

Excuse me, but I want to relay this message for help for iteachvader. He is trying to get the sound effects from “Star Wars: Rogue Squadron II: Rogue Leader” and “Rogue Squadron III: Rebel Strike” with little success. Here is the thread on Dolphin forums where he is having trouble: https://forums.dolphin-emu.org/Thread-s ... g-features
https://forums.dolphin-emu.org/Thread-s ... res?page=8. Anybody out there who can help him? I hope that this would be the right thread to put up the link on, he is having difficultly decoding the .dat files containing the sounds into .wav files.