| sonicFlushStream(sonicSpeedupStream); | sonicFlushStream(sonicSpeedupStream); | ||||
| int length = (out_end - out_ptr); | int length = (out_end - out_ptr); | ||||
| length = sonicReadShortFromStream(sonicSpeedupStream, (short*)out_ptr, length/2); | length = sonicReadShortFromStream(sonicSpeedupStream, (short*)out_ptr, length/2); | ||||
| #ifdef ARCH_BIG | |||||
| { | |||||
| unsigned i; | |||||
| for (i = 0; i < length/2; i++) { | |||||
| unsigned short v = ((unsigned short *) out_ptr)[i]; | |||||
| out_ptr[i*2] = v & 0xff; | |||||
| out_ptr[i*2+1] = v >> 8; | |||||
| } | |||||
| } | |||||
| #endif | |||||
| out_ptr += length * 2; | out_ptr += length * 2; | ||||
| } | } | ||||
| break; | break; | ||||
| // Speed up the audio samples with libsonic. | // Speed up the audio samples with libsonic. | ||||
| static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text) | static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text) | ||||
| { | { | ||||
| #ifdef ARCH_BIG | |||||
| unsigned i; | |||||
| #endif | |||||
| if (length_in > 0) { | if (length_in > 0) { | ||||
| if (sonicSpeedupStream == NULL) | if (sonicSpeedupStream == NULL) | ||||
| sonicSpeedupStream = sonicCreateStream(22050, 1); | sonicSpeedupStream = sonicCreateStream(22050, 1); | ||||
| if (sonicGetSpeed(sonicSpeedupStream) != sonicSpeed) | if (sonicGetSpeed(sonicSpeedupStream) != sonicSpeed) | ||||
| sonicSetSpeed(sonicSpeedupStream, sonicSpeed); | sonicSetSpeed(sonicSpeedupStream, sonicSpeed); | ||||
| #ifdef ARCH_BIG | |||||
| for (i = 0; i < length_in; i++) { | |||||
| unsigned short v = ((unsigned char*) outbuf)[i*2] | (((unsigned char *)outbuf)[i*2+1] << 8); | |||||
| ((unsigned short *) outbuf)[i] = v; | |||||
| } | |||||
| #endif | |||||
| sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in); | sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in); | ||||
| } | } | ||||
| if (end_of_text) | if (end_of_text) | ||||
| sonicFlushStream(sonicSpeedupStream); | sonicFlushStream(sonicSpeedupStream); | ||||
| return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out); | |||||
| int ret = sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out); | |||||
| #ifdef ARCH_BIG | |||||
| for (i = 0; i < length_out; i++) { | |||||
| unsigned short v = ((unsigned short *) outbuf)[i]; | |||||
| ((unsigned char *)outbuf)[i*2] = v & 0xff; | |||||
| ((unsigned char *)outbuf)[i*2+1] = v >> 8; | |||||
| } | |||||
| #endif | |||||
| return ret; | |||||
| } | } | ||||
| #endif | #endif | ||||