From 8d79a889af9d88d94f1614a0efa65367e503e04f Mon Sep 17 00:00:00 2001 From: Hannes Date: Fri, 13 Jan 2012 03:40:27 +0100 Subject: [PATCH] Changed header to 4 byte containing number of samples --- headeredit.cpp | 34 ++++++++++++++++++++++ outputfileulaw.raw | Bin 0 -> 4 bytes outputfileµlaw.wav => outputfileulaw.wav | Bin 3 files changed, 34 insertions(+) create mode 100644 headeredit.cpp create mode 100644 outputfileulaw.raw rename outputfileµlaw.wav => outputfileulaw.wav (100%) diff --git a/headeredit.cpp b/headeredit.cpp new file mode 100644 index 0000000..9ca0607 --- /dev/null +++ b/headeredit.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include + + +main() +{ + std::vector data; + FILE* f = fopen("outputfileulaw.wav", "rb"); + rewind(f); + while(!feof(f)) + { + unsigned char s; + fread(&s, sizeof s, 1, f); + data.push_back(s); + } + FILE* o = fopen("outputfileulaw.raw", "wb"); + int headersize = 4; + int old_header_size = 58; + unsigned int samples = data.size() - old_header_size; + unsigned char* new_data = (unsigned char*)malloc(sizeof(char) * (samples + headersize)); + //little endian: + new_data[0] = (unsigned char) samples; + samples >>= 8; + new_data[1] = (unsigned char) samples; + samples >>= 8; + new_data[2] = (unsigned char) samples; + samples >>= 8; + new_data[3] = (unsigned char) samples; + memcpy(&new_data[4], &data[58], samples); + fwrite(&new_data[0], sizeof(unsigned char), samples+headersize, o); +} \ No newline at end of file diff --git a/outputfileulaw.raw b/outputfileulaw.raw new file mode 100644 index 0000000000000000000000000000000000000000..08f375057f797ff448dd4893daba15bbd30774a6 GIT binary patch literal 4 LcmXSz#J~Um19|}i literal 0 HcmV?d00001 diff --git a/outputfileµlaw.wav b/outputfileulaw.wav similarity index 100% rename from outputfileµlaw.wav rename to outputfileulaw.wav