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 dictaphone buffer length #287

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vincerubinetti
Copy link

After coming across this StackOverflow answer, I believe since the dictaphone is showing getByteTimeDomainData, the buffer length should be the fftSize, not the frequencyBinCount (fftSize/2). I'm not an expert in audio processing, but the comments on that post seem to confirm this, and it is also backed up by it working this way in this other MDN example on getFloatTimeDomainData.

I guess it's not really a big deal, practically speaking in the case of this example. It's just throwing out half of its wave data every frame, but you can still get a good idea of your mic signal. But a lot of people follow this example for education purposes, and I think it should be fully correct.

@vincerubinetti vincerubinetti requested a review from a team as a code owner December 11, 2024 02:25
@vincerubinetti vincerubinetti requested review from pepelsbey and removed request for a team December 11, 2024 02:25
Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thank you for the suggestion. I have an additional one since we’re using analyser.fftSize in two places now: declare the bufferLength and then use it.

- analyser.fftSize = 2048;
- const bufferLength = analyser.fftSize;
- const dataArray = new Uint8Array(bufferLength);
+ const bufferLength = 2048;
+ const dataArray = new Uint8Array(bufferLength);
+ analyser.fftSize = bufferLength;

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