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

AudioContext.decodeAudioData() function always resamples every audio file to 96000 sample rate #3397

Open
ego-lay-atman-bay opened this issue Sep 17, 2024 · 3 comments

Comments

@ego-lay-atman-bay
Copy link
Contributor

While working on my audio processing library, I discovered that every sound I imported (and created in snap) has the same constant sample rate, 96000, even though the sample rate was explicitly something else.

After doing some digging, I found that the AudioContext.decodeAudioData() function now converts all audio files to have a 96000 sample rate, resulting in weird inconsistencies.

Just to be clear, this is not necessarily an issue with snap, it's an issue with browsers changing how audio data is handled.

I don't currently know how to get the audio samples and the correct sample rate, but I feel like it might be good to ditch the AudioContext class, since it messes with audio data.

@jmoenig
Copy link
Owner

jmoenig commented Sep 17, 2024

yeah, I've been noticing this also. Here's a little trick I use / built into Snap: If you access the microphone sensing reporter, e.g. to get the volume, it will adjust the sampling rate to whatever your hardware / browser currently uses. Although it tends to "forget" this quickly, sometimes :(

@ego-lay-atman-bay
Copy link
Contributor Author

It seems like my device sample rate is 96000, so it didn't change anything.

Since I am creating an audio processing library, I want to be able to work with different sample rates, not dependent on the device settings (specifically so I can compare snap to my audio processing library in python).

@jmoenig
Copy link
Owner

jmoenig commented Sep 17, 2024

yes, I'm finding the web audio api to be really frustrating for this. There doesn't seem to be any way to query the client's sample rate.

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

No branches or pull requests

2 participants