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

No Sound or periodic 'click-click' sound when using web audio option. #102

Open
pgcan opened this issue Sep 23, 2019 · 13 comments
Open

No Sound or periodic 'click-click' sound when using web audio option. #102

pgcan opened this issue Sep 23, 2019 · 13 comments
Labels
bug This is an identified bug that should be fixed. help wanted The great thing about open-source is that everyone can contribute!

Comments

@pgcan
Copy link

pgcan commented Sep 23, 2019

Hi,
Looking at the plugin code and documentation it looks pretty obvious that capturing WebAudio is minutes of task using this plugin but I have been struggling for last 2 days to get this working.

I installed the Demo App and tested "WebAudio" demo but all I hear is a 'click-click' sound every half second. There is no error and all looks pretty working.

I have tested on Android 9.0 and Android 6.0 but same behavior. Not sure what is broken or missed by me.

Is someone else also got the same issue? Please help.

Other details:
Cordova 8.0
Android: 9.0 and 6.0

@pgcan
Copy link
Author

pgcan commented Sep 24, 2019

An update here,
if disabled TypedArrays then it works.

var hasTypedArrays = false;// 'Int16Array' in window && 'Float32Array' in window;

@edimuj
Copy link
Owner

edimuj commented Oct 31, 2019

Thanks @pgcan

I'll look into this as soon as possible.

@taxilian
Copy link
Contributor

That is strange; I actually was having some trouble on android which might be related to this, but ended up just using getUserMedia on android so I didn't worry about it. It was definitely working on iOS.

I can try to look at this a bit later; it could be there is an issue with the way we're initializing the typedarrays or the data isn't getting copied correctly on android.

@pgcan
Copy link
Author

pgcan commented Nov 6, 2019

Another major issue that I found with plugin's WebAudio logic, is that the scheduling of BufferSource is done based on "setTimeOut" in method "_getNextToPlay" however AudioContext has its own timer which is more precise (double) and must be used.

I will create pull request to fix this.

BaseAudioContext

BaseAudioContext.currentTime (Read only)
Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at 0.

@edimuj edimuj added bug This is an identified bug that should be fixed. help wanted The great thing about open-source is that everyone can contribute! labels Nov 27, 2019
@aressler38
Copy link

I just started using this plugin and ran into this same issue. Setting var hasTypedArrays = false; as @pgcan says temporarily fixes the problem.

@edimuj
Copy link
Owner

edimuj commented Dec 18, 2019

@pgcan Have you been able to look into this any more?

@pgcan
Copy link
Author

pgcan commented Dec 18, 2019

We do not use this plugin in our app anymore. So I couldn't get time to look into it. However, if possible then someone can look into changes in method "_playAudio" my repo commit to understand AudioContext scheduling. But I am still hopeful to get time soon.

@iexperto
Copy link

Same problem, var hasTypedArrays = false; fixes the issue. Is any plan to fix this?
In my opinion this should be a setting instead of an "auto-detection"
This change also break the demo in some devices.
https://github.com/edimuj/app-audioinput-demo

@taxilian
Copy link
Contributor

I wrote the original PR to use typedarrays and it seemed to be working, but I ended up switching to use getUserMedia on android so didn't see the issue; unfortunately that makes it harder for me to troubleshoot it.

I'm off my day job for the next week so I'm going to see if I can figure this out, but if anyone currently affected by the issue is available to assist a bit that would be a big help -- email me at taxilian at gmail and we'll work out a more effective / faster communications method.

@taxilian
Copy link
Contributor

okay; I have looked over the code and could only come up with one slightly shot-in-the-dark theory as to what is going on. Would someone please try https://github.com/HamStudy/cordova-plugin-audioinput/tree/try_fix_android and see if it resolves the issue? (I can't repro)

@sertal70
Copy link
Contributor

Hi @taxilian, I tried your fix but it doesn't solve the issue: the recording output contains a periodic "click" only, there is no sound at all. The only way to have it work is to set hasTypedArrays to false: doing so I have sound in the recording output, although the periodic "click" is still present.

@taxilian
Copy link
Contributor

Really really strange; I have no idea why typed arrays would not work on android, but it ... really sucks.

Thanks for testing it =]

@sertal70
Copy link
Contributor

@taxilian you're welcome. I suspect the root cause is not typed arrays implementation itself, because everything is fine if I record using event instead of web audio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is an identified bug that should be fixed. help wanted The great thing about open-source is that everyone can contribute!
Projects
None yet
Development

No branches or pull requests

6 participants