4 #undef STB_VORBIS_HEADER_ONLY
5 #include "submodules/stb/stb_vorbis.c"
10 #define STB_IMAGE_WRITE_IMPLEMENTATION
11 #define STB_IMAGE_IMPLEMENTATION
12 #include "vg/submodules/stb/stb_image.h"
13 #include "vg/submodules/stb/stb_image_write.h"
16 * adapted from stb_vorbis.h, since the original does not handle mono->stereo
19 stb_vorbis_get_samples_float_interleaved_stereo( stb_vorbis
*f
, float *buffer
,
23 if( f
->channels
< 2 ) c
= 0;
26 int k
= f
->channel_buffer_end
- f
->channel_buffer_start
;
31 for( int j
=0; j
< k
; ++j
) {
32 *buffer
++ = f
->channel_buffers
[ 0 ][f
->channel_buffer_start
+j
];
33 *buffer
++ = f
->channel_buffers
[ c
][f
->channel_buffer_start
+j
];
37 f
->channel_buffer_start
+= k
;
42 if( !stb_vorbis_get_frame_float( f
, NULL
, NULL
))
50 * ........ more wrecked code sorry!
53 stb_vorbis_get_samples_i16_downmixed( stb_vorbis
*f
, i16
*buffer
, int len
)
56 if( f
->channels
< 2 ) c
= 0;
59 int k
= f
->channel_buffer_end
- f
->channel_buffer_start
;
64 for( int j
=0; j
< k
; ++j
) {
65 float sl
= f
->channel_buffers
[ 0 ][f
->channel_buffer_start
+j
],
66 sr
= f
->channel_buffers
[ c
][f
->channel_buffer_start
+j
];
68 *buffer
++ = vg_clampf( 0.5f
*(sl
+sr
), -1.0f
, 1.0f
) * 32767.0f
;
69 //*buffer++ = vg_clampf( sr, -1.0f, 1.0f ) * 32767.0f;
73 f
->channel_buffer_start
+= k
;
78 if( !stb_vorbis_get_frame_float( f
, NULL
, NULL
))