Comments (6)
And here is a working example of recording audio from masterGain
https://jsfiddle.net/chadananda/2yo93v04/
// ** Successful example of capturing Musquito output to mediaRecorder
const audioURL = 'https://cdn.glitch.com/02dcea11-9bd2-4462-ac38-eeb6a5ad9530%2F331_full_beautiful-minds_0171_preview.mp3'
// example of recording one sound looping for 3 seconds
let sound = $buzz({ src: audioURL, onerror: (err) => console.log('Error', err), volume:0.05 })
// connect MediaStreamDestination to Howler.masterGain
let streamDest = $buzz.context().createMediaStreamDestination()
$buzz.masterGain().connect(streamDest)
// set up media recorder to record output
let chunks = []
let mediaRecorder = new MediaRecorder(streamDest.stream, {mimeType: 'audio/webm'})
mediaRecorder.onstart = ()=>{ console.log('Started recording Musquito output...') }
mediaRecorder.ondataavailable = (e)=>{ chunks.push(e.data) }
mediaRecorder.onstop = ()=>{
console.log("Done recording. Now let's try playback...")
let fileReader = new FileReader() // to convert blob to data url
fileReader.onload = (e)=>{
$buzz({ src: e.target.result, format: "webm",
onerror: (err) => console.log('Error', err) }).play()
}
fileReader.readAsDataURL(new Blob(chunks)) // sends url to onLoad
}
// start sound and recording
sound.play(); mediaRecorder.start()
// stop in a few seconds
setTimeout( ()=>{ mediaRecorder.stop(); sound.stop() }, 5000)
from musquito.
Currently musquito doesn't support this directly. I googled and see there is a library called Recorderjs that might help. https://stackoverflow.com/questions/14418530/record-sounds-from-audiocontext-web-audio-api
I'll check that library out and update you how we can use it with musquito for recording.
from musquito.
I'm not asking about recording from a microphone, but recording the Musquito output.
from musquito.
The RecorderJs library is used to record the output from any Web Audio Node.
var rec = new Recorder(source [, config]);
rec.record()
rec.stop()
I haven't tried the library yet but I believe you should be passing the audio context destination as the source to the Recorder.
https://github.com/mattdiamond/Recorderjs
In musquito, you could retrieve the audio context from the engine class and pass the respective node to Recorder. Let me know if there is any challenge in doing so.
from musquito.
Oh, I see. That makes sense. Thanks.
Now with Howler, there is a Howler.masterGain
which everything goes through to allow for a global volume control. One can plug in RecorderJs or MediaRecorder to that in order to record all output.
Is there an equivalent single source point for Musquito output?
Here's a wired up example with Howler demonstrating hooking into masterGain
: https://jsfiddle.net/chadananda/kvzrsx5t/
from musquito.
I've added the method to $buzz
to expose the master gain node.
// To get Audio Context
var context = $buzz.context();
// To get master gain node
var masterGain = $buzz.masterGain();
It's available in version 1.1.3 in npm. Let me know if you need more help.
from musquito.
Related Issues (15)
- How to amplify a low volume sound? HOT 2
- If URL doesn't have .mp3 console will throw error HOT 8
- loading songs into a playlist HOT 3
- How to change sprite/sound done event to support callbacks? HOT 2
- Random error: Cannot read property 'allocated' of undefined HOT 4
- Preloading a bunch of files?
- Google Chrome 70 HOT 3
- How to play sounds from imported source when run locally? HOT 5
- Has issues streaming, but not preloading HOT 3
- Event handlers never get fired HOT 4
- Cannot get Musquito to accept a data URI HOT 4
- Percent Loaded HOT 2
- Not working in Vue Project HOT 6
- I tired the percent loaded but I get errors HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from musquito.