Module: OSCAccess::Accessible
- Defined in:
- lib/osc-access/accessible.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#osc_input(*args) ⇒ Object
osc_input takes arguments as such:.
- #osc_join(options = {}) ⇒ Object
- #osc_load_map(map) ⇒ Object
-
#osc_output(pair) ⇒ Object
osc_output takes arguments as such:.
- #osc_receive(pattern, options = {}, &block) ⇒ Object
- #osc_send(*a) ⇒ Object
- #osc_send_all_properties ⇒ Object
- #osc_send_property(prop) ⇒ Object
- #osc_start(options = {}) ⇒ Object
- #osc_translate(value, range, options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/osc-access/accessible.rb', line 6 def self.included(base) base.extend(Class) end |
Instance Method Details
#osc_input(*args) ⇒ Object
osc_input takes arguments as such:
osc_input(8000) osc_input(:port => 8000) osc_input(8000, 8005, 8010) osc_input(8000..8010)
59 60 61 62 63 |
# File 'lib/osc-access/accessible.rb', line 59 def osc_input(*args) osc_initialize ports = osc_process_ports_args(args) ports.each { |port| @osc_receiver.add_server(port) } end |
#osc_join(options = {}) ⇒ Object
35 36 37 38 |
# File 'lib/osc-access/accessible.rb', line 35 def osc_join( = {}) osc_initialize @osc_receiver.join() end |
#osc_load_map(map) ⇒ Object
86 87 88 89 |
# File 'lib/osc-access/accessible.rb', line 86 def osc_load_map(map) osc_initialize map.each { |attr, mapping| osc_add_map_row(attr, mapping) } end |
#osc_output(pair) ⇒ Object
osc_output takes arguments as such:
osc_output(:host => "localhost", :port => 9000) osc_output(:host => "localhost", :port => [9000, 9002, 9005]) osc_output(:host => "localhost", :port => 9000..9010)
46 47 48 49 50 |
# File 'lib/osc-access/accessible.rb', line 46 def osc_output(pair) osc_initialize ports = osc_process_ports_args(pair[:port]) ports.each { |port| @osc_emitter.add_client(pair[:host], port) } end |
#osc_receive(pattern, options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/osc-access/accessible.rb', line 10 def osc_receive(pattern, = {}, &block) osc_initialize @osc_receiver.add_receiver(self, pattern, , &block) if ![:accessor].nil? @osc_properties << EmittableProperty.new([:accessor], pattern, ) elsif ![:initialize].nil? @osc_properties << EmittableProperty.new([:initialize], pattern, ) end end |
#osc_send(*a) ⇒ Object
30 31 32 33 |
# File 'lib/osc-access/accessible.rb', line 30 def osc_send(*a) osc_initialize a.first.kind_of?(Symbol) ? osc_send_property(a.first) : @osc_emitter.transmit(*a) end |
#osc_send_all_properties ⇒ Object
81 82 83 84 |
# File 'lib/osc-access/accessible.rb', line 81 def osc_send_all_properties osc_initialize @osc_properties.each { |prop| osc_send_property(prop) } end |
#osc_send_property(prop) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/osc-access/accessible.rb', line 20 def osc_send_property(prop) prop = @osc_properties.find { |ep| ep.subject == prop } if prop.kind_of?(Symbol) val = prop.translated(self) msg = OSC::Message.new(prop.pattern, *val) @osc_emitter.transmit(msg) local_msg = OSC::Message.new(prop.pattern, *prop.value(self)) local_val = osc_process_arg_option(local_msg, :arg => prop.arg) prop.action.call(self, local_val, local_msg) unless prop.action.nil? end |
#osc_start(options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/osc-access/accessible.rb', line 65 def osc_start( = {}) osc_initialize() osc_initialize_from_class_def osc_load_map([:map]) unless [:map].nil? osc_input([:input_port]) unless [:input_port].nil? osc_output([:output]) unless [:output].nil? Thread.new do sleep(1) osc_send_all_properties end @osc_receiver.threads.first || Thread.new { Thread.abort_on_exception = true; loop {} } end |
#osc_translate(value, range, options = {}) ⇒ Object
91 92 93 |
# File 'lib/osc-access/accessible.rb', line 91 def osc_translate(value, range, = {}) Translate.using(value, range, ) end |