@@ -6,23 +6,23 @@ config.bufferSize = 32 | |||||
function process(block) | function process(block) | ||||
-- Loop through each column | -- Loop through each column | ||||
for i=0,5 do | |||||
for i=1,6 do | |||||
-- Get gain knob | -- Get gain knob | ||||
gain = block.knobs[i] | gain = block.knobs[i] | ||||
-- Set gain light (red = 1) | -- Set gain light (red = 1) | ||||
block.lights[i][0] = gain | |||||
block.lights[i][1] = gain | |||||
-- Check mute switch | -- Check mute switch | ||||
if block.switches[i] then | if block.switches[i] then | ||||
-- Mute output | -- Mute output | ||||
gain = 0 | gain = 0 | ||||
-- Enable mute light (red = 1) | -- Enable mute light (red = 1) | ||||
block.switchLights[i][0] = 1 | |||||
block.switchLights[i][1] = 1 | |||||
else | else | ||||
-- Disable mute light | -- Disable mute light | ||||
block.switchLights[i][0] = 0 | |||||
block.switchLights[i][1] = 0 | |||||
end | end | ||||
-- Iterate input/output buffer | -- Iterate input/output buffer | ||||
for j=0,block.bufferSize-1 do | |||||
for j=1,block.bufferSize do | |||||
-- Get input | -- Get input | ||||
x = block.inputs[i][j] | x = block.inputs[i][j] | ||||
-- Apply gain to input | -- Apply gain to input | ||||
@@ -34,10 +34,10 @@ function process(block) | |||||
h = (1 - i / 6 + phase) % 1 | h = (1 - i / 6 + phase) % 1 | ||||
rgb = hsvToRgb(h, 1, 1) | rgb = hsvToRgb(h, 1, 1) | ||||
for c=1,3 do | for c=1,3 do | ||||
block.lights[i-1][c-1] = rgb[c] | |||||
block.switchLights[i-1][c-1] = rgb[c] | |||||
block.lights[i][c] = rgb[c] | |||||
block.switchLights[i][c] = rgb[c] | |||||
end | end | ||||
block.outputs[i-1][0] = math.sin(2 * math.pi * h) * 5 + 5 | |||||
block.outputs[i][1] = math.sin(2 * math.pi * h) * 5 + 5 | |||||
end | end | ||||
end | end | ||||
@@ -9,10 +9,10 @@ config.bufferSize = 16 | |||||
phase = 0 | phase = 0 | ||||
function process(block) | function process(block) | ||||
-- Knob ranges from -5 to 5 octaves | -- Knob ranges from -5 to 5 octaves | ||||
pitch = block.knobs[0] * 10 - 5 | |||||
pitch = block.knobs[1] * 10 - 5 | |||||
-- Input follows 1V/oct standard | -- Input follows 1V/oct standard | ||||
-- Take the first input's first buffer value | -- Take the first input's first buffer value | ||||
pitch = pitch + block.inputs[0][0] | |||||
pitch = pitch + block.inputs[1][1] | |||||
-- The relationship between 1V/oct pitch and frequency is `freq = 2^pitch`. | -- The relationship between 1V/oct pitch and frequency is `freq = 2^pitch`. | ||||
-- Default frequency is middle C (C4) in Hz. | -- Default frequency is middle C (C4) in Hz. | ||||
@@ -22,13 +22,13 @@ function process(block) | |||||
-- Set all samples in output buffer | -- Set all samples in output buffer | ||||
deltaPhase = config.frameDivider * block.sampleTime * freq | deltaPhase = config.frameDivider * block.sampleTime * freq | ||||
for i=0,block.bufferSize-1 do | |||||
for i=1,block.bufferSize do | |||||
-- Accumulate phase | -- Accumulate phase | ||||
phase = phase + deltaPhase | phase = phase + deltaPhase | ||||
-- Wrap phase around range [0, 1] | -- Wrap phase around range [0, 1] | ||||
phase = phase % 1 | phase = phase % 1 | ||||
-- Convert phase to sine output | -- Convert phase to sine output | ||||
block.outputs[0][i] = math.sin(2 * math.pi * phase) * 5 | |||||
block.outputs[1][i] = math.sin(2 * math.pi * phase) * 5 | |||||
end | end | ||||
end | end |