You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
894 B
34 lines
894 B
|
14 years ago
|
#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);
|
||
|
|
}
|