mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-11 04:06:12 +00:00
ZVISION: Create utility function to convert .RAW to .WAV
This commit is contained in:
parent
7644e00bf3
commit
32f8848605
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user