midi-eye 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/midi-eye.rb +1 -1
- data/lib/midi-eye/event.rb +17 -2
- data/lib/midi-eye/listener.rb +2 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47626fcd0bb5dcea8792ba0e9d78a40c432af06
|
4
|
+
data.tar.gz: 897075b6685648cbb7863e35d765f46d77400404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eae17bf98762357e26ca3bb855ded062cda3e4cd54e9f5a2431a2b9b4fc70b191f43128ebb1ed4f30a256aa00b58aab3bf9ac10731942eed63b10ee84425736
|
7
|
+
data.tar.gz: 3aa56326edc074401fffeaa1a881c7daa3bcc4d8cf7f6bfd873dfe79cc58b8e1d0b15b95692c08fd79c215876237d140f5757e2a879ec3fc6370738528fe3c12
|
data/lib/midi-eye.rb
CHANGED
data/lib/midi-eye/event.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module MIDIEye
|
2
2
|
|
3
|
+
# User defined callbacks for input events
|
3
4
|
class Event
|
4
5
|
|
5
6
|
def initialize
|
@@ -13,11 +14,18 @@ module MIDIEye
|
|
13
14
|
@event.delete_if { |event| event[:listener_name].to_s == name.to_s }
|
14
15
|
end
|
15
16
|
|
17
|
+
# Clear the collection of events
|
18
|
+
# @return [Boolean]
|
16
19
|
def clear
|
17
20
|
@event.clear
|
18
21
|
@queue.clear
|
22
|
+
true
|
19
23
|
end
|
20
24
|
|
25
|
+
# Add a user-defined input callback
|
26
|
+
# @param [Hash] options
|
27
|
+
# @param [Proc] callback
|
28
|
+
# @return [Hash]
|
21
29
|
def add(options = {}, &callback)
|
22
30
|
name = options[:listener_name]
|
23
31
|
options.delete(:listener_name)
|
@@ -31,6 +39,7 @@ module MIDIEye
|
|
31
39
|
end
|
32
40
|
|
33
41
|
# Trigger all enqueued events
|
42
|
+
# @return [Fixnum] The number of triggered events
|
34
43
|
def trigger_enqueued
|
35
44
|
counter = 0
|
36
45
|
while !@queue.empty? do
|
@@ -40,19 +49,25 @@ module MIDIEye
|
|
40
49
|
counter
|
41
50
|
end
|
42
51
|
|
52
|
+
# Enqueue all events with the given message
|
53
|
+
# @return [Array<Hash>]
|
43
54
|
def enqueue_all(message)
|
44
|
-
@event.
|
55
|
+
@event.map { |action| enqueue(action, message) }
|
45
56
|
end
|
46
57
|
|
47
|
-
# Add an event to the trigger queue
|
58
|
+
# Add an event to the trigger queue
|
59
|
+
# @return [Hash]
|
48
60
|
def enqueue(action, message)
|
49
61
|
event = {
|
50
62
|
:action => action,
|
51
63
|
:message => message
|
52
64
|
}
|
53
65
|
@queue << event
|
66
|
+
event
|
54
67
|
end
|
55
68
|
|
69
|
+
# The number of events
|
70
|
+
# @return [Fixnum]
|
56
71
|
def count
|
57
72
|
@event.count
|
58
73
|
end
|
data/lib/midi-eye/listener.rb
CHANGED
@@ -109,10 +109,8 @@ module MIDIEye
|
|
109
109
|
objs.each do |batch|
|
110
110
|
messages = [batch[:messages]].flatten.compact
|
111
111
|
messages.each do |message|
|
112
|
-
|
113
|
-
|
114
|
-
@event.enqueue_all(data)
|
115
|
-
end
|
112
|
+
data = { :message => message, :timestamp => batch[:timestamp] }
|
113
|
+
@event.enqueue_all(data)
|
116
114
|
end
|
117
115
|
end
|
118
116
|
end
|