Class: Synthesizer::NotePerform

Inherits:
Object
  • Object
show all
Defined in:
lib/synthesizer/note_perform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(synth, note, velocity) ⇒ NotePerform

Returns a new instance of NotePerform.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/synthesizer/note_perform.rb', line 8

def initialize(synth, note, velocity)
  @synth = synth
  @note = note
  @velocity = velocity

  @processors = synth.oscillators.map {|osc|
    synth.processor.generator(osc, self)
  }

  @note_on = true
  @released = false
end

Instance Attribute Details

#noteObject (readonly)

Returns the value of attribute note.



5
6
7
# File 'lib/synthesizer/note_perform.rb', line 5

def note
  @note
end

#synthObject (readonly)

Returns the value of attribute synth.



4
5
6
# File 'lib/synthesizer/note_perform.rb', line 4

def synth
  @synth
end

#velocityObject (readonly)

Returns the value of attribute velocity.



6
7
8
# File 'lib/synthesizer/note_perform.rb', line 6

def velocity
  @velocity
end

Instance Method Details

#nextObject



21
22
23
24
25
26
27
28
# File 'lib/synthesizer/note_perform.rb', line 21

def next
  begin
    @processors.map(&:[]).inject(:+)
  rescue StopIteration => e
    @released = true
    nil
  end
end

#note_off!Object



34
35
36
# File 'lib/synthesizer/note_perform.rb', line 34

def note_off!
  @note_on = false
end

#note_on?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/synthesizer/note_perform.rb', line 30

def note_on?
  @note_on
end

#released?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/synthesizer/note_perform.rb', line 38

def released?
  @released
end