Skip to content

Commit

Permalink
added repeat clause
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriceleal committed Apr 16, 2012
1 parent f7a58ef commit f0dc1ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compiler.js
Expand Up @@ -38,6 +38,9 @@ var endTime = function (time, expr) {


return leftside > rightside ? leftside : rightside; return leftside > rightside ? leftside : rightside;
} }
if(expr.tag == 'repeat'){
return totalDuration(expr.section) * expr.count;
}


// The duration of a seq node is the sum of the durations // The duration of a seq node is the sum of the durations
return totalDuration(expr.left) + totalDuration(expr.right); return totalDuration(expr.left) + totalDuration(expr.right);
Expand Down Expand Up @@ -120,6 +123,15 @@ var compileT = function(expr, time){
dur : expr.dur dur : expr.dur
}); });
} }
if(expr.tag == 'repeat'){
for(var i = 0; i < expr.count; i++){
var rl = compileT(expr.section, time);
time = endTime(expr.section);
rl.forEach(function(val, idx, arr){
ret.push(val);
});
}
}
if(expr.tag == 'par'){ if(expr.tag == 'par'){
// Call on left and right with the same starting time // Call on left and right with the same starting time
var l = compileT(expr.left, time); var l = compileT(expr.left, time);
Expand Down

0 comments on commit f0dc1ed

Please sign in to comment.