changed type to typedefs

master
Hannes 14 years ago
parent 61ae8456ae
commit d992034049

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

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