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.



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

def initialize
  @frequency_low = @frequency_high = 0
  @pulse_low = @pulse_high = 0
  @attack_decay = @sustain_release = 0
  @control_register = 0
  @current_synth = nil
  @synths = []
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

#synthsObject (readonly)

Returns the value of attribute synths.



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

def synths
  @synths
end

Instance Method Details

#finish_frameObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sidtool/voice.rb', line 21

def finish_frame
  if gate
    if @current_synth&.released?
      @current_synth.stop!
      @current_synth = nil
    end

    if frequency > 0
      if !@current_synth
        @current_synth = Synth.new(STATE.current_frame)
        @synths << @current_synth
      end
      @current_synth.frequency = frequency
      @current_synth.waveform = waveform
      @current_synth.attack = attack
      @current_synth.decay = decay
      @current_synth.release = release
    end
  else
    @current_synth&.release!
  end
end

#stop!Object



44
45
46
47
# File 'lib/sidtool/voice.rb', line 44

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