Changed header to 4 byte containing number of samples

master
Hannes 14 years ago
parent bfc1ed883a
commit 8d79a889af

@ -0,0 +1,34 @@
#include <stdio.h>
#include <vector>
#include <complex>
#include <cstring>
#include <cstdlib>
main()
{
std::vector<unsigned char> 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);
}

Binary file not shown.
Loading…
Cancel
Save