#150612 - sowee - Fri Feb 08, 2008 3:14 pm
Hey there, does anybody know a fast way to convert unsigned to signed? I seem to be having problems with streaming 8-bit wavs from memory card because of the conversion..this is basically the method i use to fill the buffer that i stream
and this is the method i use to convert to signed, which i got from darknight ez
It was running fine when i was doing some vram access in drawing to the framebuffer alongside the streaming maybe because the vram access delays the timing a bit so the conversion is able to make it.. but now i removed the drawing code and theres popping sounds for my steaming...so i think i need to optimize the code but don't really know how else to do it?
[Subject Fairy was here -- MOD]
Last edited by sowee on Sat Feb 16, 2008 3:16 pm; edited 1 time in total
Code: |
void FillRingBufferMono(void *stream, SoundStream *ssin, u32 numsamples)
{ if( (ssin->data_pointer - 44) > ssin->length){ ssin->data_pointer = 44; fseek(ssin->fp, ssin->data_pointer, SEEK_SET);} if (ssin->data_pointer < 44) { ssin->data_pointer = 44;} fread(stream, numsamples, (size_t)1, ssin->fp); if (ssin->bits_per_sample == 8){ toggleSignBit(stream, numsamples); } ssin->data_pointer+=numsamples; } |
and this is the method i use to convert to signed, which i got from darknight ez
Code: |
void toggleSignBit(unsigned char *sample, unsigned int len) { for(; len > 0; --len, ++sample) { *sample ^= 0x80; } } |
It was running fine when i was doing some vram access in drawing to the framebuffer alongside the streaming maybe because the vram access delays the timing a bit so the conversion is able to make it.. but now i removed the drawing code and theres popping sounds for my steaming...so i think i need to optimize the code but don't really know how else to do it?
[Subject Fairy was here -- MOD]
Last edited by sowee on Sat Feb 16, 2008 3:16 pm; edited 1 time in total