Class: Sidtool::Sid

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

Instance Method Summary collapse

Constructor Details

#initializeSid

Returns a new instance of Sid.



3
4
5
6
7
8
9
10
# File 'lib/sidtool/sid.rb', line 3

def initialize
  @voices = [Voice.new, Voice.new, Voice.new]

  @frequency_low = @frequency_high = 0
  @pulse_low = @pulse_high = 0
  @control_register = 0
  @attack_decay = @sustain_release = 0
end

Instance Method Details

#finish_frameObject



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

def finish_frame
  @voices.each(&:finish_frame)
end

#poke(register, value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sidtool/sid.rb', line 12

def poke(register, value)
  if register >= 0 && register <= 6
    voice = @voices[0]
  elsif register >= 7 && register <=13
    voice = @voices[1]
    register -=7
  elsif register >= 14 && register <=20
    voice = @voices[2]
    register -=14
  end

  case register
  when 0 then voice.frequency_low = value
  when 1 then voice.frequency_high = value
  when 2 then voice.pulse_low = value
  when 3 then voice.pulse_high = value
  when 4 then voice.control_register = value
  when 5 then voice.attack_decay = value
  when 6 then voice.sustain_release = value
    # 7-20 are covered by the mapping above
  when 21 then @cutoff_frequency_low = value
  when 22 then @cutoff_frequency_high = value
  when 23 then @resonance_filter = value
  when 24 then @mode_volume = value
  end
end

#stop!Object



43
44
45
# File 'lib/sidtool/sid.rb', line 43

def stop!
  @voices.each(&:stop!)
end

#synths_for_voicesObject



47
48
49
# File 'lib/sidtool/sid.rb', line 47

def synths_for_voices
  @voices.map(&:synths)
end