1,295
edits
| Line 39: | Line 39: | ||
* Solution: if a (non-live) stream feeds into a blocking mixer, then it itself gets blocked. This has the same effect as the entire graph of (non-live) connected streams blocking as a unit. | * Solution: if a (non-live) stream feeds into a blocking mixer, then it itself gets blocked. This has the same effect as the entire graph of (non-live) connected streams blocking as a unit. | ||
== | == <mediaresource> element == | ||
interface HTMLMediaResourceElement { | interface HTMLMediaResourceElement { | ||
| Line 73: | Line 73: | ||
}; | }; | ||
<mediaresource> elements can have <source> children. | |||
Is this needed? Maybe to allow reliable synchronization/easy use of canned samples. | Is this needed? Maybe to allow reliable synchronization/easy use of canned samples. | ||
| Line 169: | Line 169: | ||
1) Play video with processing effect applied to the audio track | 1) Play video with processing effect applied to the audio track | ||
<video src="foo.webm" id="v" controls streamaudio></video> | |||
<audio id="out" autoplay></audio> | |||
<script> | |||
document.getElementById("out").src = | document.getElementById("out").src = | ||
document.getElementById("v").getStream().createProcessor(new Worker("effect.js")); | document.getElementById("v").getStream().createProcessor(new Worker("effect.js")); | ||
</script> | |||
2) Play video with processing effects mixing in out-of-band audio tracks (in sync) | 2) Play video with processing effects mixing in out-of-band audio tracks (in sync) | ||
<video src="foo.webm" id="v" streamaudio></video> | |||
<audio src="back.webm" id="back"></audio> | |||
<audio id="out" autoplay></audio> | |||
<script> | |||
var mixer = document.getElementById("v").getStream().createProcessor(new Worker("audio-ducking.js")); | var mixer = document.getElementById("v").getStream().createProcessor(new Worker("audio-ducking.js")); | ||
mixer.addStream(document.getElementById("back").getStream()); | mixer.addStream(document.getElementById("back").getStream()); | ||
| Line 190: | Line 190: | ||
// We probably need additional API to more conveniently tie together | // We probably need additional API to more conveniently tie together | ||
// the controls for multiple media elements. | // the controls for multiple media elements. | ||
</script> | |||
3) Capture microphone input and stream it out to a peer with a processing effect applied to the audio | 3) Capture microphone input and stream it out to a peer with a processing effect applied to the audio | ||
<script> | |||
navigator.getUserMedia('audio', gotAudio); | navigator.getUserMedia('audio', gotAudio); | ||
function gotAudio(stream) { | function gotAudio(stream) { | ||
peerConnection.addStream(stream.createProcessor(new Worker("effect.js"))); | peerConnection.addStream(stream.createProcessor(new Worker("effect.js"))); | ||
} | } | ||
</script> | |||
4) Capture microphone input and visualize it as it is being streamed out to a peer and recorded | 4) Capture microphone input and visualize it as it is being streamed out to a peer and recorded | ||
<canvas id="c"></canvas> | |||
<script> | |||
navigator.getUserMedia('audio', gotAudio); | navigator.getUserMedia('audio', gotAudio); | ||
var streamRecorder; | var streamRecorder; | ||
| Line 214: | Line 214: | ||
peerConnection.addStream(processed); | peerConnection.addStream(processed); | ||
} | } | ||
</script> | |||
5) Capture microphone input, visualize it, mix in another audio track and stream the result to a peer and record | 5) Capture microphone input, visualize it, mix in another audio track and stream the result to a peer and record | ||
<canvas id="c"></canvas> | |||
<mediaresource src="back.webm" id="back"></mediaresource> | |||
<script> | |||
navigator.getUserMedia('audio', gotAudio); | navigator.getUserMedia('audio', gotAudio); | ||
var streamRecorder; | var streamRecorder; | ||
| Line 233: | Line 233: | ||
peerConnection.addStream(mixer); | peerConnection.addStream(mixer); | ||
} | } | ||
</script> | |||
6) Receive audio streams from peers, mix them with spatialization effects, and play | 6) Receive audio streams from peers, mix them with spatialization effects, and play | ||
<audio id="out" autoplay></audio> | |||
<script> | |||
var worker = new Worker("spatializer.js"); | var worker = new Worker("spatializer.js"); | ||
var spatialized = stream.createProcessor(worker); | var spatialized = stream.createProcessor(worker); | ||
| Line 245: | Line 245: | ||
}; | }; | ||
document.getElementById("out").src = spatialized; | document.getElementById("out").src = spatialized; | ||
</script> | |||
7) Seamlessly chain from the end of one input stream to another | 7) Seamlessly chain from the end of one input stream to another | ||
<mediaresource src="in1.webm" id="in1" preload></mediaresource> | |||
<mediaresource src="in2.webm" id="in2"></mediaresource> | |||
<audio id="out" autoplay></audio> | |||
<script> | |||
var in1 = document.getElementById("in1"); | var in1 = document.getElementById("in1"); | ||
in1.onloadeddata = function() { | in1.onloadeddata = function() { | ||
| Line 260: | Line 260: | ||
document.getElementById("out").src = mixer; | document.getElementById("out").src = mixer; | ||
} | } | ||
</script> | |||
8) Seamlessly switch from one input stream to another, e.g. to implement adaptive streaming | 8) Seamlessly switch from one input stream to another, e.g. to implement adaptive streaming | ||
<mediaresource src="in1.webm" id="in1" preload></mediaresource> | |||
<mediaresource src="in2.webm" id="in2"></mediaresource> | |||
<audio id="out" autoplay></audio> | |||
<script> | |||
var stream1 = document.getElementById("in1").startStream(); | var stream1 = document.getElementById("in1").startStream(); | ||
var mixer = stream1.createProcessor(); | var mixer = stream1.createProcessor(); | ||
| Line 285: | Line 285: | ||
} | } | ||
} | } | ||
</script> | |||
9) Synthesize samples from JS data | 9) Synthesize samples from JS data | ||
<audio id="out" autoplay></audio> | |||
<script> | |||
document.getElementById("out").src = | document.getElementById("out").src = | ||
new StreamProcessor(new Worker("synthesizer.js")); | new StreamProcessor(new Worker("synthesizer.js")); | ||
</script> | |||
10) Trigger a sound sample to be played through the effects graph ASAP but without causing any blocking | 10) Trigger a sound sample to be played through the effects graph ASAP but without causing any blocking | ||
<script> | |||
var effectsMixer = ...; | var effectsMixer = ...; | ||
function playSound(src) { | function playSound(src) { | ||
| Line 306: | Line 306: | ||
} | } | ||
} | } | ||
</script> | |||
edits