Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

/vt/ is now archived.Become a Patron!

/g/ - Technology

Search:


View post   

[ Toggle deleted replies ]
>> No.70853712 [View]
File: 20 KB, 500x315, Slash.jpg [View same] [iqdb] [saucenao] [google] [report]
70853712

>>70853658
I'm creating a stopwatch that stops after hearing a clap. My first function with the stopwatch object should call the second function, draw, and return once the volume gets higher than a certain threshold. But it doesn't seem to return and stop the stopwatch after a clap. Can anyone tell what I'm doing wrong in my code? I hope it's really obvious.


function callStopwatch() {
var watch = new Stopwatch(timer);
watch.start();
if(draw()){
watch.stop();
}
}

function draw() {
let flag = false;
var vol = mic.getLevel();
if(vol > 0.2){
console.log("true"); //created to check whether sound detection is working
flag = true;
}
return flag;
}

>> No.43656442 [View]
File: 25 KB, 500x315, Slash.jpg [View same] [iqdb] [saucenao] [google] [report]
43656442

>Implying the only input my father had in me building my PC wasn't, "You're wasting your time and money, son. Go study!"



Navigation
View posts [+24] [+48] [+96]