Class: HeadMusic::Time::TempoEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/time/tempo_event.rb

Overview

Represents a tempo change at a specific musical position

TempoEvent marks a point in a musical timeline where the tempo changes. This is essential for converting between clock time and musical position, as different tempos affect how long each beat takes in real time.

Examples:

Creating a tempo change to quarter = 120 at bar 1

position = HeadMusic::Time::MusicalPosition.new(1, 1, 0, 0)
event = HeadMusic::Time::TempoEvent.new(position, "quarter", 120)

With a dotted quarter note tempo

position = HeadMusic::Time::MusicalPosition.new(5, 1, 0, 0)
event = HeadMusic::Time::TempoEvent.new(position, "dotted quarter", 92)

With an eighth note tempo

position = HeadMusic::Time::MusicalPosition.new(10, 1, 0, 0)
event = HeadMusic::Time::TempoEvent.new(position, "eighth", 140)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position, beat_value, beats_per_minute) ⇒ TempoEvent

Create a new tempo change event

Parameters:

  • position (MusicalPosition)

    where the tempo change occurs

  • beat_value (String)

    the rhythmic value that gets the beat (e.g., “quarter”, “eighth”)

  • beats_per_minute (Numeric)

    the tempo in beats per minute



34
35
36
37
# File 'lib/head_music/time/tempo_event.rb', line 34

def initialize(position, beat_value, beats_per_minute)
  @position = position
  @tempo = HeadMusic::Rudiment::Tempo.new(beat_value, beats_per_minute)
end

Instance Attribute Details

#positionMusicalPosition

Returns the position where this tempo change occurs.

Returns:



24
25
26
# File 'lib/head_music/time/tempo_event.rb', line 24

def position
  @position
end

#tempoHeadMusic::Rudiment::Tempo

Returns the tempo.

Returns:



27
28
29
# File 'lib/head_music/time/tempo_event.rb', line 27

def tempo
  @tempo
end