mmplayer 0.0.11 → 0.0.12
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/lib/mmplayer.rb +1 -1
- data/lib/mmplayer/context.rb +2 -2
- data/lib/mmplayer/helper/numbers.rb +4 -4
- data/lib/mmplayer/instructions/midi.rb +3 -3
- data/lib/mmplayer/midi/message_handler.rb +5 -5
- data/lib/mmplayer/midi/wrapper.rb +7 -7
- data/test/player/wrapper_test.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e74c731c6f21c8e233b1dae20c6b75386c5eef1b
|
4
|
+
data.tar.gz: b78ef8859fdf7398b1eb039e093344edebffee21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 060bce2db01515989f4d678de3a06b7ff8277deced0489551d05f3b45157c25ec0091f4bdaef5f2d1037b8c8d3ca48b10de0114ec969904658e9f0123efcd4f8
|
7
|
+
data.tar.gz: a2a2096f65fd09ee90cd5af7d07e7d553ea7f54faaa0db173368dd990483451e0a4f23e3021a6b6fae27b316cc1da8e08cf1695d60904bb876ecb6eb5aa61c85
|
data/lib/mmplayer.rb
CHANGED
data/lib/mmplayer/context.rb
CHANGED
@@ -11,9 +11,9 @@ module MMPlayer
|
|
11
11
|
|
12
12
|
# @param [UniMIDI::Input, Array<UniMIDI::Input>] midi_input
|
13
13
|
# @param [Hash] options
|
14
|
-
# @option options [
|
14
|
+
# @option options [Integer] :midi_buffer_length Length of MIDI message buffer in seconds
|
15
15
|
# @option options [String] :mplayer_flags The command-line flags to invoke MPlayer with
|
16
|
-
# @option options [
|
16
|
+
# @option options [Integer] :receive_channel (also: :rx_channel) A MIDI channel to subscribe to. By default, responds to all
|
17
17
|
# @yield
|
18
18
|
def initialize(midi_input, options = {}, &block)
|
19
19
|
midi_options = {
|
@@ -6,15 +6,15 @@ module MMPlayer
|
|
6
6
|
module Numbers
|
7
7
|
|
8
8
|
# Converts a percentage to a 7-bit int value eg 50 -> 0x40
|
9
|
-
# @param [
|
10
|
-
# @return [
|
9
|
+
# @param [Integer] num
|
10
|
+
# @return [Integer]
|
11
11
|
def to_midi_value(num)
|
12
12
|
Scale.transform(num).from(0..100).to(0..127.0).round
|
13
13
|
end
|
14
14
|
|
15
15
|
# Converts a MIDI 7-bit int value to a percentage eg 0x40 -> 50
|
16
|
-
# @param [
|
17
|
-
# @return [
|
16
|
+
# @param [Integer] num
|
17
|
+
# @return [Integer]
|
18
18
|
def to_percent(num)
|
19
19
|
Scale.transform(num).from(0..127).to(0..100.0).round
|
20
20
|
end
|
@@ -6,7 +6,7 @@ module MMPlayer
|
|
6
6
|
module MIDI
|
7
7
|
|
8
8
|
# Set the MIDI channel to receive messages on
|
9
|
-
# @param [
|
9
|
+
# @param [Integer, nil] num The channel number 0-15 or nil for all
|
10
10
|
def receive_channel(num)
|
11
11
|
@midi.channel = num
|
12
12
|
end
|
@@ -22,7 +22,7 @@ module MMPlayer
|
|
22
22
|
alias_method :system, :on_system
|
23
23
|
|
24
24
|
# Assign a callback for a given MIDI note
|
25
|
-
# @param [
|
25
|
+
# @param [Integer, String] note A MIDI note eg 64 "F4" or nil for all
|
26
26
|
# @param [Proc] callback The callback to execute when a matching message is received
|
27
27
|
# @return [Hash]
|
28
28
|
def on_note(note = nil, &callback)
|
@@ -31,7 +31,7 @@ module MMPlayer
|
|
31
31
|
alias_method :note, :on_note
|
32
32
|
|
33
33
|
# Assign a callback for the given MIDI control change
|
34
|
-
# @param [
|
34
|
+
# @param [Integer] index The MIDI control change index to assign the callback for or nil for all
|
35
35
|
# @param [Proc] callback The callback to execute when a matching message is received
|
36
36
|
# @return [Hash]
|
37
37
|
def on_cc(index = nil, &callback)
|
@@ -16,7 +16,7 @@ module MMPlayer
|
|
16
16
|
|
17
17
|
# Add a callback for a given MIDI message type
|
18
18
|
# @param [Symbol] type The MIDI message type (eg :note, :cc)
|
19
|
-
# @param [
|
19
|
+
# @param [Integer, String] key The ID of the message eg note number/cc index
|
20
20
|
# @param [Proc] callback The callback to execute when the given MIDI command is received
|
21
21
|
# @return [Hash]
|
22
22
|
def add_callback(type, key, &callback)
|
@@ -26,7 +26,7 @@ module MMPlayer
|
|
26
26
|
|
27
27
|
# Add a callback for a given MIDI note
|
28
28
|
# @param [Symbol] type The MIDI message type (eg :note, :cc)
|
29
|
-
# @param [
|
29
|
+
# @param [Integer, String] note
|
30
30
|
# @param [Proc] callback The callback to execute when the given MIDI command is received
|
31
31
|
# @return [Hash]
|
32
32
|
def add_note_callback(note, &callback)
|
@@ -35,12 +35,12 @@ module MMPlayer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Process a message for the given channel
|
38
|
-
# @param [
|
38
|
+
# @param [Integer, nil] channel
|
39
39
|
# @param [MIDIMessage] message
|
40
40
|
# @return [Boolean, nil]
|
41
41
|
def process(channel, message)
|
42
42
|
case message
|
43
|
-
when MIDIMessage::SystemCommon, MIDIMessage::SystemRealtime then system_message(message)
|
43
|
+
when MIDIMessage::SystemCommon, MIDIMessage::SystemExclusive, MIDIMessage::SystemRealtime then system_message(message)
|
44
44
|
else
|
45
45
|
channel_message(channel, message)
|
46
46
|
end
|
@@ -71,7 +71,7 @@ module MMPlayer
|
|
71
71
|
end
|
72
72
|
|
73
73
|
# Find and call a channel message callback if it exists for the given message and channel
|
74
|
-
# @param [
|
74
|
+
# @param [Integer, nil] channel
|
75
75
|
# @param [MIDIMessage] message
|
76
76
|
# @return [Boolean, nil]
|
77
77
|
def channel_message(channel, message)
|
@@ -9,8 +9,8 @@ module MMPlayer
|
|
9
9
|
|
10
10
|
# @param [UniMIDI::Input, Array<UniMIDI::Input>] input
|
11
11
|
# @param [Hash] options
|
12
|
-
# @option options [
|
13
|
-
# @option options [
|
12
|
+
# @option options [Integer] :buffer_length Length of MIDI message buffer in seconds
|
13
|
+
# @option options [Integer] :receive_channel A MIDI channel to subscribe to. By default, responds to all
|
14
14
|
def initialize(input, options = {})
|
15
15
|
@buffer_length = options[:buffer_length]
|
16
16
|
@channel = options[:receive_channel]
|
@@ -28,7 +28,7 @@ module MMPlayer
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Add a callback for a given MIDI note
|
31
|
-
# @param [
|
31
|
+
# @param [Integer, String, nil] note The MIDI note to add a callback for eg 64 "E4"
|
32
32
|
# @param [Proc] callback The callback to execute when the given MIDI note is received
|
33
33
|
# @return [Hash]
|
34
34
|
def add_note_callback(note, &callback)
|
@@ -36,7 +36,7 @@ module MMPlayer
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Add a callback for a given MIDI control change
|
39
|
-
# @param [
|
39
|
+
# @param [Integer, nil] index The MIDI control change index to add a callback for eg 10
|
40
40
|
# @param [Proc] callback The callback to execute when the given MIDI control change is received
|
41
41
|
# @return [Hash]
|
42
42
|
def add_cc_callback(index, &callback)
|
@@ -50,8 +50,8 @@ module MMPlayer
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Change the subscribed MIDI channel (or nil for all)
|
53
|
-
# @param [
|
54
|
-
# @return [
|
53
|
+
# @param [Integer, nil] channel
|
54
|
+
# @return [Integer, nil]
|
55
55
|
def channel=(channel)
|
56
56
|
@listener.event.clear
|
57
57
|
@channel = channel
|
@@ -77,7 +77,7 @@ module MMPlayer
|
|
77
77
|
private
|
78
78
|
|
79
79
|
# Elapsed time since start in seconds
|
80
|
-
# @return [
|
80
|
+
# @return [Integer]
|
81
81
|
def now
|
82
82
|
Time.now.to_i - @start_time
|
83
83
|
end
|
data/test/player/wrapper_test.rb
CHANGED
@@ -55,7 +55,7 @@ class MMPlayer::Player::WrapperTest < Minitest::Test
|
|
55
55
|
should "calcuate percentage" do
|
56
56
|
val = @player.send(:get_percentage, { :length => 10.1, :position => 5.5 })
|
57
57
|
refute_nil val
|
58
|
-
|
58
|
+
assert val.kind_of?(Integer)
|
59
59
|
assert_equal 54, val
|
60
60
|
end
|
61
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmplayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -224,7 +224,7 @@ files:
|
|
224
224
|
- test/player/wrapper_test.rb
|
225
225
|
homepage: http://github.com/arirusso/mmplayer
|
226
226
|
licenses:
|
227
|
-
- Apache
|
227
|
+
- Apache-2.0
|
228
228
|
metadata: {}
|
229
229
|
post_install_message:
|
230
230
|
rdoc_options: []
|
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: 1.3.6
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project: mmplayer
|
245
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.6.8
|
246
246
|
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: Control MPlayer with MIDI
|