Class: InevitableCacophony::Rhythm::Beat
- Inherits:
-
Struct
- Object
- Struct
- InevitableCacophony::Rhythm::Beat
- Defined in:
- lib/inevitable_cacophony/rhythm.rb
Overview
Amplitude – how loud the beat is, on a scale from silent to MAX VOLUME. Duration – how long it is, in arbitrary beat units (think metronome ticks) Timing – how early or late the beat is, relative to the same metaphorical metronome.
Instance Attribute Summary collapse
-
#amplitude ⇒ Object
Returns the value of attribute amplitude.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#timing ⇒ Object
Returns the value of attribute timing.
Instance Method Summary collapse
-
#after_delay ⇒ Float
How much silence there is after this note ends, before the next note’s timeslot.
-
#sounding_time ⇒ Object
How long this note sounds for, excluding any start/end delays.
-
#start_delay ⇒ Float
How much silence there is before this note starts, after the previous note has finished its time (like padding in CSS).
-
#start_offset ⇒ Float
How much earlier or later than normal this beat’s time slice should start, accounting for the standard start/end delays, timing, and duration.
Instance Attribute Details
#amplitude ⇒ Object
Returns the value of attribute amplitude
17 18 19 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 17 def amplitude @amplitude end |
#duration ⇒ Object
Returns the value of attribute duration
17 18 19 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 17 def duration @duration end |
#timing ⇒ Object
Returns the value of attribute timing
17 18 19 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 17 def timing @timing end |
Instance Method Details
#after_delay ⇒ Float
How much silence there is after this note ends, before the next note’s timeslot.
41 42 43 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 41 def after_delay start_and_after_delays.last * duration end |
#sounding_time ⇒ Object
How long this note sounds for, excluding any start/end delays.
47 48 49 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 47 def sounding_time duration * (1 - start_and_after_delays.sum) end |
#start_delay ⇒ Float
How much silence there is before this note starts, after the previous note has finished its time (like padding in CSS).
33 34 35 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 33 def start_delay start_and_after_delays.first * duration end |
#start_offset ⇒ Float
How much earlier or later than normal this beat’s time slice should start, accounting for the standard start/end delays, timing, and duration. Negative numbers start earlier, positive ones later.
24 25 26 27 |
# File 'lib/inevitable_cacophony/rhythm.rb', line 24 def start_offset standard_start_delay = START_DELAY * duration start_delay - standard_start_delay end |