Class: Sidtool::Voice
- Inherits:
-
Object
- Object
- Sidtool::Voice
- Defined in:
- lib/sidtool/voice.rb
Instance Attribute Summary collapse
-
#attack_decay ⇒ Object
writeonly
Sets the attribute attack_decay.
-
#control_register ⇒ Object
writeonly
Sets the attribute control_register.
-
#frequency_high ⇒ Object
writeonly
Sets the attribute frequency_high.
-
#frequency_low ⇒ Object
writeonly
Sets the attribute frequency_low.
-
#pulse_high ⇒ Object
writeonly
Sets the attribute pulse_high.
-
#pulse_low ⇒ Object
writeonly
Sets the attribute pulse_low.
-
#sustain_release ⇒ Object
writeonly
Sets the attribute sustain_release.
-
#synths ⇒ Object
readonly
Returns the value of attribute synths.
Instance Method Summary collapse
- #finish_frame ⇒ Object
-
#initialize ⇒ Voice
constructor
A new instance of Voice.
- #stop! ⇒ Object
Constructor Details
#initialize ⇒ Voice
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
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
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
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
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
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
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
9 10 11 |
# File 'lib/sidtool/voice.rb', line 9 def sustain_release=(value) @sustain_release = value end |
#synths ⇒ Object (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_frame ⇒ Object
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 |