osc 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +23 -0
- data/README.en +23 -0
- data/lib/osc.rb +377 -0
- data/sample/dumbserver.rb +21 -0
- data/sample/getmjd.ens +0 -0
- data/sample/getmjd.mxt +59 -0
- data/sample/getmjd.pd +38 -0
- data/sample/getmjd.rb +41 -0
- data/sample/joy-test.rb +43 -0
- data/sample/joy.ens +0 -0
- data/sample/joy.pd +676 -0
- data/sample/joy.rb +78 -0
- data/sample/localtest.rb +29 -0
- data/sample/send.rb +53 -0
- metadata +75 -0
data/sample/joy.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
# joy.rb: Written by Tadayoshi Funaba 2005
|
4
|
+
# $Id: joy.rb,v 1.2 2005-08-06 15:28:49+09 tadf Exp $
|
5
|
+
|
6
|
+
require 'osc'
|
7
|
+
require 'Win32API'
|
8
|
+
require 'gopt'
|
9
|
+
include OSC
|
10
|
+
|
11
|
+
module OSC
|
12
|
+
|
13
|
+
class WinMM < Win32API
|
14
|
+
|
15
|
+
def initialize(proc, import, export)
|
16
|
+
super('winmm', proc, import, export)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
module DevJoy
|
22
|
+
|
23
|
+
@@GetNumDevs = WinMM.new('joyGetNumDevs', %w(), 'l')
|
24
|
+
@@GetDevCaps = WinMM.new('joyGetDevCaps', %w(l p l), 'l')
|
25
|
+
@@GetPos = WinMM.new('joyGetPos', %w(l p), 'l')
|
26
|
+
|
27
|
+
def getnumdev() @@GetNumDevs.call end
|
28
|
+
|
29
|
+
def getdevcaps(did)
|
30
|
+
caps = "\000" * 404
|
31
|
+
@@GetDevCaps.call(did, caps, caps.size)
|
32
|
+
caps.unpack('S2Z32I19Z32Z260')
|
33
|
+
end
|
34
|
+
|
35
|
+
def getpos(did)
|
36
|
+
info = "\000" * 16
|
37
|
+
@@GetPos.call(did, info)
|
38
|
+
info.unpack('I4')
|
39
|
+
end
|
40
|
+
|
41
|
+
module_function :getnumdev, :getdevcaps, :getpos
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def usage
|
48
|
+
warn 'usage: joy [-h rhost] [-p rport]'
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
|
52
|
+
usage unless opt = Gopt.gopt('h:p:d:')
|
53
|
+
|
54
|
+
rhost = (opt[:h] || 'localhost')
|
55
|
+
rport = (opt[:p] || '10000').to_i
|
56
|
+
num = (opt[:d] || '0').to_i
|
57
|
+
|
58
|
+
sc = SimpleClient.new(rhost, rport)
|
59
|
+
|
60
|
+
loop do
|
61
|
+
x, y, z, b = OSC::DevJoy.getpos(num)
|
62
|
+
sc.send(Message.new('/joy/pos', 'f'*3,
|
63
|
+
x - (2**15-1),
|
64
|
+
y - (2**15-1),
|
65
|
+
z - (2**15-1)))
|
66
|
+
sc.send(Message.new('/joy/buttons', 'f'*10,
|
67
|
+
(b >> 0) & 1,
|
68
|
+
(b >> 1) & 1,
|
69
|
+
(b >> 2) & 1,
|
70
|
+
(b >> 3) & 1,
|
71
|
+
(b >> 4) & 1,
|
72
|
+
(b >> 5) & 1,
|
73
|
+
(b >> 6) & 1,
|
74
|
+
(b >> 7) & 1,
|
75
|
+
(b >> 8) & 1,
|
76
|
+
(b >> 9) & 1))
|
77
|
+
sleep 0.01
|
78
|
+
end
|
data/sample/localtest.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# localtest.rb: Written by Tadayoshi Funaba 2005,2006
|
2
|
+
# $Id: localtest.rb,v 1.4 2006-11-10 21:54:30+09 tadf Exp $
|
3
|
+
|
4
|
+
require 'osc'
|
5
|
+
include OSC
|
6
|
+
|
7
|
+
PORT = 10000
|
8
|
+
|
9
|
+
th = Thread.fork do
|
10
|
+
ss = SimpleServer.new(PORT)
|
11
|
+
ss.add_method('/foo/*') do |mesg|
|
12
|
+
p [mesg.address, mesg.to_a]
|
13
|
+
exit if mesg.address =~ /\/kill\z/
|
14
|
+
end
|
15
|
+
ss.run
|
16
|
+
end
|
17
|
+
|
18
|
+
sc = SimpleClient.new('localhost', PORT)
|
19
|
+
|
20
|
+
xs = []
|
21
|
+
xs << Bundle.new(Time.now + 10, Message.new('/foo/kill'))
|
22
|
+
xs << Bundle.new(Time.now + 5, Message.new('/foo/more'))
|
23
|
+
xs << Message.new('/foo/bar', nil, 1, 3.14, 'rikyu')
|
24
|
+
xs << Message.new('/foo/bar', nil, -2, 1.44, 'basho')
|
25
|
+
xs.each do |x|
|
26
|
+
sc.send(x)
|
27
|
+
end
|
28
|
+
|
29
|
+
th.join
|
data/sample/send.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# send.rb: Written by Tadayoshi Funaba 2005,2006
|
2
|
+
# $Id: send.rb,v 1.3 2006-11-12 23:37:17+09 tadf Exp $
|
3
|
+
|
4
|
+
require 'osc'
|
5
|
+
require 'readline'
|
6
|
+
require 'gopt'
|
7
|
+
include OSC
|
8
|
+
|
9
|
+
def usage
|
10
|
+
warn 'usage: send [-h rhost] [-p rport]'
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
usage unless opt = Gopt.gopt('h:p:')
|
15
|
+
|
16
|
+
rhost = (opt[:h] || 'localhost')
|
17
|
+
rport = (opt[:p] || '10000').to_i
|
18
|
+
|
19
|
+
sc = SimpleClient.new(rhost, rport)
|
20
|
+
|
21
|
+
loop do
|
22
|
+
begin
|
23
|
+
mesg = Readline.readline('? ', true)
|
24
|
+
break if mesg == nil || mesg == '.'
|
25
|
+
args = mesg.split
|
26
|
+
address = args.shift
|
27
|
+
if args[0] && args[0][0] == ?,
|
28
|
+
tags = args.shift[1..-1]
|
29
|
+
end
|
30
|
+
args.each_with_index do |arg, i|
|
31
|
+
if tags && tags[i]
|
32
|
+
case tags[i,1]
|
33
|
+
when 'i'; args[i] = OSCInt32.new(arg.to_i)
|
34
|
+
when 'f'; args[i] = OSCFloat32.new(arg.to_f)
|
35
|
+
when 's'; args[i] = OSCString.new(arg)
|
36
|
+
when 'b'; args[i] = OSCBlob.new(arg)
|
37
|
+
else; raise ArgumentError, 'unknown type'
|
38
|
+
end
|
39
|
+
else
|
40
|
+
case arg
|
41
|
+
when /\A[-+]?\d+\z/; args[i] = OSCInt32.new(arg.to_i)
|
42
|
+
when /\A[-+]?\d+\./; args[i] = OSCFloat32.new(arg.to_f)
|
43
|
+
else; args[i] = OSCString.new(arg)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
if address
|
48
|
+
sc.send(Message.new(address, nil, *args))
|
49
|
+
end
|
50
|
+
rescue
|
51
|
+
warn $!
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tadayoshi Funaba
|
8
|
+
autorequire: osc
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-12 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: gopt
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: tadf@funaba.org
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- README
|
35
|
+
- README.en
|
36
|
+
- lib/osc.rb
|
37
|
+
- sample/dumbserver.rb
|
38
|
+
- sample/getmjd.ens
|
39
|
+
- sample/getmjd.mxt
|
40
|
+
- sample/getmjd.pd
|
41
|
+
- sample/getmjd.rb
|
42
|
+
- sample/joy-test.rb
|
43
|
+
- sample/joy.ens
|
44
|
+
- sample/joy.pd
|
45
|
+
- sample/joy.rb
|
46
|
+
- sample/localtest.rb
|
47
|
+
- sample/send.rb
|
48
|
+
has_rdoc: false
|
49
|
+
homepage: http://www.funaba.org/en/ruby.html
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: tadf
|
70
|
+
rubygems_version: 1.3.1
|
71
|
+
signing_key:
|
72
|
+
specification_version: 2
|
73
|
+
summary: OSC is an "OpenSound Control" module for an object-oriented scripting language Ruby.
|
74
|
+
test_files: []
|
75
|
+
|