alsa-rawmidi 0.3.1 → 0.3.2
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 +4 -4
- data/LICENSE +1 -1
- data/README.md +6 -6
- data/lib/alsa-rawmidi.rb +6 -5
- data/lib/alsa-rawmidi/api.rb +24 -24
- data/lib/alsa-rawmidi/device.rb +3 -3
- data/lib/alsa-rawmidi/input.rb +3 -3
- data/lib/alsa-rawmidi/output.rb +2 -2
- data/lib/alsa-rawmidi/soundcard.rb +2 -2
- data/lib/alsa-rawmidi/version.rb +5 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f58d0a3f8e6060d9315afd9534b4aec7834f196
|
4
|
+
data.tar.gz: 26a79750d4048440e0769805bb0576c183b3ef80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f00bc3bba78d18e2017e749b708276dac2b597974dd796ec481636d59c0d2f8ca98d8afb7c2c94c47ee7f060e2797a2e3f4bf4f2a9da7f651b511c663e237523
|
7
|
+
data.tar.gz: 6b1d5c46be16974720e25d9347ca9b304741ed89d89689b85f620ebf386d9dd48481bb0d79faa2f9852ef3cd0d2ef8364bf74a49cf410ae85ccf534f1a9f68db
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Access the ALSA RawMIDI API with Ruby.
|
6
6
|
|
7
|
-
Note that in the interest of allowing people on other platforms to utilize your code, you should consider using [unimidi](http://github.com/arirusso/unimidi). Unimidi is a platform independent wrapper that implements this gem and has a similar API.
|
7
|
+
Note that in the interest of allowing people on other platforms to utilize your code, you should consider using [unimidi](http://github.com/arirusso/unimidi). Unimidi is a platform independent wrapper that implements this gem and has a similar API.
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
@@ -27,7 +27,7 @@ If you're using Bundler, add this line to your application's Gemfile:
|
|
27
27
|
Otherwise
|
28
28
|
|
29
29
|
`gem install alsa-rawmidi`
|
30
|
-
|
30
|
+
|
31
31
|
## Usage
|
32
32
|
|
33
33
|
* [input](http://github.com/arirusso/alsa-rawmidi/blob/master/examples/input.rb)
|
@@ -36,13 +36,13 @@ Otherwise
|
|
36
36
|
## Documentation
|
37
37
|
|
38
38
|
* [rdoc](http://rdoc.info/gems/alsa-rawmidi)
|
39
|
-
|
40
|
-
## Author
|
39
|
+
|
40
|
+
## Author
|
41
41
|
|
42
42
|
[Ari Russo](http://github.com/arirusso) <ari.russo at gmail.com>
|
43
|
-
|
43
|
+
|
44
44
|
## License
|
45
45
|
|
46
46
|
Apache 2.0, See the file LICENSE
|
47
47
|
|
48
|
-
Copyright (c) 2010-
|
48
|
+
Copyright (c) 2010-2017 Ari Russo
|
data/lib/alsa-rawmidi.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# alsa-rawmidi
|
3
|
+
# ALSA Driver Interface
|
3
4
|
#
|
4
|
-
# Ari Russo
|
5
|
-
# (c) 2010-2014
|
5
|
+
# (c) 2010-2014 Ari Russo
|
6
6
|
# Licensed under Apache 2.0
|
7
|
+
# https://github.com/arirusso/alsa-rawmidi
|
8
|
+
#
|
7
9
|
|
8
10
|
# libs
|
9
11
|
require "ffi"
|
@@ -11,6 +13,7 @@ require "ffi"
|
|
11
13
|
# modules
|
12
14
|
require "alsa-rawmidi/api"
|
13
15
|
require "alsa-rawmidi/device"
|
16
|
+
require "alsa-rawmidi/version"
|
14
17
|
|
15
18
|
# class
|
16
19
|
require "alsa-rawmidi/input"
|
@@ -19,6 +22,4 @@ require "alsa-rawmidi/soundcard"
|
|
19
22
|
|
20
23
|
module AlsaRawMIDI
|
21
24
|
|
22
|
-
VERSION = "0.3.1"
|
23
|
-
|
24
25
|
end
|
data/lib/alsa-rawmidi/api.rb
CHANGED
@@ -241,8 +241,8 @@ module AlsaRawMIDI
|
|
241
241
|
extend self
|
242
242
|
|
243
243
|
# Open the output with the given ID
|
244
|
-
# @param [
|
245
|
-
# @return [
|
244
|
+
# @param [Integer] id
|
245
|
+
# @return [Integer]
|
246
246
|
def open(id)
|
247
247
|
API::Device.open(id) do |pointer|
|
248
248
|
API.snd_rawmidi_open(pointer, nil, id, API::CONSTANTS[:SND_RAWMIDI_NONBLOCK])
|
@@ -272,8 +272,8 @@ module AlsaRawMIDI
|
|
272
272
|
extend self
|
273
273
|
|
274
274
|
# Send the given MIDI data to the output with the given handle
|
275
|
-
# @param [
|
276
|
-
# @param [Array<
|
275
|
+
# @param [Integer] handle
|
276
|
+
# @param [Array<Integer>] data
|
277
277
|
# @return [Boolean]
|
278
278
|
def puts(handle, data)
|
279
279
|
format = "C" * data.size
|
@@ -286,8 +286,8 @@ module AlsaRawMIDI
|
|
286
286
|
end
|
287
287
|
|
288
288
|
# Open the output with the given ID
|
289
|
-
# @param [
|
290
|
-
# @return [
|
289
|
+
# @param [Integer] id
|
290
|
+
# @return [Integer]
|
291
291
|
def open(id)
|
292
292
|
API::Device.open(id) do |pointer|
|
293
293
|
API.snd_rawmidi_open(nil, pointer, id, 0)
|
@@ -301,7 +301,7 @@ module AlsaRawMIDI
|
|
301
301
|
|
302
302
|
extend self
|
303
303
|
|
304
|
-
# @param [
|
304
|
+
# @param [Integer] id
|
305
305
|
# @param [Symbol] direction
|
306
306
|
# @return [SndCtlCardInfo]
|
307
307
|
def get_info(id, direction)
|
@@ -317,7 +317,7 @@ module AlsaRawMIDI
|
|
317
317
|
end
|
318
318
|
|
319
319
|
# Close the device with the given handle
|
320
|
-
# @param [
|
320
|
+
# @param [Integer] handle
|
321
321
|
# @return [Boolean]
|
322
322
|
def close(handle)
|
323
323
|
API.snd_rawmidi_drain(handle)
|
@@ -326,9 +326,9 @@ module AlsaRawMIDI
|
|
326
326
|
end
|
327
327
|
|
328
328
|
# Open the device with the given id
|
329
|
-
# @param [
|
329
|
+
# @param [Integer] id
|
330
330
|
# @param [Proc] block
|
331
|
-
# @return [
|
331
|
+
# @return [Integer]
|
332
332
|
def open(id, &block)
|
333
333
|
handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int))
|
334
334
|
yield(handle_pointer)
|
@@ -343,16 +343,16 @@ module AlsaRawMIDI
|
|
343
343
|
extend self
|
344
344
|
|
345
345
|
# @param [SndCtlCardInfo] info
|
346
|
-
# @return [
|
346
|
+
# @return [Integer]
|
347
347
|
def get_subdevice_count(info)
|
348
348
|
subdev_count = API.snd_rawmidi_info_get_subdevices_count(info.pointer)
|
349
349
|
subdev_count = 0 if subdev_count > 32
|
350
350
|
subdev_count
|
351
351
|
end
|
352
352
|
|
353
|
-
# @param [
|
354
|
-
# @param [
|
355
|
-
# @param [
|
353
|
+
# @param [Integer, String] device_num
|
354
|
+
# @param [Integer] subdev_count
|
355
|
+
# @param [Integer] id
|
356
356
|
# @return [String]
|
357
357
|
def get_subdevice_id(soundcard_id, device_id, subdev_count, id)
|
358
358
|
ext = (subdev_count > 1) ? ",#{id}" : ''
|
@@ -361,16 +361,16 @@ module AlsaRawMIDI
|
|
361
361
|
end
|
362
362
|
|
363
363
|
# @param [SndCtlCardInfo] info
|
364
|
-
# @param [
|
365
|
-
# @param [
|
364
|
+
# @param [Integer] id
|
365
|
+
# @param [Integer] handle
|
366
366
|
# @return [Boolean]
|
367
367
|
def valid_subdevice?(info, id, handle)
|
368
368
|
API.snd_rawmidi_info_set_subdevice(info.pointer, id)
|
369
369
|
API.snd_ctl_rawmidi_info(handle, info.pointer) >= 0
|
370
370
|
end
|
371
371
|
|
372
|
-
# @param [
|
373
|
-
# @param [
|
372
|
+
# @param [Integer] soundcard_id
|
373
|
+
# @param [Integer] device_id
|
374
374
|
# @param [Symbol] direction
|
375
375
|
# @param [Proc] block
|
376
376
|
# @return [Array<Object>]
|
@@ -398,8 +398,8 @@ module AlsaRawMIDI
|
|
398
398
|
available
|
399
399
|
end
|
400
400
|
|
401
|
-
# @param [
|
402
|
-
# @return [Array<
|
401
|
+
# @param [Integer] id
|
402
|
+
# @return [Array<Integer>]
|
403
403
|
def get_device_ids(id)
|
404
404
|
handle = API::Soundcard.get_handle(id)
|
405
405
|
(0..31).to_a.select do |n|
|
@@ -408,21 +408,21 @@ module AlsaRawMIDI
|
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
411
|
-
# @param [
|
411
|
+
# @param [Integer] soundcard_id
|
412
412
|
# @return [String]
|
413
413
|
def get_name(soundcard_id)
|
414
414
|
"hw:#{soundcard_id.to_s}"
|
415
415
|
end
|
416
416
|
|
417
417
|
# Does a soundcard exist for the given id?
|
418
|
-
# @param [
|
418
|
+
# @param [Integer] id
|
419
419
|
# @return [Boolean]
|
420
420
|
def exists?(id)
|
421
421
|
API.snd_card_load(id) == 1
|
422
422
|
end
|
423
423
|
|
424
|
-
# @param [
|
425
|
-
# @return [
|
424
|
+
# @param [Integer] soundcard_id
|
425
|
+
# @return [Integer]
|
426
426
|
def get_handle(soundcard_id)
|
427
427
|
handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int))
|
428
428
|
API.snd_ctl_open(handle_pointer, get_name(soundcard_id), 0)
|
data/lib/alsa-rawmidi/device.rb
CHANGED
@@ -75,7 +75,7 @@ module AlsaRawMIDI
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# @param [Hash] options
|
78
|
-
# @option options [
|
78
|
+
# @option options [Integer] :id
|
79
79
|
# @option options [String] :name
|
80
80
|
# @option options [String] :subname
|
81
81
|
# @option options [String] :system_id
|
@@ -91,8 +91,8 @@ module AlsaRawMIDI
|
|
91
91
|
private
|
92
92
|
|
93
93
|
# Assign an id
|
94
|
-
# @param [
|
95
|
-
# @return [
|
94
|
+
# @param [Integer] id
|
95
|
+
# @return [Integer]
|
96
96
|
def id=(id)
|
97
97
|
@id = id
|
98
98
|
end
|
data/lib/alsa-rawmidi/input.rb
CHANGED
@@ -72,7 +72,7 @@ module AlsaRawMIDI
|
|
72
72
|
def close
|
73
73
|
if @enabled
|
74
74
|
Thread.kill(@listener)
|
75
|
-
|
75
|
+
API::Device.close(@resource)
|
76
76
|
@enabled = false
|
77
77
|
true
|
78
78
|
else
|
@@ -171,7 +171,7 @@ module AlsaRawMIDI
|
|
171
171
|
|
172
172
|
# Convert a hex string to an array of numeric bytes eg "904040" -> [0x90, 0x40, 0x40]
|
173
173
|
# @param [String] string
|
174
|
-
# @return [Array<
|
174
|
+
# @return [Array<Integer>]
|
175
175
|
def hex_string_to_numeric_bytes(string)
|
176
176
|
string = string.dup
|
177
177
|
bytes = []
|
@@ -183,7 +183,7 @@ module AlsaRawMIDI
|
|
183
183
|
end
|
184
184
|
|
185
185
|
# Convert an array of numeric bytes to a hex string eg [0x90, 0x40, 0x40] -> "904040"
|
186
|
-
# @param [Array<
|
186
|
+
# @param [Array<Integer>] bytes
|
187
187
|
# @return [String]
|
188
188
|
def numeric_bytes_to_hex_string(bytes)
|
189
189
|
string_bytes = bytes.map do |byte|
|
data/lib/alsa-rawmidi/output.rb
CHANGED
@@ -33,7 +33,7 @@ module AlsaRawMIDI
|
|
33
33
|
alias_method :puts_hex, :puts_s
|
34
34
|
|
35
35
|
# Output a MIDI message in numeric byte format
|
36
|
-
# @param [*
|
36
|
+
# @param [*Integer] data
|
37
37
|
# @return [Boolean]
|
38
38
|
def puts_bytes(*data)
|
39
39
|
API::Output.puts(@resource, data)
|
@@ -41,7 +41,7 @@ module AlsaRawMIDI
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Output the given MIDI message
|
44
|
-
# @param [*
|
44
|
+
# @param [*Integer, *String] args
|
45
45
|
# @return [Boolean]
|
46
46
|
def puts(*args)
|
47
47
|
case args.first
|
@@ -4,7 +4,7 @@ module AlsaRawMIDI
|
|
4
4
|
|
5
5
|
attr_reader :id, :subdevices
|
6
6
|
|
7
|
-
# @param [
|
7
|
+
# @param [Integer] id
|
8
8
|
def initialize(id)
|
9
9
|
@subdevices = {
|
10
10
|
:input => [],
|
@@ -15,7 +15,7 @@ module AlsaRawMIDI
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Find a soundcard by its ID
|
18
|
-
# @param [
|
18
|
+
# @param [Integer] id
|
19
19
|
# @return [Soundcard]
|
20
20
|
def self.find(id)
|
21
21
|
@soundcards ||= {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alsa-rawmidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
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: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -39,12 +39,13 @@ files:
|
|
39
39
|
- lib/alsa-rawmidi/input.rb
|
40
40
|
- lib/alsa-rawmidi/output.rb
|
41
41
|
- lib/alsa-rawmidi/soundcard.rb
|
42
|
+
- lib/alsa-rawmidi/version.rb
|
42
43
|
- test/helper.rb
|
43
44
|
- test/input_buffer_test.rb
|
44
45
|
- test/io_test.rb
|
45
46
|
homepage: http://github.com/arirusso/alsa-rawmidi
|
46
47
|
licenses:
|
47
|
-
- Apache
|
48
|
+
- Apache-2.0
|
48
49
|
metadata: {}
|
49
50
|
post_install_message:
|
50
51
|
rdoc_options: []
|
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
version: 1.3.6
|
63
64
|
requirements: []
|
64
65
|
rubyforge_project: alsa-rawmidi
|
65
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.6.8
|
66
67
|
signing_key:
|
67
68
|
specification_version: 4
|
68
69
|
summary: Realtime MIDI IO with Ruby for Linux
|