diff options
author | richiesams | 2013-07-18 14:38:57 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:32:25 -0500 |
commit | 32f88486058c0553ae2c0cd1808ef06fcd09b143 (patch) | |
tree | 35154abdd9749db5194df2869896dbb6f775ccac /engines | |
parent | 7644e00bf3e55c1b6b2ea0d74db89d8539cb9f31 (diff) | |
download | scummvm-rg350-32f88486058c0553ae2c0cd1808ef06fcd09b143.tar.gz scummvm-rg350-32f88486058c0553ae2c0cd1808ef06fcd09b143.tar.bz2 scummvm-rg350-32f88486058c0553ae2c0cd1808ef06fcd09b143.zip |
ZVISION: Create utility function to convert .RAW to .WAV
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/utility.cpp | 44 | ||||
-rw-r--r-- | engines/zvision/utility.h | 18 |
2 files changed, 55 insertions, 7 deletions
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp index 5f69fd7433..42fadc78c4 100644 --- a/engines/zvision/utility.cpp +++ b/engines/zvision/utility.cpp @@ -25,6 +25,8 @@ #include "common/tokenizer.h" #include "zvision/utility.h" +#include "zvision/zvision.h" +#include "zvision/zork_raw.h" namespace ZVision { @@ -179,13 +181,6 @@ void dumpEveryResultAction(const Common::String &destFile) { output.close(); } -/** - * Gets the name of the file (including extension). Forward or back slashes - * are interpreted as directory changes - * - * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt - * @return The name of the file without any preceding directories. Ex: file.txt - */ Common::String getFileName(const Common::String &fullPath) { Common::StringTokenizer tokenizer(fullPath, "/\\"); Common::String token; @@ -196,4 +191,39 @@ Common::String getFileName(const Common::String &fullPath) { return token; } +void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile) { + Common::File file; + if (!file.open(inputFile)) + return; + + Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine); + + Common::DumpFile output; + output.open(outputFile); + + output.writeUint32BE(MKTAG('R', 'I', 'F', 'F')); + output.writeUint32LE(file.size() * 2 + 36); + output.writeUint32BE(MKTAG('W', 'A', 'V', 'E')); + output.writeUint32BE(MKTAG('f', 'm', 't', ' ')); + output.writeUint32LE(16); + output.writeUint16LE(1); + uint16 numChannels; + if (audioStream->isStereo()) { + numChannels = 2; + output.writeUint16LE(2); + } else { + numChannels = 1; + output.writeUint16LE(1); + } + output.writeUint32LE(audioStream->getRate()); + output.writeUint32LE(audioStream->getRate() * numChannels * 2); + output.writeUint16LE(numChannels * 2); + output.writeUint16LE(16); + output.writeUint32BE(MKTAG('d', 'a', 't', 'a')); + output.writeUint32LE(file.size() * 2); + int16 *buffer = new int16[file.size()]; + int readBytes = audioStream->readBuffer(buffer, file.size()); + output.write(buffer, file.size() * 2); +} + } // End of namespace ZVision diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h index dba765b65c..46f81efb33 100644 --- a/engines/zvision/utility.h +++ b/engines/zvision/utility.h @@ -30,6 +30,8 @@ namespace ZVision { +class ZVision; + /** * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the * contents to destFile. destFile is created in the working directory @@ -73,8 +75,24 @@ void removeDuplicateEntries(Common::Array<T> *container) { } } +/** + * Gets the name of the file (including extension). Forward or back slashes + * are interpreted as directory changes + * + * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt + * @return The name of the file without any preceding directories. Ex: file.txt + */ Common::String getFileName(const Common::String &fullPath); +/** + * Converts a ZVision .RAW file to a .WAV + * The .WAV will be created in the working directory and will overwrite any existing file + * + * @param inputFile The path to the input .RAW file + * @param outputFile The name of the output .WAV file + */ +void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile); + } // End of namespace ZVision #endif |