mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-25 11:20:48 +00:00
recorder implemented
This commit is contained in:
parent
b047d6c706
commit
ecdf9fa4cc
@ -54,5 +54,12 @@ module Voicemeeter
|
||||
define_singleton_method("#{param}=") { |value| setter(param, value) }
|
||||
end
|
||||
end
|
||||
|
||||
# methods for performing certain actions as opposed to setting values
|
||||
def make_action_method(*params)
|
||||
params.each do |param|
|
||||
define_singleton_method(param) { setter(param, 1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
93
lib/voicemeeter/recorder.rb
Normal file
93
lib/voicemeeter/recorder.rb
Normal file
@ -0,0 +1,93 @@
|
||||
require_relative "iremote"
|
||||
require_relative "meta"
|
||||
require_relative "mixins"
|
||||
require_relative "errors"
|
||||
|
||||
require "date"
|
||||
require "easy_logging"
|
||||
|
||||
module Voicemeeter
|
||||
module Recorder
|
||||
module FileTypeEnum
|
||||
WAV = 1
|
||||
AIFF = 2
|
||||
BWF = 3
|
||||
MP3 = 100
|
||||
end
|
||||
|
||||
class Recorder < IRemote
|
||||
include EasyLogging
|
||||
include Mixins::Outputs
|
||||
|
||||
attr_reader :mode, :armstrip, :armbus
|
||||
|
||||
def initialize(remote)
|
||||
super
|
||||
make_action_method :play, :stop, :pause, :replay, :record, :ff, :rew
|
||||
make_accessor_int :bitresolution, :channel, :kbps
|
||||
make_accessor_float :gain
|
||||
|
||||
@mode = RecorderMode.new(self)
|
||||
@armstrip = (0...remote.kind.num_strip).map { |j| RecorderArmStrip.new(remote, j) }
|
||||
@armbus = (0...remote.kind.num_bus).map { |j| RecorderArmBus.new(remote, j) }
|
||||
end
|
||||
|
||||
def identifier
|
||||
:recorder
|
||||
end
|
||||
|
||||
def load(filepath)
|
||||
setter("load", filepath)
|
||||
end
|
||||
|
||||
def goto(timestr)
|
||||
if !(timestr =~ /^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/)
|
||||
logger.error("goto got: '#{timestr}', but expects a time string in the format 'hh:mm:ss'")
|
||||
return
|
||||
end
|
||||
dt = DateTime.parse(timestr)
|
||||
seconds = dt.hour * 3600 + dt.min * 60 + dt.second
|
||||
setter("goto", seconds)
|
||||
end
|
||||
|
||||
def filetype(val)
|
||||
opts = {wav: FileTypeEnum::WAV, aiff: FileTypeEnum::AIFF, bwf: FileTypeEnum::BWF, mp3: FileTypeEnum::MP3}
|
||||
setter("filetype", opts[val])
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderMode < IRemote
|
||||
def initialize(remote)
|
||||
super
|
||||
make_accessor_bool :recbus, :playonload, :loop, :multitrack
|
||||
end
|
||||
|
||||
def identifier
|
||||
"recorder.mode"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderArmChannel < IRemote
|
||||
def initialize(remote, j)
|
||||
super(remote)
|
||||
@j = j
|
||||
end
|
||||
|
||||
def set
|
||||
setter("", val && 1 || 0)
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderArmStrip < RecorderArmChannel
|
||||
def identifier
|
||||
"recorder.armstrip[#{@j}]"
|
||||
end
|
||||
end
|
||||
|
||||
class RecorderArmBus < RecorderArmChannel
|
||||
def identifier
|
||||
"recorder.armbus[#{@j}]"
|
||||
end
|
||||
end
|
||||
end
|
@ -5,6 +5,7 @@ require_relative "strip"
|
||||
require_relative "bus"
|
||||
require_relative "button"
|
||||
require_relative "vban"
|
||||
require_relative "recorder"
|
||||
require_relative "configs"
|
||||
|
||||
module Voicemeeter
|
||||
@ -12,7 +13,7 @@ module Voicemeeter
|
||||
private
|
||||
|
||||
class Remote < Base
|
||||
attr_reader :strip, :bus, :button, :vban
|
||||
attr_reader :strip, :bus, :button, :vban, :recorder
|
||||
|
||||
def initialize(kind, **kwargs)
|
||||
super
|
||||
@ -20,6 +21,7 @@ module Voicemeeter
|
||||
@bus = (0...kind.num_bus).map { |i| Bus::Bus.make(self, i) }
|
||||
@button = (0...kind.num_buttons).map { |i| Button::Button.new(self, i) }
|
||||
@vban = Vban::Vban.new(self)
|
||||
@recorder = Recorder::Recorder.new(self)
|
||||
end
|
||||
|
||||
def configs
|
||||
|
Loading…
Reference in New Issue
Block a user