Merge branch 'master' of ghostdub.de:gg-button

master
Paul Goeser 14 years ago
commit 639e972abc

@ -4,11 +4,11 @@
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
signed short decode(unsigned char t);
main() main()
{ {
std::vector<unsigned char> data; std::vector<unsigned char> data;
FILE* f = fopen("outputfileulaw.wav", "rb"); FILE* f = fopen("outputfileulaw.raw", "rb");
rewind(f); rewind(f);
while(!feof(f)) while(!feof(f))
{ {
@ -16,7 +16,7 @@ main()
fread(&s, sizeof s, 1, f); fread(&s, sizeof s, 1, f);
data.push_back(s); data.push_back(s);
} }
FILE* o = fopen("outputfileulaw.raw", "wb"); FILE* o = fopen("outputfileulaw.dec", "wb");
int headersize = 4; int headersize = 4;
int old_header_size = 58; int old_header_size = 58;
unsigned int samples = data.size() - old_header_size; unsigned int samples = data.size() - old_header_size;
@ -37,4 +37,15 @@ main()
//memcpy(&new_data[0], &samples, sizeof(int)); //memcpy(&new_data[0], &samples, sizeof(int));
memcpy(&new_data[4], &data[old_header_size], samples_old); memcpy(&new_data[4], &data[old_header_size], samples_old);
fwrite(&new_data[0], sizeof(unsigned char), samples_old+headersize, o); fwrite(&new_data[0], sizeof(unsigned char), samples_old+headersize, o);
}
signed short decode(unsigned char t)
{
int exp = 0x8 - (0x7 & (t >> 4));
int base = (0x1 << (exp+ 5)) - 34;
int step = 0x1 << exp;
signed short ret = base - step * (0xf & t);
ret = -ret - 1 + (2 * ret + 1) * (t >> 7);
return ret;
} }

@ -0,0 +1,9 @@
signed short decode(unsigned char t)
{
int exp = 0x8 - (0x7 & (t >> 4));
int base = (0x1 << (exp+ 5)) - 34;
int step = 0x1 << exp;
signed short ret = base - step * (0xf & t);
ret = -ret - 1 + (2 * ret + 1) * (t >> 7);
return ret;
}
Loading…
Cancel
Save