From f050c35cc329e6dcdd21b747065205633bb192f6 Mon Sep 17 00:00:00 2001 From: gretchen Date: Sat, 16 Nov 2019 16:08:58 -0800 Subject: Configurable vport --- intervals.lua | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/intervals.lua b/intervals.lua index 2b402d5..cd61424 100644 --- a/intervals.lua +++ b/intervals.lua @@ -491,22 +491,6 @@ function play(note, vel) end function init() - -- initialize midi - -- TODO configure vport - intervals_state.midi_in = midi.connect(1) - intervals_state.midi_in.event = function (a) - b = midi.to_msg(a) - -- monitor - if b.type == "note_on" then - play_start(b.note, b.vel) - end - if b.type == "note_off" or b.vel == 0 then - play_stop(b.note, b.vel) - end - state_call(intervals_state, "midi", {b}) - end - intervals_state.midi_out = midi.connect(2) - -- TODO save params:add({ type = "option", @@ -558,6 +542,35 @@ function init() action = function(value) intervals_state.note_vel = value end}) + params:add({ + type = "control", + id = "midi_in_vport", + name = "Midi in vport", + default=60, + controlspec = ControlSpec.new(1, 4, 'lin', 1, 1), + action = function(value) + intervals_state.midi_in = midi.connect(value) + intervals_state.midi_in.event = function (a) + b = midi.to_msg(a) + -- monitor + if b.type == "note_on" then + play_start(b.note, b.vel) + end + if b.type == "note_off" or b.vel == 0 then + play_stop(b.note, b.vel) + end + state_call(intervals_state, "midi", {b}) + end + end}) + params:add({ + type = "control", + id = "midi_out_vport", + name = "Midi out vport", + default=60, + controlspec = ControlSpec.new(1, 4, 'lin', 1, 2), + action = function(value) + intervals_state.midi_out = midi.connect(value) + end}) params:bang() play(60) -- cgit v1.2.1