faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.03k stars 150 forks source link

Stuttering on 96 kHz / 24 bit FLAC #132

Open jericdeleon opened 2 years ago

jericdeleon commented 2 years ago

👋 Hello!

First off, thanks for this library! Got it mostly working, but struggling on a certain area.

Whenever I try playing a hi-res FLAC file (96 kHz / 24 bit) following the Beep Tutorial, I encounter stuttering and breaking.

Logging out format from flac.Decode on 2 different FLAC files:

Here's a sample file where I can reproduce the stuttering.

It also doesn't help that this is my first time delving into audio processing, so I'm not quite sure if I'm just missing some configuration on how I'm using the lib, or whether this problem exists within faiface/beep, or hajimehoshi/oto, or even just on OSX in general.

Any pointer to the right direction will be highly appreciated.

I am on: MacOS Big Sur 11.6 (let me know if you'd like more environment settings).

kemokemo commented 1 year ago

First of all, Thank you so much for this awesome product beep!

I just recently started using beep. I am suffering from similar symptoms. Adjusting the buffer size as shown below improves the symptoms somewhat, but stuttering still occurs.

- speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
+ speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/1000))

development specs

kemokemo commented 1 year ago

Sorry to keep coming back to you.

I noticed the following statement in the README of the oto that beep uses internally.

// Usually 44100 or 48000. Other values might cause distortions in Oto samplingRate := 44100

I will discuss this with the issue of oto repository to see if they can support a sampling rate of 96000.

kemokemo commented 1 year ago

In my environment and usage, I can playback without noise by changing the buffer size to 20000. On the other hand, in my Windows environment, I can playback with a buffer size of 10.

Due to my lack of knowledge and research, I cannot explain the reasons for these behaviors. I am thinking of using it anyway, as it seems to accomplish the application at hand.