diff --git a/examples/midi/README.md b/examples/midi/README.md new file mode 100644 index 0000000..ac702bf --- /dev/null +++ b/examples/midi/README.md @@ -0,0 +1,22 @@ +## About/Requirements + +A simple demonstration showing how to use a midi controller with this API. Specifically, this script binds the sliders of a Korg NanoKontrol2 to the 8 input strips of gainlayer 0. + +In order to run this example script you will need to have setup Voicemeeter with a midi device in Menu->Midi Mapping. + +This script was written for and tested with a Korg NanoKontrol2 configured in CC mode. The slider CC numbers were increased by 1, as shown: + +![Image of Korg NanoKontrol2 Software](./img/nanokontrolsoftware.png) + +## Use + +First ensure Voicemeeter Potato version is launched. Then Press SEL for bus0 (A1). + +Move the NanoKontrol2 sliders and watch the strip sliders move. + +## Resources + +If you want to know how to setup the NanoKontrol2 for CC mode check the following resources. + +- [Korg NanoKontrol2 Manual](https://www.korg.com/us/support/download/manual/0/159/1912/) +- [CC Mode Info](https://i.korg.com/uploads/Support/nanoKONTROL2_PG_E1_634479709631760000.pdf) diff --git a/examples/midi/img/nanokontrolsoftware.png b/examples/midi/img/nanokontrolsoftware.png new file mode 100644 index 0000000..7325ce0 Binary files /dev/null and b/examples/midi/img/nanokontrolsoftware.png differ diff --git a/examples/midi/main.rb b/examples/midi/main.rb new file mode 100644 index 0000000..83420e0 --- /dev/null +++ b/examples/midi/main.rb @@ -0,0 +1,35 @@ +require_relative "../../lib/voicemeeter" + +class Main + GAINLAYER = 0 + + def initialize(vm) + @vm = vm + @vm.callback.register(self) + end + + def run + puts "press to quit" + loop { exit if gets.chomp.empty? } + end + + def on_update(event) + if event == "midi" + current = @vm.midi.current + midi_handler(current, @vm.midi.get(current)) + end + end + + def midi_handler(i, val) + if i.between?(1, 8) + @vm.strip[i - 1].gainlayer[GAINLAYER].gain = (val * 72 / 127) - 60 + end + end +end + + +if $0 == __FILE__ + Voicemeeter::Remote.new(:potato, midi: true).run do |vm| + Main.new(vm).run + end +end