-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Bad sample length after normalize #103
Comments
I think it could be due to this: https://github.com/edimuj/cordova-plugin-audioinput/blob/master/www/audioInputCapture.js#L397 The reason for this code is that on iOS the last sample delivered from native is not a number. |
Hi, I recently got the same problem on iOS, that always the last sample is missing. After debugging the Objective-C code and finding that all samples are present, I finally ended up in "audioInputCapture.js": In line 378 in function "normalizeToTyped(pcmData)": if (isNaN(out.subarray[out.length - 1])) { However this is a bug in so far, that "out.subarray[out.length - 1]" returns an array and is never a Number. So isNaN always is true and the last sample is always removed. The fix for this bug is: Line 378: if (isNaN(out[out.length - 1])) { Now only the last sample is checked and if it is a Number, it will not be removed. Applying this change fixed the problem of the last sample always missing and the size not being a power of 2 for me. With kind regards, Joerg |
Thank you so much for this @JoergHansmann. I've pushed your suggested fix to version 1.0.3. |
Hi! i'm using audioinput in a ionic app for iOS. I'm using it to capture audio from device mic and extract features through meyda library. Meyda library needs a 32 bit array so i might normalize signal. The problem is that after normalize, the sample array length is not a power of two (8192). It's 8191 length.
This is my code:
Any idea of why is the raw data having bad length?
Thanks!
The text was updated successfully, but these errors were encountered: