voicemeeter-rb/examples/midi/main.rb

32 lines
562 B
Ruby
Raw Normal View History

2023-07-18 07:30:24 +01:00
require_relative "../../lib/voicemeeter"
class Main
GAINLAYER = 0
def initialize(vm)
@vm = vm
@vm.on :midi do
current = @vm.midi.current
handler(current, @vm.midi.get(current))
end
2023-07-18 07:30:24 +01:00
end
def run
puts "press <Enter> to quit"
2023-07-21 09:34:26 +01:00
loop { break if gets.chomp.empty? }
2023-07-18 07:30:24 +01:00
end
def handler(i, val)
if i.between?(0, 7)
@vm.strip[i].gainlayer[GAINLAYER].gain = (val * 72 / 127) - 60
2023-07-18 07:30:24 +01:00
end
end
end
2023-07-21 09:34:26 +01:00
if $PROGRAM_NAME == __FILE__
2023-07-18 07:30:24 +01:00
Voicemeeter::Remote.new(:potato, midi: true).run do |vm|
Main.new(vm).run
end
end