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 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)
@@ -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
- if result[:messages].length < 2
58
- (result[:messages].empty? ? nil : result[:messages][0])
59
- else
60
- result[:messages]
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
@@ -16,7 +16,7 @@ require 'nibbler/hex_char_array_filter'
16
16
  #
17
17
  module Nibbler
18
18
 
19
- VERSION = "0.0.3"
19
+ VERSION = "0.0.4"
20
20
 
21
21
  # shortcut to Parser.new
22
22
  def self.new(*a, &block)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: midi-nibbler
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ari Russo