Class: MIDI::MetaEvent
Instance Attribute Summary collapse
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
Methods inherited from Event
#<=>, #channel_to_s, #number_to_s, #quantize_to
Constructor Details
#initialize(meta_type, data = nil, delta_time = 0) ⇒ MetaEvent
431
432
433
434
435
|
# File 'lib/midilib/event.rb', line 431
def initialize(meta_type, data = nil, delta_time = 0)
super(META_EVENT, delta_time)
@meta_type = meta_type
self.data = (data)
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
421
422
423
|
# File 'lib/midilib/event.rb', line 421
def data
@data
end
|
Returns the value of attribute meta_type.
421
422
423
|
# File 'lib/midilib/event.rb', line 421
def meta_type
@meta_type
end
|
Class Method Details
.bytes_as_str(bytes) ⇒ Object
423
424
425
|
# File 'lib/midilib/event.rb', line 423
def self.bytes_as_str(bytes)
bytes ? bytes.collect { |byte| byte.chr }.join : nil
end
|
.str_as_bytes(str) ⇒ Object
427
428
429
|
# File 'lib/midilib/event.rb', line 427
def self.str_as_bytes(str)
str.split(//).collect { |chr| chr.ord }
end
|
Instance Method Details
#data_as_bytes ⇒ Object
437
438
439
440
441
442
443
444
|
# File 'lib/midilib/event.rb', line 437
def data_as_bytes
data = []
data << @status
data << @meta_type
data << (@data ? Utils.as_var_len(@data.length) : 0)
data << @data if @data
data.flatten
end
|
#data_as_str ⇒ Object
446
447
448
|
# File 'lib/midilib/event.rb', line 446
def data_as_str
MetaEvent.bytes_as_str(@data)
end
|
#to_s ⇒ Object
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
496
|
# File 'lib/midilib/event.rb', line 460
def to_s
str = super()
str << "meta #{number_to_s(@meta_type)} "
str << case @meta_type
when META_SEQ_NUM
'sequence number'
when META_TEXT
"text: #{data_as_str}"
when META_COPYRIGHT
"copyright: #{data_as_str}"
when META_SEQ_NAME
"sequence or track name: #{data_as_str}"
when META_INSTRUMENT
"instrument name: #{data_as_str}"
when META_LYRIC
"lyric: #{data_as_str}"
when META_MARKER
"marker: #{data_as_str}"
when META_CUE
"cue point: #{@data}"
when META_TRACK_END
'track end'
when META_SMPTE
'smpte'
when META_TIME_SIG
'time signature'
when META_KEY_SIG
'key signature'
when META_SEQ_SPECIF
'sequence specific'
else
'(other)'
end
str
end
|