midi-nibbler 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/lib/nibbler/nibbler.rb +5 -5
- data/lib/nibbler.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -88,6 +88,11 @@ See progress
|
|
88
88
|
p nibbler.buffer_hex
|
89
89
|
"940"
|
90
90
|
|
91
|
+
Pass in a timestamp
|
92
|
+
|
93
|
+
p nibbler.parse("904040", :timestamp => Time.now.to_i)
|
94
|
+
# { :messages=> #<MIDIMessage::NoteOn:0x92f4564 ..>, :timestamp=>1304488440 }
|
95
|
+
|
91
96
|
Nibbler defaults to generate {midi-message}[http://github.com/arirusso/midi-message] objects, but it is also possible to use {midilib}[https://github.com/jimm/midilib]
|
92
97
|
|
93
98
|
Nibbler.new(:message_lib => :midilib)
|
data/lib/nibbler/nibbler.rb
CHANGED
@@ -43,6 +43,7 @@ module Nibbler
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def parse(*a)
|
46
|
+
options = a.last.kind_of?(Hash) ? a.pop : nil
|
46
47
|
queue = @typefilter.process(a)
|
47
48
|
result = @parser.process(queue)
|
48
49
|
@messages += result[:messages]
|
@@ -54,11 +55,10 @@ module Nibbler
|
|
54
55
|
# 1 message: the message
|
55
56
|
# >1 message: an array of messages
|
56
57
|
# might make sense to make this an array no matter what...
|
57
|
-
|
58
|
-
(result[:messages].empty? ? nil : result[:messages][0])
|
59
|
-
|
60
|
-
|
61
|
-
end
|
58
|
+
output = result[:messages].length < 2 ?
|
59
|
+
(result[:messages].empty? ? nil : result[:messages][0]) : result[:messages]
|
60
|
+
output = { :messages => output, :timestamp => options[:timestamp] } unless options.nil? || options[:timestamp].nil?
|
61
|
+
output
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
data/lib/nibbler.rb
CHANGED