Module: Musa::Datasets::AbsD

Includes:
Abs
Included in:
GDV, PDV, PS, Score
Defined in:
lib/musa-dsl/datasets/e.rb

Constant Summary collapse

NaturalKeys =
(NaturalKeys +
[:duration, # duration of the process (note reproduction, dynamics evolution, etc)
 :note_duration, # duration of the note (a staccato note is effectively shorter than elapsed duration until next note)
 :forward_duration # duration to wait until next event (if 0 means the next event should be executed at the same time than this one)
]).freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from E

#valid?, #validate!

Class Method Details

.is_compatible?(thing) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/musa-dsl/datasets/e.rb', line 64

def self.is_compatible?(thing)
  thing.is_a?(AbsD) || thing.is_a?(Hash) && thing.has_key?(:duration)
end

.to_AbsD(thing) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/musa-dsl/datasets/e.rb', line 68

def self.to_AbsD(thing)
  if thing.is_a?(AbsD)
    thing
  elsif thing.is_a?(Hash) && thing.has_key?(:duration)
    thing.clone.extend(AbsD)
  else
    raise ArgumentError, "Cannot convert #{thing} to AbsD dataset"
  end
end

Instance Method Details

#durationObject



60
61
62
# File 'lib/musa-dsl/datasets/e.rb', line 60

def duration
  self[:duration]
end

#forward_durationObject



52
53
54
# File 'lib/musa-dsl/datasets/e.rb', line 52

def forward_duration
  self[:forward_duration] || self[:duration]
end

#note_durationObject



56
57
58
# File 'lib/musa-dsl/datasets/e.rb', line 56

def note_duration
  self[:note_duration] || self[:duration]
end