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.
18 19 20 21 22 23 24 25 |
# File 'lib/jsound/midi/devices/recorder.rb', line 18 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.
Timestamps are in floating point seconds.
11 12 13 |
# File 'lib/jsound/midi/devices/recorder.rb', line 11 def @messages_with_timestamps end |
Instance Method Details
#clear ⇒ Object
clear any recorded messages
28 29 30 |
# File 'lib/jsound/midi/devices/recorder.rb', line 28 def clear @messages_with_timestamps = [] end |
#close ⇒ Object Also known as: stop
stop recording
39 40 41 |
# File 'lib/jsound/midi/devices/recorder.rb', line 39 def close @recording = false end |
#message(message) ⇒ Object
54 55 56 |
# File 'lib/jsound/midi/devices/recorder.rb', line 54 def () @messages_with_timestamps << [, Time.now.to_f] if recording? end |
#messages ⇒ Object
The recorded messages without timestamps
14 15 16 |
# File 'lib/jsound/midi/devices/recorder.rb', line 14 def @messages_with_timestamps.map{|m,t| m } end |
#open ⇒ Object Also known as: start
start recording
33 34 35 |
# File 'lib/jsound/midi/devices/recorder.rb', line 33 def open @recording = true end |
#open? ⇒ Boolean Also known as: recording?
true if this object is currently recording
45 46 47 |
# File 'lib/jsound/midi/devices/recorder.rb', line 45 def open? @recording end |
#output=(device) ⇒ Object
50 51 52 |
# File 'lib/jsound/midi/devices/recorder.rb', line 50 def output= device raise "#{self.class} cannot be assigned an output" end |