58 auto audioBuffer = std::make_shared<AudioBuffer>();
62 if (drmp3_init_memory(&mp3, file->data().data(), file->size(),
nullptr)
68 const drmp3_uint64 frameCount = drmp3_get_pcm_frame_count(&mp3);
69 if (frameCount == 0) {
74 decodedAudio.
channels = mp3.channels;
80 const size_t totalSampleCount = frameCount * mp3.channels;
82 std::vector<drmp3_int16> pcm(totalSampleCount);
84 const drmp3_uint64 samplesDecoded =
85 drmp3_read_pcm_frames_s16(&mp3, frameCount, pcm.data());
89 if (samplesDecoded == 0) {
92 decodedAudio.
samples.resize(samplesDecoded * mp3.channels
93 *
sizeof(drmp3_int16));
94 std::memcpy(decodedAudio.
samples.data(), pcm.data(),
97 audioBuffer->upload(decodedAudio);