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

Refactor audio with a dedicated Sampler #365

Merged
merged 4 commits into from
May 7, 2023
Merged

Refactor audio with a dedicated Sampler #365

merged 4 commits into from
May 7, 2023

Conversation

JD557
Copy link
Owner

@JD557 JD557 commented May 7, 2023

Moves the AudioClip/AudioWave iterator methods to a new Sampler class.

The reasons for this are the following:

  • There was a huge performance problem introduced in Improve audio player performance #356, where AudioWave#drop was pretty much broken for waves generated for oscillators. Turns out that I would need to add more iterator special cases.
  • The original reason to have the iterator methods was to allow streaming data from audio files, but that doesn't make much sense with the current interface, which pretty much promises random access to the clip.

As such, I decided to simplify the code and make those methods agnostic of the underlying AudioWave/AudioClip implementation.

Also, for now I'm considering streaming audio out of the scope for Minart. It's still possible for an application to implement that using something like a Iterator[AudioClip] or a Stream[AudioClip]`, but I imagine each application will have their preferred format.

I also did some tests with HyperLoopRunner on Firefox and now the audio seems good, so I think this should close #354

Finally, this also fixes a bug with AudioPlayer#play(wave, channel), which was always using channel 0.

@JD557 JD557 added this to the 0.5.2 milestone May 7, 2023
@JD557 JD557 merged commit 6c74626 into master May 7, 2023
@JD557 JD557 deleted the refactor-audio branch May 7, 2023 20:59
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.

Fix audio sync problems in Firefox
1 participant