midi example added

This commit is contained in:
onyx-and-iris 2023-07-18 07:30:24 +01:00
parent 0980cebffe
commit fdac727ee7
3 changed files with 57 additions and 0 deletions

22
examples/midi/README.md Normal file
View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

35
examples/midi/main.rb Normal file
View File

@ -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 <Enter> 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