Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CPAL buffer bug (standalone) #142

Merged
merged 1 commit into from
May 5, 2024

Conversation

JerwuQu
Copy link
Contributor

@JerwuQu JerwuQu commented Apr 16, 2024

This is trying to solve the same thing as #104.

nih-plug master gives distorted audio for me when using wasapi or alsa backends when built standalone.

#104 fixes this, but for me it only worked for one channel, while this worked for all channels.

Tested working on Windows/WASAPI and Linux/Alsa. Further testing would be good too.

@robbert-vdh robbert-vdh merged commit 1c03d4a into robbert-vdh:master May 5, 2024
7 checks passed
@robbert-vdh
Copy link
Owner

Thanks for the PR! There were two (or well, three) issues here:

  • The current implementation reads but doesn't actually write in an interleaved fashion. This PR fixes that for the writing part.
  • CPAL promises us that we'll receive a certain number of samples per buffer, but it gives us different amounts for the audio callback. Using data.len() / num_output_channels instead of the configured buffer size works as long as that number is below the configured buffer size (i.e. as long as these constraints still holds true). This is a bit annoying and there are also situations where you get more samples than you requested (e.g. Requested buffer size not used on macOS RustAudio/cpal#748), but I guess this behavior is still better than what it is now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants