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

Recording and playing audio at the same time #1

Open
efunneko opened this issue Mar 11, 2019 · 3 comments
Open

Recording and playing audio at the same time #1

efunneko opened this issue Mar 11, 2019 · 3 comments

Comments

@efunneko
Copy link

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
Copy link
Owner

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:

  • There is some sort of non-obvious state being kept on iOS/Safari with the echoCancellation setting when given in the user media constraints. You can see this with this test client by enabling/disabling echoCancellation and then switching to the Diagnostics page. You'll see the under track[0].settings[echoCancellation] the value reflects the last setting given on Test 1. (The call to getUserMedia on Diagnostics page does not pass an echoCancellation constraint.)
  • I've noticed that changing volume while playing back and recording can break things. I don't know why.
  • Consider that if the issue really is echo cancellation, then the volume of playback can each affect the final result.
  • While developing, there have been times where recorded audio was poor, I force quit safari, and then audio was good again.

@kaliatech
Copy link
Owner

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
Copy link
Author

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

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