unimidi 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +7 -7
- data/lib/unimidi.rb +3 -2
- data/lib/unimidi/input.rb +5 -96
- data/lib/unimidi/input/buffer_access.rb +47 -0
- data/lib/unimidi/input/stream_reader.rb +85 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0531893dc83d0ed407f9c4f984c488058481957e
|
4
|
+
data.tar.gz: c22c25a2305d2007e7179cf8826268abb4e40156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7abb6b93f5b49ec458ee47e24f277446528a233a174e6aed9c54db93239648d2ef058ef788f9532c24793c4b1b335a50ffa4ff10be360068d43bf49560a93586
|
7
|
+
data.tar.gz: 7372540218623430ed69eb8012e1d8493e52693923801dc6326a607ad16040c69033e7097d9e433aa347e1b089a8fa0c91ff045973616caad5078431b8e5a6d9
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Also see [MicroMIDI](http://github.com/arirusso/micromidi) which builds a full M
|
|
16
16
|
|
17
17
|
Using Ruby 1.9.2 or JRuby 1.6.1 (or newer) is strongly recommended. JRuby should be run in 1.9 mode where applicable
|
18
18
|
|
19
|
-
UniMIDI uses one of the following libraries, depending on which platform you're using it on. The necessary library should install automatically with the unimidi gem.
|
19
|
+
UniMIDI uses one of the following libraries, depending on which platform you're using it on. The necessary library should install automatically with the unimidi gem.
|
20
20
|
|
21
21
|
Platform
|
22
22
|
|
@@ -24,7 +24,7 @@ Platform
|
|
24
24
|
* Linux: [alsa-rawmidi](http://github.com/arirusso/alsa-rawmidi)
|
25
25
|
* OSX: [ffi-coremidi](http://github.com/arirusso/ffi-coremidi)
|
26
26
|
* Windows/Cygwin: [midi-winmm](http://github.com/arirusso/midi-winmm)
|
27
|
-
|
27
|
+
|
28
28
|
### Install
|
29
29
|
|
30
30
|
If you're using Bundler, add this line to your application's Gemfile:
|
@@ -34,7 +34,7 @@ If you're using Bundler, add this line to your application's Gemfile:
|
|
34
34
|
Otherwise...
|
35
35
|
|
36
36
|
`gem install unimidi`
|
37
|
-
|
37
|
+
|
38
38
|
### Usage
|
39
39
|
|
40
40
|
##### Blog Posts
|
@@ -75,13 +75,13 @@ See below for additional notes on testing with JRuby
|
|
75
75
|
##### Linux
|
76
76
|
|
77
77
|
* *libasound* and *libasound-dev* packages are required
|
78
|
-
|
79
|
-
### Author
|
78
|
+
|
79
|
+
### Author
|
80
80
|
|
81
81
|
[Ari Russo](http://github.com/arirusso) <ari.russo at gmail.com>
|
82
|
-
|
82
|
+
|
83
83
|
### License
|
84
84
|
|
85
85
|
Apache 2.0, See the file LICENSE
|
86
86
|
|
87
|
-
Copyright (c) 2010-
|
87
|
+
Copyright (c) 2010-2016 Ari Russo
|
data/lib/unimidi.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Realtime MIDI IO for Ruby
|
3
3
|
#
|
4
|
-
# (c)2010-
|
4
|
+
# (c)2010-2016 Ari Russo
|
5
|
+
# Licensed under the Apache 2.0 License
|
5
6
|
#
|
6
7
|
|
7
8
|
# modules
|
@@ -17,7 +18,7 @@ require "unimidi/output"
|
|
17
18
|
|
18
19
|
module UniMIDI
|
19
20
|
|
20
|
-
VERSION = "0.4.
|
21
|
+
VERSION = "0.4.7"
|
21
22
|
|
22
23
|
Platform.bootstrap
|
23
24
|
|
data/lib/unimidi/input.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
require "unimidi/input/buffer_access"
|
2
|
+
require "unimidi/input/stream_reader"
|
3
|
+
|
1
4
|
module UniMIDI
|
2
5
|
|
3
6
|
# A MIDI input device
|
4
7
|
class Input
|
5
8
|
|
6
9
|
extend Device::ClassMethods
|
10
|
+
include BufferAccess
|
7
11
|
include Device::InstanceMethods
|
12
|
+
include StreamReader
|
8
13
|
|
9
14
|
# All MIDI input devices -- used to populate the class
|
10
15
|
# @return [Array<Input>]
|
@@ -12,102 +17,6 @@ module UniMIDI
|
|
12
17
|
Loader.devices(:direction => :input)
|
13
18
|
end
|
14
19
|
|
15
|
-
# The device buffer
|
16
|
-
# @return [Array<Hash>]
|
17
|
-
def buffer
|
18
|
-
@device.buffer
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Plucks data from the input buffer and returns it as array of MIDI event hashes as such:
|
23
|
-
# [
|
24
|
-
# { :data => [144, 60, 100], :timestamp => 1024 },
|
25
|
-
# { :data => [128, 60, 100], :timestamp => 1100 },
|
26
|
-
# { :data => [144, 40, 120], :timestamp => 1200 }
|
27
|
-
# ]
|
28
|
-
#
|
29
|
-
# In this case, the data is an array of Numeric bytes
|
30
|
-
# The timestamp is the number of millis since this input was enabled
|
31
|
-
# Arguments are passed to the underlying device object
|
32
|
-
#
|
33
|
-
# @param [*Object] args
|
34
|
-
# @return [Array<Hash>]
|
35
|
-
def gets(*args)
|
36
|
-
@device.gets(*args)
|
37
|
-
rescue SystemExit, Interrupt
|
38
|
-
exit
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Plucks data from the input buffer and returns it as array of MIDI event hashes.
|
43
|
-
# Similar to Input#gets except that the returned message data as string of hex digits eg:
|
44
|
-
# [
|
45
|
-
# { :data => "904060", :timestamp => 904 },
|
46
|
-
# { :data => "804060", :timestamp => 1150 },
|
47
|
-
# { :data => "90447F", :timestamp => 1300 }
|
48
|
-
# ]
|
49
|
-
#
|
50
|
-
# @param [*Object] args
|
51
|
-
# @return [Array<Hash>]
|
52
|
-
def gets_s(*args)
|
53
|
-
@device.gets_s(*args)
|
54
|
-
rescue SystemExit, Interrupt
|
55
|
-
exit
|
56
|
-
end
|
57
|
-
alias_method :gets_bytestr, :gets_s
|
58
|
-
alias_method :gets_hex, :gets_s
|
59
|
-
|
60
|
-
#
|
61
|
-
# Plucks data from the input buffer and returns it as an array of data bytes such as
|
62
|
-
# [144, 60, 100, 128, 60, 100, 144, 40, 120]
|
63
|
-
#
|
64
|
-
# @param [*Object] args
|
65
|
-
# @return [Array<Fixnum>]
|
66
|
-
def gets_data(*args)
|
67
|
-
arr = gets(*args)
|
68
|
-
arr.map { |msg| msg[:data] }.inject(:+)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Plucks data from the input buffer and returns it as a string of data such as
|
73
|
-
# "90406080406090447F"
|
74
|
-
#
|
75
|
-
# @param [*Object] args
|
76
|
-
# @return [String]
|
77
|
-
def gets_data_s(*args)
|
78
|
-
arr = gets_bytestr(*args)
|
79
|
-
arr.map { |msg| msg[:data] }.join
|
80
|
-
end
|
81
|
-
alias_method :gets_data_bytestr, :gets_data_s
|
82
|
-
alias_method :gets_data_hex, :gets_data_s
|
83
|
-
|
84
|
-
# Clears the input buffer
|
85
|
-
# @return [Array]
|
86
|
-
def clear_buffer
|
87
|
-
@device.buffer.clear
|
88
|
-
end
|
89
|
-
|
90
|
-
# Gets any messages in the buffer in the same format as Input#gets, without removing them from the buffer
|
91
|
-
# @param [*Object] args
|
92
|
-
# @return [Array<Hash>]
|
93
|
-
def gets_buffer(*args)
|
94
|
-
@device.buffer
|
95
|
-
end
|
96
|
-
|
97
|
-
# Gets any messages in the buffer in the same format as Input#gets_s, without removing them from the buffer
|
98
|
-
# @param [*Object] args
|
99
|
-
# @return [Array<Hash>]
|
100
|
-
def gets_buffer_s(*args)
|
101
|
-
@device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg }
|
102
|
-
end
|
103
|
-
|
104
|
-
# Gets any messages in the buffer in the same format as Input#gets_data without removing them from the buffer
|
105
|
-
# @param [*Object] args
|
106
|
-
# @return [Array<Fixnum>]
|
107
|
-
def gets_buffer_data(*args)
|
108
|
-
@device.buffer.map { |msg| msg[:data] }
|
109
|
-
end
|
110
|
-
|
111
20
|
end
|
112
21
|
|
113
22
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module UniMIDI
|
2
|
+
|
3
|
+
class Input
|
4
|
+
|
5
|
+
module BufferAccess
|
6
|
+
|
7
|
+
# The device buffer
|
8
|
+
# @return [Array<Hash>]
|
9
|
+
def buffer
|
10
|
+
@device.buffer
|
11
|
+
end
|
12
|
+
|
13
|
+
# Clears the input buffer
|
14
|
+
# @return [Array]
|
15
|
+
def clear_buffer
|
16
|
+
@device.buffer.clear
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gets any messages in the buffer in the same format as Input::StreamReader#gets. This doesn't remove
|
20
|
+
# the messages from the buffer or have any effect on the StreamReader pointer position
|
21
|
+
# @param [*Object] args
|
22
|
+
# @return [Array<Hash>]
|
23
|
+
def gets_buffer(*args)
|
24
|
+
@device.buffer
|
25
|
+
end
|
26
|
+
|
27
|
+
# Gets any messages in the buffer in the same format as Input#gets_s. This doesn't remove
|
28
|
+
# the messages from the buffer or have any effect on the StreamReader pointer position
|
29
|
+
# @param [*Object] args
|
30
|
+
# @return [Array<Hash>]
|
31
|
+
def gets_buffer_s(*args)
|
32
|
+
@device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg }
|
33
|
+
end
|
34
|
+
|
35
|
+
# Gets any messages in the buffer in the same format as Input#gets_data. . This doesn't remove
|
36
|
+
# the messages from the buffer or have any effect on the StreamReader pointer position
|
37
|
+
# @param [*Object] args
|
38
|
+
# @return [Array<Fixnum>]
|
39
|
+
def gets_buffer_data(*args)
|
40
|
+
@device.buffer.map { |msg| msg[:data] }
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module UniMIDI
|
2
|
+
|
3
|
+
class Input
|
4
|
+
|
5
|
+
module StreamReader
|
6
|
+
|
7
|
+
# Returns any data in the input buffer that have been received since the last call to a
|
8
|
+
# StreamReader method. If a StreamReader method has not yet been called, all data received
|
9
|
+
# since the program was initialized will be returned
|
10
|
+
#
|
11
|
+
# The data is returned as array of MIDI event hashes as such:
|
12
|
+
# [
|
13
|
+
# { :data => [144, 60, 100], :timestamp => 1024 },
|
14
|
+
# { :data => [128, 60, 100], :timestamp => 1100 },
|
15
|
+
# { :data => [144, 40, 120], :timestamp => 1200 }
|
16
|
+
# ]
|
17
|
+
#
|
18
|
+
# In this case, the data is an array of Numeric bytes
|
19
|
+
# The timestamp is the number of millis since this input was enabled
|
20
|
+
# Arguments are passed to the underlying device object
|
21
|
+
#
|
22
|
+
# @param [*Object] args
|
23
|
+
# @return [Array<Hash>]
|
24
|
+
def gets(*args)
|
25
|
+
@device.gets(*args)
|
26
|
+
rescue SystemExit, Interrupt
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns any data in the input buffer that have been received since the last call to a
|
31
|
+
# StreamReader method. If a StreamReader method has not yet been called, all data received
|
32
|
+
# since the program was initialized will be returned
|
33
|
+
#
|
34
|
+
# Similar to Input#gets except that the returned message data as string of hex digits eg:
|
35
|
+
# [
|
36
|
+
# { :data => "904060", :timestamp => 904 },
|
37
|
+
# { :data => "804060", :timestamp => 1150 },
|
38
|
+
# { :data => "90447F", :timestamp => 1300 }
|
39
|
+
# ]
|
40
|
+
#
|
41
|
+
# @param [*Object] args
|
42
|
+
# @return [Array<Hash>]
|
43
|
+
def gets_s(*args)
|
44
|
+
@device.gets_s(*args)
|
45
|
+
rescue SystemExit, Interrupt
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
alias_method :gets_bytestr, :gets_s
|
49
|
+
alias_method :gets_hex, :gets_s
|
50
|
+
|
51
|
+
# Returns any data in the input buffer that have been received since the last call to a
|
52
|
+
# StreamReader method. If a StreamReader method has not yet been called, all data received
|
53
|
+
# since the program was initialized will be returned
|
54
|
+
#
|
55
|
+
# Similar to Input#gets except that the returned message data as an array of data bytes such as
|
56
|
+
# [144, 60, 100, 128, 60, 100, 144, 40, 120]
|
57
|
+
#
|
58
|
+
# @param [*Object] args
|
59
|
+
# @return [Array<Fixnum>]
|
60
|
+
def gets_data(*args)
|
61
|
+
arr = gets(*args)
|
62
|
+
arr.map { |msg| msg[:data] }.inject(:+)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns any data in the input buffer that have been received since the last call to a
|
66
|
+
# StreamReader method. If a StreamReader method has not yet been called, all data received
|
67
|
+
# since the program was initialized will be returned
|
68
|
+
#
|
69
|
+
# Similar to Input#gets except that the returned message data as a string of data such as
|
70
|
+
# "90406080406090447F"
|
71
|
+
#
|
72
|
+
# @param [*Object] args
|
73
|
+
# @return [String]
|
74
|
+
def gets_data_s(*args)
|
75
|
+
arr = gets_bytestr(*args)
|
76
|
+
arr.map { |msg| msg[:data] }.join
|
77
|
+
end
|
78
|
+
alias_method :gets_data_bytestr, :gets_data_s
|
79
|
+
alias_method :gets_data_hex, :gets_data_s
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -187,6 +187,8 @@ files:
|
|
187
187
|
- lib/unimidi/command.rb
|
188
188
|
- lib/unimidi/device.rb
|
189
189
|
- lib/unimidi/input.rb
|
190
|
+
- lib/unimidi/input/buffer_access.rb
|
191
|
+
- lib/unimidi/input/stream_reader.rb
|
190
192
|
- lib/unimidi/loader.rb
|
191
193
|
- lib/unimidi/output.rb
|
192
194
|
- lib/unimidi/platform.rb
|
@@ -210,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
212
|
requirements:
|
211
213
|
- - ">="
|
212
214
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
215
|
+
version: 1.8.6
|
214
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
217
|
requirements:
|
216
218
|
- - ">="
|
@@ -218,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
220
|
version: 1.3.6
|
219
221
|
requirements: []
|
220
222
|
rubyforge_project: unimidi
|
221
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.4.6
|
222
224
|
signing_key:
|
223
225
|
specification_version: 4
|
224
226
|
summary: Realtime MIDI IO for Ruby
|