diff --git a/README.md b/README.md index bb4a4ca..735b4ad 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,15 @@ The size determines how long the sound will last. Larger circles will sound out There are also a few parameters to adjust under the _KEY 1_ parameters page. Play around with those. +### v1.6.1 + +Minor update to add midi continue support. + +- Added two new params; midi continue device and midi continue mode + - Midi continue device lets you choose which device to listen for "continue" messages from; This allows you to choose a different midi device for "continue" messages than the device you're sending midi out messages to + - Midi continue mode lets you choose if new "continue" messages always start playback or toggle so you can use it as a play/pause button +- Grouped new params in "midi continue" group + ### v1.6 This is a pretty major update under the hood. Because of that I took this as an opportunity to update some of the param IDs. This means that existing PSETs will probably result in unexpected behavior. diff --git a/circles.lua b/circles.lua index dec84f1..1196e01 100644 --- a/circles.lua +++ b/circles.lua @@ -1,5 +1,5 @@ -- oO ( circles ) Oo --- v1.6 @jakecarter +-- v1.6.1 @jakecarter -- llllllll.co/t/22951 -- -- ENC 2 & 3 move cursor @@ -34,10 +34,13 @@ local isRunning = true -- enums local outputs = { audio = 1, midi = 2, crow = 3, crow_jf = 4 } local radius_affects = { release = 1, amp = 2 } +local midi_continue_modes = { always_play = 1, toggle= 2 } local midi_devices local midi_out_device local midi_out_channel +local midi_continue_device +local midi_continue_mode function build_midi_device_list() midi_devices = {} for i = 1,#midi.vports do @@ -100,6 +103,19 @@ function setupParams() action = function() build_scale_notes() end }) + -- midi continue + params:add_group("midi continue", 2) + params:add({type = "option", id = "midi_continue_device", name = "device", + options = midi_devices, default = 1, + action = function(value) + midi_continue_device = midi.connect(value) + end + }) + params:add_option("midi_continue_mode", "mode", { "always play", "toggle" }) + params:set_action("midi_continue_mode", function(value) + midi_continue_mode = value + end) + -- libCircles params:add_option("keep_on_screen", "keep on screen", { "no", "yes" }) params:set_action("keep_on_screen", function(value) @@ -134,6 +150,7 @@ function init() build_midi_device_list() setupParams() + midi_continue_device.event = midi_continue_device_event clock.run(step) end @@ -169,6 +186,18 @@ function clock.transport.stop() isRunning = false end +function midi_continue_device_event(data) + msg = midi.to_msg(data) + + if msg.type == "continue" then + if midi_continue_mode == midi_continue_modes.always_play then + isRunning = true + elseif midi_continue_mode == midi_continue_modes.toggle then + isRunning = not isRunning + end + end +end + function noteForCircle(circle) local noteIndex = math.floor(math_helpers.scale(circle.x, 0, 128, 1, #scale_notes)) local note = scale_notes[noteIndex]