Audio-TinySoundFont
view release on metacpan or search on metacpan
TinySoundFont/tsf.h view on Meta::CPAN
// Decode one frame of vorbis samples with whatever stb_vorbis API that is available
#if !defined(STB_VORBIS_NO_PULLDATA_API) && !defined(STB_VORBIS_NO_FROMMEMORY)
n_samples = stb_vorbis_get_frame_float(v, TSF_NULL, &outputs);
if (!n_samples) break;
#else
if (pSmpl >= pSmplEnd) break;
{ int use = stb_vorbis_decode_frame_pushdata(v, pSmpl, (int)(pSmplEnd - pSmpl), TSF_NULL, &outputs, &n_samples); pSmpl += use; }
if (!n_samples) continue;
#endif
// Expand our output buffer if necessary then copy over the decoded frame samples
resNum += n_samples;
if (resNum > resMax)
{
do { resMax += (resMax ? (resMax < 1048576 ? resMax : 1048576) : resInitial); } while (resNum > resMax);
res = (float*)TSF_REALLOC((oldres = res), resMax * sizeof(float));
if (!res) { TSF_FREE(oldres); stb_vorbis_close(v); return 0; }
}
TSF_MEMCPY(res + resNum - n_samples, outputs[0], n_samples * sizeof(float));
}
stb_vorbis_close(v);
( run in 0.237 second using v1.01-cache-2.11-cpan-26ccb49234f )