Class: InevitableCacophony::Note

Inherits:
Struct
  • Object
show all
Defined in:
lib/inevitable_cacophony/note.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ratio, beat) ⇒ Note

Returns a new instance of Note.

Parameters:

  • amplitude (Rhythm::Beat)

    A Beat object defining amplitude and timing



11
12
13
# File 'lib/inevitable_cacophony/note.rb', line 11

def initialize(ratio, beat)
	super(ratio, beat)
end

Instance Attribute Details

#beatObject

Returns the value of attribute beat

Returns:

  • (Object)

    the current value of beat



7
8
9
# File 'lib/inevitable_cacophony/note.rb', line 7

def beat
  @beat
end

#ratioObject

Returns the value of attribute ratio

Returns:

  • (Object)

    the current value of ratio



7
8
9
# File 'lib/inevitable_cacophony/note.rb', line 7

def ratio
  @ratio
end

Class Method Details

.rest(beat) ⇒ Object

Create a rest for the duration of the given beat.

Parameters:

  • beat (Beat)


17
18
19
20
21
# File 'lib/inevitable_cacophony/note.rb', line 17

def self.rest(beat)
        
	# Can't set ratio to 0 as it causes divide-by-zero errors
	new(1, Rhythm::Beat.new(0, beat.duration, beat.timing))
end

Instance Method Details

#after_delayObject



27
28
29
# File 'lib/inevitable_cacophony/note.rb', line 27

def after_delay
	beat.after_delay
end

#durationObject



31
32
33
# File 'lib/inevitable_cacophony/note.rb', line 31

def duration
	beat.duration
end

#frequencyObject



35
36
37
# File 'lib/inevitable_cacophony/note.rb', line 35

def frequency
       ratio
end

#start_delayObject



23
24
25
# File 'lib/inevitable_cacophony/note.rb', line 23

def start_delay
	beat.start_delay
end