Permalink
Browse files

Merge pull request #1 from damiencornu/gh-pages

Copy video stream into canvas
  • Loading branch information...
2 parents 6c53a38 + 9190385 commit c41f1466032d1318e619c3a9cce5a6088f2c8583 @mcouzinet committed Jan 9, 2013
Showing with 7 additions and 4 deletions.
  1. +1 −1 index.html
  2. +6 −3 javascripts/main.js
View
@@ -30,8 +30,8 @@ <h2 id="project_tagline">"Parler pour être vu" v0.2</h2>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
+ <video id="camFeed" width="800px" height="600px" autoplay></video>
<canvas id="canvasCarre" width="800px" height="600px"></canvas>
- <video id="camFeed" width="800px" height="600px" autoplay>
</section>
</div>
View
@@ -7,6 +7,7 @@ $(function(){
data,
sum,
x,
+ camFeed,
canvasCarre = $('#canvasCarre'),
tabCarre = new Array(),
max = 2000,
@@ -32,8 +33,8 @@ $(function(){
}
function onStream(stream) {
-
- document.getElementById('camFeed').src = webkitURL.createObjectURL(stream);
+ camFeed = document.getElementById('camFeed');
+ camFeed.src = webkitURL.createObjectURL(stream);
context = new webkitAudioContext();
microphone = context.createMediaStreamSource(stream);
@@ -43,7 +44,7 @@ $(function(){
microphone.connect(analyser);
analyser.connect(jsProcessor);
jsProcessor.connect(context.destination);
- window.setInterval(update, 400);
+ window.setInterval(update, 1000 / 24);
jsProcessor.onaudioprocess = function(e){
data = new Uint8Array(10);
analyser.getByteFrequencyData(data);
@@ -61,6 +62,8 @@ $(function(){
contextCanvas.clearRect(0, 0, 800, 600);
+ contextCanvas.drawImage(camFeed, 0, 0, 800, 600);
+
sum = data[0]+data[1]+data[2]+data[3]+data[4]+data[5]+data[6]+data[7]+data[8]+data[9];
x = 160 * (sum-300) / max;

0 comments on commit c41f146

Please sign in to comment.