kaliatech / web-audio-recording-tests

Web audio recording tests, particularly for verifying functionality on iOS/Safari.
https://kaliatech.github.io/web-audio-recording-tests/dist/
MIT License
139 stars 34 forks source link

Recording and playing audio at the same time #1

Open efunneko opened 5 years ago

efunneko commented 5 years ago

Hi,

Sorry about raising this as an issue - I am not sure of a better way to ask this question. I am hoping on building a page that can both record and play audio simultaneously - in fact I really want to be able to record the same audio I am playing. I have used your great example code to be able to record audio, but when I attempt to play audio simultaneously, I get pauses and hiccups in both the playing and recording.

You can see this fairly easily by just running your live demo on an iPhone. Make one recording, then start recording again and hit play on the first recording.

I am about to dive much deeper to try other means of playing audio to see if it works better, but I figured I should ask first on off chance that you have done anything like this.

Thanks for what you have already done - it was very useful in getting me over the first hump.

kaliatech commented 5 years ago

I'm glad you've found this repo useful. I also noticed the pops and other weird artifacts at times while simultaneously playing and recording. Although not certain, I believe the issue is related to echoCancellation. One reason for thinking that is that I've never noticed it when using an external microphone.

With that in mind, I recently pushed a few minor fixes to this repo, and while doing so I also added the option on "Test 1" to enable/disable echo cancellation. Testing back-to-back just now on an iPad Pro running iOS 12.1.4, I found that with echoCancellation enabled while playing and recording, poor audio was captured, and with it disabled, the recorded audio was fine. I am still hesitant to say definitely this is the issue though because there's been many times I've thought the issue was solved only to hear it again later.

If anyone decides to research this further, a few things to consider:

kaliatech commented 5 years ago

Independent of this issue specifically, but possibly of use...

I've noticed a lot of people finding this repo helpful. However, I built the client with vue and webpack, and I included all sorts of things not relevant to basic reliable audio recording. So, I published a new repo that uses plain JavaScript and has only basic repeatable recording functionality:

It has echoCancellation set to false by default. You can easily change that and other settings by remixing on glitch here:

efunneko commented 5 years ago

Thanks so much for this Josh. I am going to try it out tonight and see if it works for me.