mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Crackly when seeking with ma_sound_seek_to_pcm_frame() #449

Closed mackron closed 2 years ago

mackron commented 2 years ago

Originally posted by @quetzalsly in https://github.com/mackron/miniaudio/issues/442

I am using the easy setup of miniaudio and calling my own play() quite a lot, quite fast but not every frame, only when a new thing is displayed on screen. inside my play() I have ma_sound_seek_to_pcm_frame(sound, 0); it results in the correct sound being repeated but it seems to crackle. Just playing the sound once normally without ma_sound_seek_to_pcm_frame does not produce a crackle.

mackron commented 2 years ago

@quetzalsly When this happens, is it just a one-off glitch for each seek, or is it like a persistent crackle that lasts the length of the sound? What flags are you using when you initialize your sound? If you're not already, are you able to try with MA_SOUND_FLAG_DECODE and let me know how that changes it, if at all?

quetzalsly commented 2 years ago

I am actually already using that decode flag, to me it sounds like the crackle is at the very start of the series of sounds. I tried to simply make a sound[10] array and play each one only if its not already playing, resulting in something like what I needed, but I would prefer to do it with resetting the buffer on a single sound. Also this is happening on very small sounds that are like 1 sec and under like little beeps that are meant to make a beeping signal.

mackron commented 2 years ago

Are you able to give the dev branch a try? I had a report about a crash with ma_sound_seek_to_pcm_frame() which I've fixed and I'm wondering if perhaps it has coincidentally fixed your issue.

mackron commented 2 years ago

Assuming fixed. This will be released in the next few days.