Skip to content
Permalink
Browse files

add hold modulator

  • Loading branch information...
mmckegg committed Apr 24, 2017
1 parent b749836 commit 559077259cd568f81b6c7013a4d49d00ec876708
Showing with 63 additions and 1 deletion.
  1. +25 −1 lib/params/mod-range.js
  2. +4 −0 nodes/hold/index.js
  3. +34 −0 nodes/hold/object.js
@@ -57,7 +57,13 @@ module.exports = function render (param, options) {
interpolate: isExpFormat(options.format) ? 'exp' : 'linear'
},
action: Value(wrap)
}, 'Trigger Random')
}, 'Trigger Random'),
h('option', {
rawValue: {
node: 'modulator/hold'
},
action: Value(wrap)
}, 'Trigger Hold')
)
}

@@ -206,6 +212,8 @@ function getSubEditors (param, options) {
return Quantize(item, options)
} else if (nodeType === 'modulator/random') {
return Random(item, options)
} else if (nodeType === 'modulator/hold') {
return Hold(item, options)
} else if (nodeType === 'modulator/adsr') {
return ADSR(item, options)
}
@@ -297,6 +305,22 @@ function Random (node, options) {
])
}

function Hold (node, options) {
return h('div', [
LinkableRange(node.attack, {
flex: true,
defaultValue: 0,
title: 'hold attack',
format: 'ms'
}),

h('button.remove Button -warn', {
title: 'Remove',
'ev-click': send(remove, node)
}, 'X')
])
}

function LFO (node, options) {
var adding = computed(node.mode, v => v === 'add')

@@ -0,0 +1,4 @@
module.exports = {
node: 'modulator/hold',
object: require('./object')
}
@@ -0,0 +1,34 @@
var ParamSource = require('lib/param-source')
var Param = require('lib/param')
var ObservStruct = require('mutant/struct')
var resolve = require('mutant/resolve')

module.exports = HoldModulator

function HoldModulator (context) {
var obs = ObservStruct({
attack: Param(context, 0),
value: Param(context, 0)
})

obs.context = context
obs.currentValue = ParamSource(context, 0)

obs.triggerOn = function (at) {
var value = obs.value.getValueAtTime(at)
var attackTime = obs.attack.getValueAtTime(at)
if (attackTime) {
obs.currentValue.cancelScheduledValues(at)
obs.currentValue.setTargetAtTime(value, at, attackTime / 8)
} else {
obs.currentValue.setValueAtTime(value, at)
}
Param.triggerOn(obs, at)
}

obs.triggerOff = function (at) {
Param.triggerOff(obs, at)
}

return obs
}

0 comments on commit 5590772

Please sign in to comment.
You can’t perform that action at this time.