Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

[WIP] record audio to file #28

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

davidnaas
Copy link
Contributor

@davidnaas davidnaas commented Aug 28, 2016

This pr adds a <Recorder> component used to generate a wav file of what it's wrapping over. It takes two props, isRecording and onRecordStop. The component will start recording as soon as it's created and will stop when isRecording is set to false. The onRecordStop property is a callback function that will be called with the generated blob when the recording stops. It is up to the user to decide what to do with that data. In the demo app, there's an example of how to generate a download link from the blob of audio.

TODO:

  1. Use flow
  2. Render file with offline context and/or get rid of clicks and pop in exported file

@kenwheeler
Copy link
Contributor

Whoah! Nice job. So I think you should be able to do a dual connection. Check out how the Analyser does the scriptProcessor. Make the recorder a component will a callback that wraps the part you want to record, and then you can hook into the UI the same way the Analyser does.

@davidnaas
Copy link
Contributor Author

Thanks! Yeah the wrapping thing might be more in line with the rest of the code base. My thinking was that you never want to record anything but the song itself. But I'll give that a shot!

Another idea would be to use an offline audio context to instantly render an explicit number of bars/loops to a file. Since the whole system currently is deterministic (there's no live input/manipulation, right?) there's really no point in letting it play through in realtime to do it. This would probably also be more performant. I noticed that the current implementation suffers a bit from clicks and pops in the recording which most likely is the processor node failing intermittently due to performance issues and too short buffer length.

@kenwheeler
Copy link
Contributor

Offline would be spectacular, especially with a loop count as a prop.

@davidnaas
Copy link
Contributor Author

Will look into it! Hopefully will have some more time later this week!

@davidnaas
Copy link
Contributor Author

@kenwheeler This is starting to come together! I managed to fix the recorder muting the audio and turned it into a component. I also talked to some web audio peeps and apparently it's not possible to connect a node to two different contexts. So either the "instant" recorder would have to work without the app being playable, or I find a way to duplicate the tree of nodes and connect that copy to the offline context.

@wyhinton
Copy link

Any status update on this? Is there a work around for accessing the audio context and using a different library to do the recording bit?

@carbonrobot
Copy link

@wyhinton Thanks for checking in with us. This project moved to an "Archived" maintenance status 2 years ago, and is no longer maintained by Formidable. We encourage interested developers to fork this project and make it their own!

https://github.com/FormidableLabs/react-music#maintenance-status

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants