Skip to content

Commit

Permalink
add held loop recording to loop-grid (hold loop button while playing)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckegg committed Nov 16, 2017
1 parent aaa0757 commit 31def0b
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 189 deletions.
16 changes: 1 addition & 15 deletions lib/param-looper.js
Expand Up @@ -6,6 +6,7 @@ var computed = require('mutant/computed')

var getEvents = require('lib/get-events')
var ParamSource = require('lib/param-source')
var quantizeDuration = require('lib/quantize-duration')

module.exports = ParamLooper

Expand Down Expand Up @@ -114,18 +115,3 @@ function getLoop (events, startPos, endPos) {

return loop
}

function getGrid (duration) {
if (duration < 0.7) {
return 0.5
} else if (duration < 1.7) {
return 1
} else {
return 2
}
}

function quantizeDuration (value) {
var grid = getGrid(value)
return Math.round(value / grid) * grid
}
16 changes: 16 additions & 0 deletions lib/quantize-duration.js
@@ -0,0 +1,16 @@
module.exports = quantizeDuration

function quantizeDuration (value) {
var grid = getGrid(value)
return Math.round(value / grid) * grid
}

function getGrid (duration) {
if (duration < 0.7) {
return 0.5
} else if (duration < 1.7) {
return 1
} else {
return 2
}
}
17 changes: 17 additions & 0 deletions lib/quantize-to-square.js
@@ -0,0 +1,17 @@
module.exports = function quantizeToSquare (value) {
if (value > 16) {
return Math.floor(value / 16) * 16
} else if (value > 8) {
return Math.floor(value / 8) * 8
} else if (value > 4) {
return Math.floor(value / 4) * 4
} else if (value > 2) {
return Math.floor(value / 2) * 2
} else if (value > 1) {
return Math.floor(value / 1) * 1
} else if (value > 0.5) {
return Math.floor(value / 0.5) * 0.5
} else {
return value
}
}

0 comments on commit 31def0b

Please sign in to comment.