Module: Musa::Datasets::AbsD
Overview
Absolute events with duration.
AbsD represents absolute events that have duration - they occupy a time span rather than occurring at a single instant.
Natural Keys
- :duration: Total duration of the event process
- :note_duration: Actual note duration (may differ for staccato, etc.)
- :forward_duration: Time until next event (may be 0 for simultaneous events)
Duration Types
duration: How long the event process lasts (note playing, dynamics change, etc.)
note_duration: Actual note length. For staccato, this is shorter than duration. Defaults to duration if not specified.
forward_duration: Time to wait before next event. Can be:
- Same as duration (default): next event starts when this one ends
- Less than duration: events overlap
- Zero: next event starts simultaneously
- More than duration: gap/rest before next event
Constant Summary collapse
- NaturalKeys =
Natural keys including duration variants.
(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
-
.is_compatible?(thing) ⇒ Boolean
Checks if thing can be converted to AbsD.
-
.to_AbsD(thing) ⇒ AbsD
Converts thing to AbsD if possible.
Instance Method Summary collapse
-
#duration ⇒ Numeric
Returns event duration.
-
#forward_duration ⇒ Numeric
Returns forward duration (time until next event).
-
#note_duration ⇒ Numeric
Returns actual note duration.
-
#valid? ⇒ Boolean
included
from E
Checks if event is valid.
-
#validate! ⇒ void
included
from E
Validates event, raising if invalid.
Class Method Details
.is_compatible?(thing) ⇒ Boolean
Checks if thing can be converted to AbsD.
240 241 242 |
# File 'lib/musa-dsl/datasets/e.rb', line 240 def self.is_compatible?(thing) thing.is_a?(AbsD) || thing.is_a?(Hash) && thing.has_key?(:duration) end |
.to_AbsD(thing) ⇒ AbsD
Converts thing to AbsD if possible.
252 253 254 255 256 257 258 259 260 |
# File 'lib/musa-dsl/datasets/e.rb', line 252 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
#duration ⇒ Numeric
Returns event duration.
228 229 230 |
# File 'lib/musa-dsl/datasets/e.rb', line 228 def duration self[:duration] end |
#forward_duration ⇒ Numeric
Returns forward duration (time until next event).
Defaults to :duration if :forward_duration not specified.
206 207 208 |
# File 'lib/musa-dsl/datasets/e.rb', line 206 def forward_duration self[:forward_duration] || self[:duration] end |
#note_duration ⇒ Numeric
Returns actual note duration.
Defaults to :duration if :note_duration not specified.
218 219 220 |
# File 'lib/musa-dsl/datasets/e.rb', line 218 def note_duration self[:note_duration] || self[:duration] end |
#valid? ⇒ Boolean Originally defined in module E
Checks if event is valid.
Base implementation always returns true. Subclasses should override to implement specific validation logic.
#validate! ⇒ void Originally defined in module E
This method returns an undefined value.
Validates event, raising if invalid.