-
Notifications
You must be signed in to change notification settings - Fork 0
/
wv_writer.cpp
28 lines (23 loc) · 889 Bytes
/
wv_writer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "wv_writer.h"
#include "wav_format.h"
#include "indywv.h"
namespace WvWriter {
void write(std::string& path, const WavFormat::WavHeader* wavHeader, char* inData, uint32_t compressedSize)
{
auto writeInt = [](std::ostream& os, auto val)
{
os.write(reinterpret_cast<const char*>(&val), sizeof(val));
};
std::ofstream os(path, std::ofstream::binary);
os.write(IndyWV::kIndyWV, sizeof(IndyWV::kIndyWV));
writeInt(os, (uint32_t)(wavHeader->sampleRate));
writeInt(os, (uint32_t)(wavHeader->bitDepth));
writeInt(os, (uint32_t)(wavHeader->numChannels));
writeInt(os, (uint32_t)(compressedSize + 3));
writeInt(os, (int32_t)0);
writeInt(os, (int32_t)wavHeader->dataChunkSize);
writeInt(os, (int8_t)0); // Unknown
writeInt(os, (int16_t)0); // Unknown
os.write((char*)inData, compressedSize - 4);
}
} // namespace WvWriter