Class: Scruby::Bus
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#main_bus ⇒ Object
readonly
Returns the value of attribute main_bus.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Class Method Summary collapse
Instance Method Summary collapse
- #audio_out? ⇒ Boolean
- #fill(value, channels = @channels) ⇒ Object
- #free ⇒ Object
- #index ⇒ Object
-
#initialize(server, rate, channels = 1, main_bus = self, hardware_out = false) ⇒ Bus
constructor
A new instance of Bus.
-
#set(*args) ⇒ Object
Messaging.
- #to_map ⇒ Object
Constructor Details
#initialize(server, rate, channels = 1, main_bus = self, hardware_out = false) ⇒ Bus
Returns a new instance of Bus.
6 7 8 |
# File 'lib/scruby/bus.rb', line 6 def initialize server, rate, channels = 1, main_bus = self, hardware_out = false @server, @rate, @channels, @main_bus, @hardware_out = server, rate, channels, main_bus, hardware_out end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
4 5 6 |
# File 'lib/scruby/bus.rb', line 4 def channels @channels end |
#main_bus ⇒ Object (readonly)
Returns the value of attribute main_bus.
4 5 6 |
# File 'lib/scruby/bus.rb', line 4 def main_bus @main_bus end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
4 5 6 |
# File 'lib/scruby/bus.rb', line 4 def rate @rate end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
4 5 6 |
# File 'lib/scruby/bus.rb', line 4 def server @server end |
Class Method Details
.audio(server, channels = 1) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/scruby/bus.rb', line 58 def audio server, channels = 1 buses = [new(server, :audio, channels)] buses.push new(server, :audio, channels, buses.first) while buses.size < channels server.allocate :audio_buses, buses buses.first end |
.control(server, channels = 1) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/scruby/bus.rb', line 51 def control server, channels = 1 buses = [new(server, :control, channels)] buses.push new(server, :control, channels, buses.first) while buses.size < channels server.allocate :control_buses, buses buses.first end |
Instance Method Details
#audio_out? ⇒ Boolean
24 25 26 |
# File 'lib/scruby/bus.rb', line 24 def audio_out? index < @server.instance_variable_get(:@opts)[:audio_outputs] end |
#fill(value, channels = @channels) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/scruby/bus.rb', line 41 def fill value, channels = @channels if channels > @channels warn "You tried to set #{ channels } values for bus #{ index } that only has #{ @channels } channels, extra values are ignored." end @server.send '/c_fill', index, channels.min(@channels), value end |
#free ⇒ Object
14 15 16 17 |
# File 'lib/scruby/bus.rb', line 14 def free @index = nil @server.__send__("#{ @rate }_buses").delete(self) end |
#index ⇒ Object
10 11 12 |
# File 'lib/scruby/bus.rb', line 10 def index @index ||= @server.__send__("#{ @rate }_buses").index(self) end |
#set(*args) ⇒ Object
Messaging
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scruby/bus.rb', line 29 def set *args args.flatten! = [] (index...channels).to_a.zip(args) do |chan, val| .push(chan).push(val) if chan and val end if args.size > channels warn "You tried to set #{ args.size } values for bus #{ index } that only has #{ channels } channels, extra values are ignored." end @server.send '/c_set', * end |