- clip->data = vg_file_read( vg_audio.audio_pool, clip->path );
- clip->size = vg_file_size( vg_audio.audio_pool );
+ if( clip->source_mode == k_audio_source_mono )
+ {
+ vg_linear_clear( vg_mem.scratch );
+ u32 fsize;
+ void *filedata = vg_file_read( vg_mem.scratch, clip->path, &fsize );
+
+ stb_vorbis_alloc alloc = {
+ .alloc_buffer = vg_linear_alloc( vg_mem.scratch, AUDIO_DECODE_SIZE ),
+ .alloc_buffer_length_in_bytes = AUDIO_DECODE_SIZE
+ };
+
+ int err;
+ stb_vorbis *decoder = stb_vorbis_open_memory(
+ filedata, fsize, &err, &alloc );
+
+ if( !decoder )
+ {
+ vg_error( "stb_vorbis_open_memory failed on '%s' (%d)\n",
+ clip->path, err );
+ vg_fatal_exit_loop( "Vorbis decode error" );
+ }
+
+ /* only mono is supported in uncompressed */
+ u32 length_samples = stb_vorbis_stream_length_in_samples( decoder ),
+ data_size = length_samples * sizeof(i16);
+
+ clip->data = vg_linear_alloc( vg_audio.audio_pool, data_size );
+ clip->size = length_samples;