Skip to content

Commit

Permalink
Added live input node.
Browse files Browse the repository at this point in the history
  • Loading branch information
cwilso committed Sep 25, 2012
1 parent 85e9478 commit 6a73b08
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
application: webaudioplayground
version: 1
runtime: python
api_version: 1
threadsafe: yes

handlers:
- url: /
static_files: index.html
upload: index.html

- url: /css
static_dir: css

- url: /fonts
static_dir: fonts

- url: /img
static_dir: img

- url: /favicon.ico
static_files: favicon.ico
upload: favicon.ico

- url: /js
static_dir: js

- url: /sounds
static_dir: sounds
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<!--
<li><a href="#">Audio Buffer Source From URL</a></li>
--> <li><a href="#" onclick="createOscillator()">Oscillator</a></li>
<li><a href="#" onclick="createLiveInput()">Live Input</a></li>
</ul>
</div>
</li>
Expand Down
24 changes: 24 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,30 @@ function createGain() {
this.event.preventDefault();
}

function gotStream(stream) {
// Create an AudioNode from the stream.
// realAudioInput = audioContext.createMediaStreamSource(stream);
this.audioNode = audioContext.createMediaStreamSource(stream);
}

function createLiveInput() {
var module = createNewModule( "live input", false, true );

// after adding sliders, walk up to the module to store the audioNode.
module = module.parentNode;

if (!navigator.webkitGetUserMedia)
return(alert("Error: getUserMedia not supported!"));

navigator.webkitGetUserMedia({audio:true}, gotStream.bind(module), function(e) {
alert('Error getting audio');
console.log(e);
});

if (this.event)
this.event.preventDefault();
}

function createDelay() {
var module = createNewModule( "delay", true, true );
addModuleSlider( module, "delay time", 0.2, 0.0, 10.0, 0.01, "sec", onUpdateDelay );
Expand Down

0 comments on commit 6a73b08

Please sign in to comment.