.WAV file support

View previous topic View next topic Go down

.WAV file support

Post  dilshod on Tue Jan 06, 2009 11:31 pm

Unpacking vorbis codec is very slow. I'm using this code for wave files.
First rename sio2SoundBufferLoad to sio2SoundBufferLoadOGG

Code:

void sio2SoundBufferLoadWAV(SIO2soundbuffer *_SIO2soundbuffer, SIO2stream *_SIO2stream) {
   unsigned char *header;
   header = ( unsigned char * )sio2StreamReadPtr( _SIO2stream, 0x2c );
   _SIO2soundbuffer->size = *(unsigned int *)((int)header + 0x28);
   _SIO2soundbuffer->freq = *(unsigned int *)((int)header + 0x18);
   
   if (header[0x16] == 1 && header[0x22] == 0x10)
      _SIO2soundbuffer->format = AL_FORMAT_MONO16;
   else if (header[0x16] == 2 && header[0x22] == 0x10)
      _SIO2soundbuffer->format = AL_FORMAT_STEREO16;
   else if (header[0x16] == 1 && header[0x22] == 0x8)
      _SIO2soundbuffer->format = AL_FORMAT_MONO8;
   else if (header[0x16] == 2 && header[0x22] == 0x8)
      _SIO2soundbuffer->format = AL_FORMAT_STEREO8;

   _SIO2soundbuffer->data = (char *)malloc(_SIO2soundbuffer->size);
   sio2StreamRead( _SIO2stream, _SIO2soundbuffer->data, _SIO2soundbuffer->size );
}


void sio2SoundBufferLoad(SIO2soundbuffer *_SIO2soundbuffer, SIO2stream *_SIO2stream) {
   if( strstr(_SIO2stream->fname, ".ogg") ||
            strstr(_SIO2stream->fname, ".OGG"))
        {
      sio2SoundBufferLoadOGG(_SIO2soundbuffer, _SIO2stream);
   }
   else if( strstr( _SIO2stream->fname, ".wav" ) ||
        strstr( _SIO2stream->fname, ".WAV" ))
        {
      sio2SoundBufferLoadWAV(_SIO2soundbuffer, _SIO2stream);
   }
}

dilshod

Posts : 7
Join date : 2008-12-28

View user profile

Back to top Go down

Re: .WAV file support

Post  uprise78 on Wed Jan 07, 2009 1:10 pm

Also check out this: http://forum.sio2interactive.com/about-the-sdk-f1/ogg-vs-caf-for-audio-t126.htm?sid=968ad3c3048ee8c51ca2c898d5fef4da

It is a caf file loader that supports compressed and uncompressed audio. Probably having ogg, caf and wav would cover just about every audio requirement out there.

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: .WAV file support

Post  sio2interactive on Wed Jan 07, 2009 2:44 pm

totally agree...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: .WAV file support

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum