Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated to be slightly more functional

  • Loading branch information...
commit c7dbd449969b8f896a6ab980b9b7357ce87253ea 1 parent d76e3b3
Nikolaj Baer authored
Showing with 19 additions and 9 deletions.
  1. +4 −0 experiments/ytseq/index.html
  2. +15 −9 experiments/ytseq/ytseq.js
4 experiments/ytseq/index.html
View
@@ -9,5 +9,9 @@
<body>
<div id="tubes"></div>
<div id="sequencer"></div>
+ <div id="controsl">
+ <button id="play">PLAY</button>
+ <button id="pause">PAUSE</button>
+ </div>
</body>
</html>
24 experiments/ytseq/ytseq.js
View
@@ -30,9 +30,9 @@ var Sequencer = function(steps,tracks,bpm){
t.ival=null;
}
console.log(t.player);
- //t.player.seekTo(t.start,false);
+ t.player.seekTo(t.start,false);
t.player.playVideo(); // TODO make this play the yt player
- t.ival = setTimeout(function(){ t.pauseVideo(); },t.end - t.start);
+ t.ival = setTimeout(function(){ console.log(t); t.player.pauseVideo(); },(t.end - t.start)*1000);
}
}
this.current_step = (this.current_step + 1)%this.steps;
@@ -45,7 +45,7 @@ var Sequencer = function(steps,tracks,bpm){
}
this.pause = function(){
- if(this.ival){
+ if(this.ival != null){
clearInterval(this.ival);
this.ival = null;
}
@@ -61,7 +61,7 @@ var Sequencer = function(steps,tracks,bpm){
var sequence = [];
for(var j=0;j<this.tracks.length;j++){
var s = [];
- for(var j=0;j<steps;j++){
+ for(var k=0;k<steps;k++){
s.push(randomize?Math.random()>0.5:false);
}
sequence.push(s);
@@ -74,16 +74,19 @@ var Sequencer = function(steps,tracks,bpm){
var sequencer = null;
function onYouTubePlayerAPIReady() {
- sequencer = new Sequencer(16,4,100);
- var tracks = [{name:"cymbal",ytid:"mslT361M6-E",start:0,end:5},
- {name:"guitar",ytid:"ICLkuwWO9tU",start:0,end:1},]
+ sequencer = new Sequencer(8,2,60);
+ var tracks = [{name:"cymbal",ytid:"mv4kBI15cEk",start:44,end:46},
+ {name:"guitar",ytid:"ICLkuwWO9tU",start:2,end:4},]
+
+ var h = window.height;
+ var w = window.width;
// Build samples
for(var i=0;i<tracks.length;i++){
$("#tubes").append('<div id="track_'+i+'"></div>');
var player = new YT.Player('track_'+i, {
- width: 50,
- height: 50,
+ width: w/tracks.length,
+ height: 0.75*w,
videoId: tracks[i].ytid,
playerVars: {'autoplay':false,'controls':0}
});
@@ -91,6 +94,9 @@ function onYouTubePlayerAPIReady() {
}
sequencer.build_sequences(4,true);
//sequencer.play();
+
+ document.getElementById("play").addEventListener("click",function(){ sequencer.play(); });
+ document.getElementById("pause").addEventListener("click",function(){ sequencer.pause(); });
}
Please sign in to comment.
Something went wrong with that request. Please try again.