Class: MIDI::MetaEvent
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#meta_type ⇒ Object
readonly
Returns the value of attribute meta_type.
Attributes inherited from Event
#delta_time, #print_channel_numbers_from_one, #print_decimal_numbers, #print_note_names, #status, #time_from_start
Class Method Summary collapse
Instance Method Summary collapse
- #data_as_bytes ⇒ Object
- #data_as_str ⇒ Object
-
#initialize(meta_type, data = nil, delta_time = 0) ⇒ MetaEvent
constructor
A new instance of MetaEvent.
- #to_s ⇒ Object
Methods inherited from Event
#<=>, #channel_to_s, #number_to_s, #quantize_to
Constructor Details
#initialize(meta_type, data = nil, delta_time = 0) ⇒ MetaEvent
Returns a new instance of MetaEvent.
430 431 432 433 434 |
# File 'lib/midilib/event.rb', line 430 def initialize(, data = nil, delta_time = 0) super(META_EVENT, delta_time) = self.data=(data) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
414 415 416 |
# File 'lib/midilib/event.rb', line 414 def data @data end |
#meta_type ⇒ Object (readonly)
Returns the value of attribute meta_type.
413 414 415 |
# File 'lib/midilib/event.rb', line 413 def end |
Class Method Details
.bytes_as_str(bytes) ⇒ Object
416 417 418 |
# File 'lib/midilib/event.rb', line 416 def self.bytes_as_str(bytes) bytes ? bytes.collect { |byte| byte.chr }.join : nil end |
.str_as_bytes(str) ⇒ Object
421 422 423 |
# File 'lib/midilib/event.rb', line 421 def self.str_as_bytes(str) str.split(//).collect { |chr| chr.ord } end |
Instance Method Details
#data_as_bytes ⇒ Object
436 437 438 439 440 441 442 443 |
# File 'lib/midilib/event.rb', line 436 def data_as_bytes data = [] data << @status data << data << (@data ? Utils.as_var_len(@data.length) : 0) data << @data if @data data.flatten end |
#data_as_str ⇒ Object
445 446 447 |
# File 'lib/midilib/event.rb', line 445 def data_as_str MetaEvent.bytes_as_str(@data) end |
#to_s ⇒ Object
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/midilib/event.rb', line 459 def to_s str = super() str << "meta #{number_to_s(@meta_type)} " # I know, I know...this isn't OO. case when META_SEQ_NUM str << "sequence number" when META_TEXT str << "text: #{data_as_str}" when META_COPYRIGHT str << "copyright: #{data_as_str}" when META_SEQ_NAME str << "sequence or track name: #{data_as_str}" when META_INSTRUMENT str << "instrument name: #{data_as_str}" when META_LYRIC str << "lyric: #{data_as_str}" when META_MARKER str << "marker: #{data_as_str}" when META_CUE str << "cue point: #{@data}" when META_TRACK_END str << "track end" when META_SMPTE str << "smpte" when META_TIME_SIG str << "time signature" when META_KEY_SIG str << "key signature" when META_SEQ_SPECIF str << "sequence specific" else # Some other possible @meta_type values are handled by subclasses. str << "(other)" end return str end |