-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from monome/snippets
Snippets & Public
- Loading branch information
Showing
33 changed files
with
1,304 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- boolean logic | ||
-- output logic transfer functions are dynamically selected per channel | ||
-- a state change on any input triggers update of all outputs | ||
|
||
-- enumeration of the fnlist. least to most density of transfer | ||
fenum = {'~|','>','<','&','~^','^','~&','<=','>=','|'} | ||
|
||
public.add('f1','&',fenum) | ||
public.add('f2','|',fenum) | ||
public.add('f3','^',fenum) | ||
public.add('f4','~^',fenum) | ||
|
||
-- all the dynamic transfer fns between 2 inputs (ordering doesn't matter) | ||
fnlist = | ||
{ '~|' = function(a,b) return not (a or b) end | ||
, '>' = function(a,b) return a>b end | ||
, '<' = function(a,b) return a<b end | ||
, '&' = function(a,b) return (a and b) end | ||
, '~^' = function(a,b) return a==b end | ||
, '^' = function(a,b) return a~=b end | ||
, '~&' = function(a,b) return not (a and b) end | ||
, '<=' = function(a,b) return a<=b end | ||
, '>=' = function(a,b) return a>=b end | ||
, '|' = function(a,b) return (a or b) end | ||
} | ||
|
||
function q(n) return input[n].volts > 1.0 end | ||
function apply() | ||
local a, b = q(1), q(2) | ||
output[1].volts = fnlist[public.f1](a, b) | ||
output[2].volts = fnlist[public.f2](a, b) | ||
output[3].volts = fnlist[public.f3](a, b) | ||
output[4].volts = fnlist[public.f4](a, b) | ||
end | ||
|
||
function init() | ||
for n=1,2 do | ||
input[n].mode('change') | ||
input[n].change = apply -- update all outs on any state change | ||
end | ||
apply() -- initialize to current state | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,43 @@ | ||
--- control voltage delay | ||
-- input1: CV to delay | ||
-- input2: 0v = capture, 5v = loop | ||
-- input2: 0v = capture, 5v = loop (continuous) | ||
-- output1-4: delay equaly spaced delay taps | ||
|
||
LENGTH = 100 -- sets loop time | ||
-- closer to LENGTH is shorter, closer to 0 is longer | ||
taps = { 1 | ||
, 26 | ||
, 51 | ||
, 76 | ||
} | ||
LENGTH = 1000 -- max loop time. MUST BE CONSTANT | ||
|
||
public.add('tap1', 250, {1,LENGTH,'slider'}) | ||
public.add('tap2', 500, {1,LENGTH,'slider'}) | ||
public.add('tap3', 750, {1,LENGTH,'slider'}) | ||
public.add('tap4', LENGTH, {1,LENGTH,'slider'}) | ||
public.add('loop', 0.0, {0,1,'slider'}) | ||
|
||
--private vars | ||
bucket = {} | ||
write = 1 | ||
cv_mode = 0 | ||
|
||
function init() | ||
input[1].mode( 'stream', 0.01 ) -- 100Hz fastest stable | ||
for n=1,4 do output[n].slew = 0.01 end | ||
for n=1,LENGTH do bucket[n] = 0 end | ||
input[1].mode('stream', 0.001) -- 1kHz | ||
for n=1,4 do output[n].slew = 0.002 end -- smoothing at nyquist | ||
for n=1,LENGTH do bucket[n] = 0 end -- clear the buffer | ||
end | ||
|
||
input[1].stream = function(v) | ||
c = input[2].volts / 4.5 | ||
function peek(tap) | ||
local ix = (math.floor(write - tap - 1) % LENGTH) + 1 | ||
return bucket[ix] | ||
end | ||
|
||
function poke(v, ix) | ||
local c = (input[2].volts / 4.5) + public.loop | ||
c = (c < 0) and 0 or c | ||
c = (c > 1) and 1 or c | ||
bucket[write] = v + c*(bucket[write] - v) | ||
bucket[ix] = v + c*(bucket[ix] - v) | ||
end | ||
|
||
input[1].stream = function(v) | ||
output[1].volts = peek(public.tap1) | ||
output[2].volts = peek(public.tap2) | ||
output[3].volts = peek(public.tap3) | ||
output[4].volts = peek(public.tap4) | ||
poke(v, write) | ||
write = (write % LENGTH) + 1 | ||
for n=1,4 do | ||
taps[n] = (taps[n] % LENGTH) + 1 | ||
output[n].volts = bucket[math.floor(taps[n])] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.