mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-21 17:30:49 +00:00
midi example added
This commit is contained in:
parent
0980cebffe
commit
fdac727ee7
22
examples/midi/README.md
Normal file
22
examples/midi/README.md
Normal 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)
|
BIN
examples/midi/img/nanokontrolsoftware.png
Normal file
BIN
examples/midi/img/nanokontrolsoftware.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
35
examples/midi/main.rb
Normal file
35
examples/midi/main.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user