Class: JSound::Midi::Devices::Recorder
- Inherits:
-
JSound::Midi::Device
- Object
- JSound::Midi::Device
- JSound::Midi::Devices::Recorder
- Defined in:
- lib/jsound/midi/devices/recorder.rb
Overview
A Device that records incoming messages, and the timestamp at which they were received.
Instance Attribute Summary collapse
-
#messages_with_timestamps ⇒ Object
readonly
The recorded [message,timestamp] pairs.
Instance Method Summary collapse
-
#clear ⇒ Object
clear any recorded messages.
-
#close ⇒ Object
(also: #stop)
stop recording.
-
#initialize(autostart = true) ⇒ Recorder
constructor
A new instance of Recorder.
- #message(message) ⇒ Object
-
#messages ⇒ Object
The recorded messages without timestamps.
-
#open ⇒ Object
(also: #start)
start recording.
-
#open? ⇒ Boolean
(also: #recording?)
true if this object is currently recording.
- #output=(device) ⇒ Object
Methods inherited from JSound::Midi::Device
#<=, #>>, #output, #to_s, #type
Methods included from TypeFromClassName
Constructor Details
#initialize(autostart = true) ⇒ Recorder
Returns a new instance of Recorder.
16 17 18 19 20 21 22 23 |
# File 'lib/jsound/midi/devices/recorder.rb', line 16 def initialize(autostart=true) clear if autostart start else stop end end |
Instance Attribute Details
#messages_with_timestamps ⇒ Object (readonly)
The recorded [message,timestamp] pairs
9 10 11 |
# File 'lib/jsound/midi/devices/recorder.rb', line 9 def @messages_with_timestamps end |
Instance Method Details
#clear ⇒ Object
clear any recorded messages
26 27 28 |
# File 'lib/jsound/midi/devices/recorder.rb', line 26 def clear @messages_with_timestamps = [] end |
#close ⇒ Object Also known as: stop
stop recording
37 38 39 |
# File 'lib/jsound/midi/devices/recorder.rb', line 37 def close @recording = false end |
#message(message) ⇒ Object
52 53 54 |
# File 'lib/jsound/midi/devices/recorder.rb', line 52 def () @messages_with_timestamps << [, Time.now.to_i] if recording? end |
#messages ⇒ Object
The recorded messages without timestamps
12 13 14 |
# File 'lib/jsound/midi/devices/recorder.rb', line 12 def @messages_with_timestamps.map{|m,t| m } end |
#open ⇒ Object Also known as: start
start recording
31 32 33 |
# File 'lib/jsound/midi/devices/recorder.rb', line 31 def open @recording = true end |
#open? ⇒ Boolean Also known as: recording?
true if this object is currently recording
43 44 45 |
# File 'lib/jsound/midi/devices/recorder.rb', line 43 def open? @recording end |
#output=(device) ⇒ Object
48 49 50 |
# File 'lib/jsound/midi/devices/recorder.rb', line 48 def output= device raise "#{self.class} cannot be assigned an output" end |