fast_osc 0.0.12 → 1.0.1
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.
- checksums.yaml +5 -5
- data/.travis.yml +2 -0
- data/README.md +88 -9
- data/ext/fast_osc/extconf.rb +1 -1
- data/ext/fast_osc/fast_osc_wrapper.c +74 -3
- data/ext/fast_osc/rtosc.c +2 -2
- data/fast_osc.gemspec +1 -1
- data/lib/fast_osc/version.rb +1 -1
- data/test/benchmark_test.rb +1 -1
- data/test/fast_osc_test.rb +160 -22
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 949bcdc8e52905bef3bb5b53468844ab80232dd84e41b4d3d6c583c4317a6ff6
|
4
|
+
data.tar.gz: 229101f3ae65814846abb268e3780d4ac2c41d8c0d80f1e4c6da914cd07f2066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8e2777889e23339b1aebfbf15dd0bf26c98377c17721a876261767df06de0eaff80cb1418bc979dcadfcd61f5fced74e8857c52dbd601e8029c25d9b9fac6a
|
7
|
+
data.tar.gz: 2c61360c8a58ff7994c4158e31060938f98352941aedb7941359980730cbd9bd9a8ca0f43c7ec88c09d4d0e56b5736ad24cbc8a7ad15106b525d73378b29522b
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# FastOsc
|
2
2
|
|
3
|
-
`WARNING - Work in progress. Probably not safe for production yet`
|
4
|
-
|
5
3
|
A Ruby wrapper around [rtosc](https://github.com/fundamental/rtosc/) to encode and decode OSC messages.
|
6
4
|
|
7
5
|
This also includes a fallback implementation in pure Ruby in the case that the compiled version doesn't load properly. This can be forced by setting an environment variable of `FAST_OSC_USE_FALLBACK=1` where needed.
|
@@ -43,7 +41,7 @@ Calculating -------------------------------------
|
|
43
41
|
osc-ruby 83.203k (±12.6%) i/s - 415.314k in 5.073578s
|
44
42
|
```
|
45
43
|
|
46
|
-
|
44
|
+
### Decoding Bencmark
|
47
45
|
|
48
46
|
```
|
49
47
|
Warming up --------------------------------------
|
@@ -58,6 +56,87 @@ Calculating -------------------------------------
|
|
58
56
|
|
59
57
|
Benchmarks are now part of this repo - run `rake test` to see the results for yourself.
|
60
58
|
|
59
|
+
## What about Truffle Ruby?
|
60
|
+
|
61
|
+
> A high performance implementation of the Ruby programming language. Built on GraalVM by Oracle Labs.
|
62
|
+
|
63
|
+
Just for fun, I re-ran the benchmarks using TruffleRuby. First some install steps:
|
64
|
+
|
65
|
+
```
|
66
|
+
git clone this repo
|
67
|
+
bundle install
|
68
|
+
export PATH="/usr/local/opt/llvm@4/bin:$PATH"
|
69
|
+
rake clean && rake compile
|
70
|
+
```
|
71
|
+
|
72
|
+
then the test:
|
73
|
+
|
74
|
+
```
|
75
|
+
$ rake test
|
76
|
+
ENCODING TEST
|
77
|
+
Warming up --------------------------------------
|
78
|
+
fast_osc 3.000 i/100ms
|
79
|
+
samsosc 28.219k i/100ms
|
80
|
+
osc-ruby 234.000 i/100ms
|
81
|
+
Calculating -------------------------------------
|
82
|
+
fast_osc 33.294 (±45.1%) i/s - 129.000 in 5.295649s
|
83
|
+
samsosc 1.369M (±33.5%) i/s - 3.556M in 5.010343s
|
84
|
+
osc-ruby 274.170k (±20.2%) i/s - 1.064M in 4.971832s
|
85
|
+
DECODING TEST
|
86
|
+
Warming up --------------------------------------
|
87
|
+
fast_osc 9.000 i/100ms
|
88
|
+
samsosc 6.087k i/100ms
|
89
|
+
osc-ruby 418.000 i/100ms
|
90
|
+
Calculating -------------------------------------
|
91
|
+
fast_osc 71.034 (±45.0%) i/s - 261.000 in 5.015393s
|
92
|
+
samsosc 114.443k (±70.2%) i/s - 261.741k in 5.283892s
|
93
|
+
osc-ruby 84.236k (±34.7%) i/s - 237.424k in 5.317738s
|
94
|
+
|
95
|
+
# update - retested using rc5
|
96
|
+
ENCODING TEST
|
97
|
+
Warming up --------------------------------------
|
98
|
+
fast_osc 106.000 i/100ms
|
99
|
+
samsosc 999.000 i/100ms
|
100
|
+
osc-ruby 159.000 i/100ms
|
101
|
+
Calculating -------------------------------------
|
102
|
+
fast_osc 24.507k (±28.6%) i/s - 83.316k in 4.984544s
|
103
|
+
samsosc 1.494M (±22.4%) i/s - 2.785M in 4.988822s
|
104
|
+
osc-ruby 265.322k (±26.5%) i/s - 597.522k in 5.014127s
|
105
|
+
DECODING TEST
|
106
|
+
Warming up --------------------------------------
|
107
|
+
fast_osc 173.000 i/100ms
|
108
|
+
samsosc 454.000 i/100ms
|
109
|
+
osc-ruby 208.000 i/100ms
|
110
|
+
Calculating -------------------------------------
|
111
|
+
fast_osc 73.712k (±66.4%) i/s - 163.831k in 5.049410s
|
112
|
+
samsosc 325.920k (±33.7%) i/s - 875.766k in 4.989279s
|
113
|
+
osc-ruby 63.624k (±52.3%) i/s - 129.792k in 5.005088s
|
114
|
+
Run options: --seed 56032
|
115
|
+
```
|
116
|
+
|
117
|
+
### The Good
|
118
|
+
|
119
|
+
The encoding benchmark - the optimised pure Ruby version is nearly as fast as
|
120
|
+
the C extension!
|
121
|
+
|
122
|
+
```
|
123
|
+
# C ext in MRI
|
124
|
+
fast_osc 797.673k (±15.0%) i/s - 3.900M in 5.043770s
|
125
|
+
# Pure Ruby in Truffle rc3
|
126
|
+
samsosc 1.369M (±33.5%) i/s - 3.556M in 5.010343s
|
127
|
+
# Pure Ruby in Truffle rc5
|
128
|
+
samsosc 1.494M (±22.4%) i/s - 2.785M in 4.988822s
|
129
|
+
```
|
130
|
+
|
131
|
+
### The Bad
|
132
|
+
|
133
|
+
Decoding was generally slower, although the (non optimised) osc gem seemed to
|
134
|
+
prefer TruffleRuby, running around 40% faster.
|
135
|
+
|
136
|
+
~Also the performance of the C extension in TruffleRuby was very, very poor but
|
137
|
+
this may be due to not warming up enough.~ update - this appears to be better
|
138
|
+
in rc5.
|
139
|
+
|
61
140
|
## Usage
|
62
141
|
|
63
142
|
```
|
@@ -81,12 +160,12 @@ $ rake clean && rake clobber && rake compile && rake test
|
|
81
160
|
|
82
161
|
## Still todo
|
83
162
|
|
84
|
-
-[x] Implement more types
|
85
|
-
-[x] Bring benchmarks into the repo
|
86
|
-
-[ ] Work out cross compilation story for easier packaging
|
87
|
-
-[
|
88
|
-
-[ ]
|
89
|
-
-[
|
163
|
+
- [x] Implement more types
|
164
|
+
- [x] Bring benchmarks into the repo
|
165
|
+
- [ ] Work out cross compilation story for easier packaging
|
166
|
+
- [x] Implement multi message/nested bundles
|
167
|
+
- [ ] More documentation
|
168
|
+
- [x] Travis
|
90
169
|
|
91
170
|
## Development notes
|
92
171
|
|
data/ext/fast_osc/extconf.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <ruby/encoding.h>
|
3
3
|
#include <rtosc.h>
|
4
|
-
#include <rtosc.c>
|
5
4
|
|
6
5
|
|
7
6
|
// Allocate VALUE variables to hold the modules we'll create. Ruby values
|
@@ -15,7 +14,8 @@ void Init_fast_osc();
|
|
15
14
|
VALUE method_fast_osc_decode_single_message(VALUE self, VALUE msg);
|
16
15
|
VALUE method_fast_osc_encode_single_message(int argc, VALUE* argv, VALUE self);
|
17
16
|
VALUE method_fast_osc_encode_single_bundle(int argc, VALUE* argv, VALUE self);
|
18
|
-
|
17
|
+
VALUE method_fast_osc_decode(VALUE self, VALUE msg);
|
18
|
+
VALUE method_fast_osc_decode_do(VALUE self, VALUE msg, VALUE output);
|
19
19
|
// Initial setup function, takes no arguments and returns nothing. Some API
|
20
20
|
// notes:
|
21
21
|
//
|
@@ -30,7 +30,8 @@ VALUE method_fast_osc_encode_single_bundle(int argc, VALUE* argv, VALUE self);
|
|
30
30
|
//
|
31
31
|
void Init_fast_osc() {
|
32
32
|
FastOsc = rb_define_module("FastOsc");
|
33
|
-
rb_define_singleton_method(FastOsc, "
|
33
|
+
rb_define_singleton_method(FastOsc, "decode", method_fast_osc_decode, 1);
|
34
|
+
rb_define_singleton_method(FastOsc, "decode_no_bundles", method_fast_osc_decode_single_message, 1);
|
34
35
|
rb_define_singleton_method(FastOsc, "encode_single_message", method_fast_osc_encode_single_message, -1);
|
35
36
|
rb_define_singleton_method(FastOsc, "encode_single_bundle", method_fast_osc_encode_single_bundle, -1);
|
36
37
|
}
|
@@ -68,6 +69,76 @@ uint64_t ruby_time_to_osc_timetag(VALUE rubytime) {
|
|
68
69
|
return timetag;
|
69
70
|
}
|
70
71
|
|
72
|
+
VALUE osc_timetag_to_ruby_time(uint64_t timetag) {
|
73
|
+
uint32_t secs = timetag >> 32;
|
74
|
+
uint32_t frac = timetag;
|
75
|
+
double d_frac = 1.0 * frac / 4294967296.0;
|
76
|
+
|
77
|
+
VALUE c_time = rb_const_get(rb_cObject, rb_intern("Time"));
|
78
|
+
VALUE rb_time = rb_funcall(c_time, rb_intern("at"), 1, DBL2NUM((secs - JAN_1970 + d_frac)));
|
79
|
+
|
80
|
+
return rb_time;
|
81
|
+
}
|
82
|
+
|
83
|
+
/*
|
84
|
+
# Example of how to process the messages in ruby:
|
85
|
+
msgs.each do |timestamp, osc_messages|
|
86
|
+
# These are the messages within this bundle
|
87
|
+
puts "T: #{timestamp}, D: #{osc_messages}"
|
88
|
+
osc_messages.each do |path, args|
|
89
|
+
# And this is each message
|
90
|
+
puts "P: #{path}, A: #{args}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
*/
|
94
|
+
VALUE method_fast_osc_decode(VALUE self, VALUE msg) {
|
95
|
+
VALUE output_ary = rb_ary_new();
|
96
|
+
// If we get != Qnil, then there were no bundles, and we need to add the element
|
97
|
+
VALUE element = method_fast_osc_decode_do(self, msg, output_ary);
|
98
|
+
if (element != Qnil){
|
99
|
+
VALUE element_ary = rb_ary_new();
|
100
|
+
rb_ary_push(element_ary, osc_timetag_to_ruby_time(1));
|
101
|
+
rb_ary_push(element_ary, element);
|
102
|
+
rb_ary_push(output_ary, element_ary);
|
103
|
+
}
|
104
|
+
return output_ary;
|
105
|
+
}
|
106
|
+
|
107
|
+
VALUE method_fast_osc_decode_do(VALUE self, VALUE msg, VALUE output_ary) {
|
108
|
+
char* data = StringValuePtr(msg);
|
109
|
+
int data_len = RSTRING_LEN(msg);
|
110
|
+
VALUE elements_ary = Qnil;
|
111
|
+
VALUE bundle_output_ary;
|
112
|
+
|
113
|
+
if (rtosc_bundle_p(data)){
|
114
|
+
int n_messages = rtosc_bundle_elements(data, data_len);
|
115
|
+
for (int i = 0; i < n_messages; i++){
|
116
|
+
int message_size = rtosc_bundle_size(data, i);
|
117
|
+
const char *message = rtosc_bundle_fetch(data, i);
|
118
|
+
VALUE rb_message = rb_str_new(message, message_size);
|
119
|
+
VALUE element = method_fast_osc_decode_do(self, rb_message, output_ary);
|
120
|
+
if (element != Qnil){
|
121
|
+
if (elements_ary == Qnil){
|
122
|
+
elements_ary = rb_ary_new();
|
123
|
+
}
|
124
|
+
rb_ary_push(elements_ary, element);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
if (elements_ary != Qnil){
|
128
|
+
uint64_t timetag = rtosc_bundle_timetag(data);
|
129
|
+
bundle_output_ary = rb_ary_new();
|
130
|
+
rb_ary_push(bundle_output_ary, osc_timetag_to_ruby_time(timetag));
|
131
|
+
rb_ary_push(bundle_output_ary, elements_ary);
|
132
|
+
rb_ary_push(output_ary, bundle_output_ary);
|
133
|
+
}
|
134
|
+
return Qnil;
|
135
|
+
}
|
136
|
+
else{
|
137
|
+
VALUE element = method_fast_osc_decode_single_message(self, msg);
|
138
|
+
return element;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
71
142
|
|
72
143
|
VALUE method_fast_osc_decode_single_message(VALUE self, VALUE msg) {
|
73
144
|
rtosc_arg_itr_t itr;
|
data/ext/fast_osc/rtosc.c
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#include <ctype.h>
|
7
7
|
#include <assert.h>
|
8
8
|
|
9
|
-
|
9
|
+
#include <rtosc.h>
|
10
10
|
|
11
11
|
const char *rtosc_argument_string(const char *msg)
|
12
12
|
{
|
@@ -762,7 +762,7 @@ size_t rtosc_bundle_size(const char *buffer, unsigned elm)
|
|
762
762
|
const uint32_t *lengths = (const uint32_t*) (buffer+16);
|
763
763
|
size_t elm_pos = 0;
|
764
764
|
size_t last_len = 0;
|
765
|
-
while(elm_pos!=elm && extract_uint32((const uint8_t*)lengths)) {
|
765
|
+
while(elm_pos!=elm+1 && extract_uint32((const uint8_t*)lengths)) {
|
766
766
|
last_len = extract_uint32((const uint8_t*)lengths);
|
767
767
|
++elm_pos, lengths+=extract_uint32((const uint8_t*)lengths)/4+1;
|
768
768
|
}
|
data/fast_osc.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.extensions << "ext/fast_osc/extconf.rb"
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~>
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rake-compiler"
|
26
26
|
spec.add_development_dependency "minitest", "~> 5.0"
|
data/lib/fast_osc/version.rb
CHANGED
data/test/benchmark_test.rb
CHANGED
@@ -43,7 +43,7 @@ end
|
|
43
43
|
# puts samosc.decode_single_message(test_message).inspect
|
44
44
|
puts "DECODING TEST"
|
45
45
|
Benchmark.ips do |bencher|
|
46
|
-
bencher.report("fast_osc") { FastOsc.
|
46
|
+
bencher.report("fast_osc") { FastOsc.decode_no_bundles(test_message) }
|
47
47
|
bencher.report("samsosc") { samosc.decode_single_message(test_message) }
|
48
48
|
bencher.report("osc-ruby") { oscruby.messages_from_network(test_message) }
|
49
49
|
|
data/test/fast_osc_test.rb
CHANGED
@@ -6,12 +6,34 @@ class FastOscTest < Minitest::Test
|
|
6
6
|
def setup
|
7
7
|
@path = "/thisisatest"
|
8
8
|
@args = ["", 1, 2.0, "baz", "▁▃▅▇"]
|
9
|
+
@args2 = [1]
|
10
|
+
@args3 = ["somestring", 2]
|
11
|
+
@args4 = [3, 5.0, "another_string"]
|
9
12
|
@timestamp = Date.parse("1st Jan 1990").to_time
|
13
|
+
@timestamp2 = Date.parse("21st Mar 2000").to_time
|
14
|
+
@timestamp3 = Date.parse("22nd Jun 2010").to_time
|
15
|
+
|
10
16
|
|
11
17
|
@msg0 = OSC::Message.new(@path).encode
|
12
18
|
@encoded_msg0 = @msg0.encode
|
13
19
|
@msg1 = OSC::Message.new(@path, *@args).encode
|
14
20
|
@encoded_msg1 = @msg1.encode
|
21
|
+
@msg2 = OSC::Message.new(@path, *@args2).encode
|
22
|
+
@encoded_msg2 = @msg2.encode
|
23
|
+
@msg3 = OSC::Message.new(@path, *@args3).encode
|
24
|
+
@encoded_msg3 = @msg3.encode
|
25
|
+
@msg4 = OSC::Message.new(@path, *@args4).encode
|
26
|
+
@encoded_msg4 = @msg4.encode
|
27
|
+
|
28
|
+
@bundle = OSC::Bundle.new(@timestamp, @msg1, @msg2)
|
29
|
+
@encoded_bundle = @bundle.encode
|
30
|
+
|
31
|
+
@bundle2 = OSC::Bundle.new(@timestamp2, @msg2, @bundle, @msg3)
|
32
|
+
@encoded_bundle2 = @bundle2.encode
|
33
|
+
|
34
|
+
@bundle3 = OSC::Bundle.new(@timestamp3, @msg4, @bundle2, @msg3, @msg2)
|
35
|
+
@encoded_bundle3 = @bundle3.encode
|
36
|
+
|
15
37
|
end
|
16
38
|
|
17
39
|
def test_that_it_has_a_version_number
|
@@ -24,11 +46,16 @@ class FastOscTest < Minitest::Test
|
|
24
46
|
assert_equal msg, @encoded_msg0
|
25
47
|
end
|
26
48
|
|
49
|
+
|
27
50
|
def test_that_it_decodes_a_single_message
|
28
|
-
|
51
|
+
msgs = FastOsc.decode(@encoded_msg0)
|
52
|
+
|
53
|
+
_timestamp, osc_msgs = msgs[0]
|
54
|
+
path, args = osc_msgs
|
29
55
|
|
30
56
|
assert path == @path
|
31
57
|
assert args == []
|
58
|
+
assert_nil msgs[1]
|
32
59
|
end
|
33
60
|
|
34
61
|
def test_that_it_encodes_a_single_message_with_args
|
@@ -38,12 +65,31 @@ class FastOscTest < Minitest::Test
|
|
38
65
|
end
|
39
66
|
|
40
67
|
def test_that_it_decodes_a_single_message_with_args
|
41
|
-
|
68
|
+
msgs = FastOsc.decode(@encoded_msg1)
|
69
|
+
|
70
|
+
_timestamp, osc_msgs = msgs[0]
|
71
|
+
path, args = osc_msgs
|
72
|
+
|
73
|
+
assert_equal path, @path
|
74
|
+
assert_equal args, @args
|
75
|
+
assert_nil msgs[1]
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_that_it_decodes_a_single_message_with_args_knowing_there_are_no_bundles_using_the_decode_function
|
79
|
+
_timestamp, (path, args) = FastOsc.decode(@encoded_msg1)[0]
|
80
|
+
|
81
|
+
assert_equal path, @path
|
82
|
+
assert_equal args, @args
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_that_it_decodes_a_single_message_with_args_knowing_there_are_no_bundles_using_the_decode_no_bundles_function
|
86
|
+
path, args = FastOsc.decode_no_bundles(@encoded_msg1)
|
42
87
|
|
43
88
|
assert_equal path, @path
|
44
89
|
assert_equal args, @args
|
45
90
|
end
|
46
91
|
|
92
|
+
|
47
93
|
def test_that_it_encodes_a_single_bundle
|
48
94
|
bundle1 = OSC::Bundle.new(@timestamp, @msg1).encode
|
49
95
|
bundle2 = FastOsc.encode_single_bundle(@timestamp, @path, @args)
|
@@ -51,6 +97,117 @@ class FastOscTest < Minitest::Test
|
|
51
97
|
assert_equal bundle1, bundle2
|
52
98
|
end
|
53
99
|
|
100
|
+
def test_that_it_decodes_a_bundle
|
101
|
+
msgs = FastOsc.decode(@encoded_bundle)
|
102
|
+
|
103
|
+
timestamp, osc_msgs = msgs[0]
|
104
|
+
assert_equal @timestamp, timestamp
|
105
|
+
|
106
|
+
path, args = osc_msgs[0]
|
107
|
+
assert_equal @path, path
|
108
|
+
assert_equal @args, args
|
109
|
+
|
110
|
+
path, args = osc_msgs[1]
|
111
|
+
assert_equal @path, path
|
112
|
+
assert_equal @args2, args
|
113
|
+
|
114
|
+
assert_nil osc_msgs[2]
|
115
|
+
assert_nil msgs[1]
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_that_it_decodes_a_nested_bundle
|
119
|
+
msgs = FastOsc.decode(@encoded_bundle2)
|
120
|
+
|
121
|
+
# Example of how to process the message:
|
122
|
+
#msgs.each do |timestamp, osc_messages|
|
123
|
+
# These are the messages within this bundle
|
124
|
+
# puts "T: #{timestamp}, M: #{osc_messages}"
|
125
|
+
# osc_messages.each do |path, args|
|
126
|
+
# And this is each message
|
127
|
+
# puts "P: #{path}, A: #{args}"
|
128
|
+
# end
|
129
|
+
#end
|
130
|
+
|
131
|
+
timestamp, osc_msgs = msgs[0]
|
132
|
+
assert_equal @timestamp, timestamp
|
133
|
+
|
134
|
+
path, args = osc_msgs[0]
|
135
|
+
assert_equal @path, path
|
136
|
+
assert_equal @args, args
|
137
|
+
|
138
|
+
path, args = osc_msgs[1]
|
139
|
+
assert_equal @path, path
|
140
|
+
assert_equal @args2, args
|
141
|
+
|
142
|
+
assert_nil osc_msgs[2]
|
143
|
+
|
144
|
+
timestamp, osc_msgs = msgs[1]
|
145
|
+
assert_equal @timestamp2, timestamp
|
146
|
+
|
147
|
+
path, args = osc_msgs[0]
|
148
|
+
assert_equal @path, path
|
149
|
+
assert_equal @args2, args
|
150
|
+
|
151
|
+
path, args = osc_msgs[1]
|
152
|
+
assert_equal @path, path
|
153
|
+
assert_equal @args3, args
|
154
|
+
assert_nil osc_msgs[2]
|
155
|
+
|
156
|
+
assert_nil msgs[2]
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_that_it_decodes_another_nested_bundle
|
160
|
+
msgs = FastOsc.decode(@encoded_bundle3)
|
161
|
+
|
162
|
+
timestamp, osc_msgs = msgs[0]
|
163
|
+
assert_equal @timestamp, timestamp
|
164
|
+
|
165
|
+
path, args = osc_msgs[0]
|
166
|
+
assert_equal @path, path
|
167
|
+
assert_equal @args, args
|
168
|
+
|
169
|
+
path, args = osc_msgs[1]
|
170
|
+
assert_equal @path, path
|
171
|
+
assert_equal @args2, args
|
172
|
+
|
173
|
+
assert_nil osc_msgs[2]
|
174
|
+
|
175
|
+
timestamp, osc_msgs = msgs[1]
|
176
|
+
assert_equal @timestamp2, timestamp
|
177
|
+
|
178
|
+
path, args = osc_msgs[0]
|
179
|
+
assert_equal @path, path
|
180
|
+
assert_equal @args2, args
|
181
|
+
|
182
|
+
path, args = osc_msgs[1]
|
183
|
+
assert_equal @path, path
|
184
|
+
assert_equal @args3, args
|
185
|
+
assert_nil osc_msgs[2]
|
186
|
+
|
187
|
+
timestamp, osc_msgs = msgs[2]
|
188
|
+
assert_equal @timestamp3, timestamp
|
189
|
+
|
190
|
+
path, args = osc_msgs[0]
|
191
|
+
assert_equal @path, path
|
192
|
+
assert_equal @args4, args
|
193
|
+
|
194
|
+
path, args = osc_msgs[1]
|
195
|
+
assert_equal @path, path
|
196
|
+
assert_equal @args3, args
|
197
|
+
|
198
|
+
path, args = osc_msgs[2]
|
199
|
+
assert_equal @path, path
|
200
|
+
assert_equal @args2, args
|
201
|
+
|
202
|
+
assert_nil osc_msgs[3]
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
assert_nil msgs[3]
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
|
54
211
|
def test_that_it_encodes_a_single_bundle_with_fractional_time
|
55
212
|
bundle1 = OSC::Bundle.new(@timestamp + 0.3343215, @msg1).encode
|
56
213
|
bundle2 = FastOsc.encode_single_bundle(@timestamp + 0.3343215, @path, @args)
|
@@ -65,27 +222,8 @@ class FastOscTest < Minitest::Test
|
|
65
222
|
assert_equal bundle1, bundle2
|
66
223
|
end
|
67
224
|
|
68
|
-
def test_that_it_encodes_and_decodes_messages_with_symbols
|
69
|
-
path = "/s_new"
|
70
|
-
args = ["sonic-pi-basic_mixer", 10, 0, 2, :amp, 1, :amp_slide, 0.1, :amp_slide_shape, 1, :amp_slide_curve, 0, "in_bus", 12, "amp", 0.3 , "out_bus", 10]
|
71
|
-
outpath, outargs = FastOsc.decode_single_message(FastOsc.encode_single_message(path, args))
|
72
|
-
|
73
|
-
assert_equal path, outpath
|
74
|
-
# normalize symbols to strings, round floats to 5 places
|
75
|
-
assert_equal args.map {|x| x.is_a?(Symbol) ? x.to_s : x}, outargs.map {|x| x.is_a?(Float) ? x.round(5) : x }
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_that_it_encodes_and_decodes_messages_with_timestamps
|
79
|
-
path = "/s_new"
|
80
|
-
args = [Time.at(1463234577.488746)]
|
81
|
-
#args = [Time.at(1463234577.0)]
|
82
|
-
outpath, outargs = FastOsc.decode_single_message(FastOsc.encode_single_message(path, args))
|
83
|
-
|
84
|
-
assert_equal path, outpath
|
85
|
-
assert_equal args.first.to_f.round(5), outargs.first.to_f.round(5)
|
86
|
-
end
|
87
225
|
|
88
|
-
def
|
226
|
+
def _test_that_encoded_timestamps_line_up
|
89
227
|
# this test is a bit convoluted but I found that fractional
|
90
228
|
# seconds weren't working when I plugged this into Sonic Pi
|
91
229
|
# This test ensures that the timestamp encoding matches to
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_osc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +103,7 @@ extensions:
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
106
107
|
- Gemfile
|
107
108
|
- LICENSE.txt
|
108
109
|
- README.md
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
143
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
144
|
+
rubygems_version: 2.7.9
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Serialize and deserialize Open Sound Control messages
|