Class: Beats::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/beats/track.rb

Overview

Domain object which models a kit sound playing a rhythm. For example, a bass drum playing every quarter note for two measures.

This object is like sheet music; the AudioEngine is responsible creating actual audio data for a Track (with the help of a Kit).

Defined Under Namespace

Classes: InvalidRhythmError

Constant Summary collapse

REST =
"."
BEAT =
"X"
BARLINE =
"|"
SPACE =
" "
DISALLOWED_CHARACTERS =

I.e., anything not an ‘X’ or a ‘.’

/[^X\.]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, rhythm) ⇒ Track

Returns a new instance of Track.



16
17
18
19
# File 'lib/beats/track.rb', line 16

def initialize(name, rhythm)
  @name = name
  self.rhythm = rhythm
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



31
32
33
# File 'lib/beats/track.rb', line 31

def name
  @name
end

#rhythmObject

Returns the value of attribute rhythm.



31
32
33
# File 'lib/beats/track.rb', line 31

def rhythm
  @rhythm
end

#trigger_step_lengthsObject (readonly)

Returns the value of attribute trigger_step_lengths.



31
32
33
# File 'lib/beats/track.rb', line 31

def trigger_step_lengths
  @trigger_step_lengths
end

Instance Method Details

#step_countObject



27
28
29
# File 'lib/beats/track.rb', line 27

def step_count
  @rhythm.length
end