Class: Sidtool::Voice

Inherits:
Object
  • Object
show all
Defined in:
lib/sidtool/voice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVoice

Returns a new instance of Voice.



11
12
13
14
15
16
17
# File 'lib/sidtool/voice.rb', line 11

def initialize
  @frequency_low = @frequency_high = 0
  @pulse_low = @pulse_high = 0
  @attack_decay = @sustain_release = 0
  @control_register = 0
  @synth = nil
end

Instance Attribute Details

#attack_decay=(value) ⇒ Object (writeonly)

Sets the attribute attack_decay

Parameters:

  • value

    the value to set the attribute attack_decay to.



8
9
10
# File 'lib/sidtool/voice.rb', line 8

def attack_decay=(value)
  @attack_decay = value
end

#control_register=(value) ⇒ Object (writeonly)

Sets the attribute control_register

Parameters:

  • value

    the value to set the attribute control_register to.



7
8
9
# File 'lib/sidtool/voice.rb', line 7

def control_register=(value)
  @control_register = value
end

#frequency_high=(value) ⇒ Object (writeonly)

Sets the attribute frequency_high

Parameters:

  • value

    the value to set the attribute frequency_high to.



4
5
6
# File 'lib/sidtool/voice.rb', line 4

def frequency_high=(value)
  @frequency_high = value
end

#frequency_low=(value) ⇒ Object (writeonly)

Sets the attribute frequency_low

Parameters:

  • value

    the value to set the attribute frequency_low to.



3
4
5
# File 'lib/sidtool/voice.rb', line 3

def frequency_low=(value)
  @frequency_low = value
end

#pulse_high=(value) ⇒ Object (writeonly)

Sets the attribute pulse_high

Parameters:

  • value

    the value to set the attribute pulse_high to.



6
7
8
# File 'lib/sidtool/voice.rb', line 6

def pulse_high=(value)
  @pulse_high = value
end

#pulse_low=(value) ⇒ Object (writeonly)

Sets the attribute pulse_low

Parameters:

  • value

    the value to set the attribute pulse_low to.



5
6
7
# File 'lib/sidtool/voice.rb', line 5

def pulse_low=(value)
  @pulse_low = value
end

#sustain_release=(value) ⇒ Object (writeonly)

Sets the attribute sustain_release

Parameters:

  • value

    the value to set the attribute sustain_release to.



9
10
11
# File 'lib/sidtool/voice.rb', line 9

def sustain_release=(value)
  @sustain_release = value
end

Instance Method Details

#finish_frameObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sidtool/voice.rb', line 19

def finish_frame
  if gate
    if frequency > 0
      unless @synth
        @synth = Synth.new(STATE.current_frame)
        STATE.synths << @synth
      end
      @synth.frequency = frequency
      @synth.waveform = waveform
      @synth.attack = attack
      @synth.decay = decay
      @synth.release = release
    end
  else
    @synth&.release!
    @synth = nil
  end
end

#stop!Object



38
39
40
41
# File 'lib/sidtool/voice.rb', line 38

def stop!
  @synth&.stop!
  @synth = nil
end