Klasse WaveformGenerator

java.lang.Object
builder.resid.residfp.WaveformGenerator

public final class WaveformGenerator extends Object
A 24-bit accumulator is the basis for waveform generation. FREQ is added to the lower 16 bits of the accumulator each cycle. The accumulator is set to zero when TEST is set and starts counting when TEST is cleared. The noise waveform is taken from intermediate bits of a 23-bit shift register. This register is clocked by bit 19 of the accumulator.
Autor:
Ken Händel
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    private int
    Current and previous accumulator value.
    private int
    Current and previous accumulator value.
    private float[]
     
    private int
    Fout = (Fn*Fclk/16777216)Hz
    private int
    Value in noise XOR register.
    private int
    Time until the Noise XOR register is overwritten.
    private byte
    Cached digital value of OSC3.
    private float
    Cached analog value of OSC3
    private int
    PWout = (PWn/40.95)%
    private boolean
    The control register bits.
    private boolean
    The control register bits.
    private boolean
    The control register bits.
    private int
    The control register right-shifted 4 bits; used for output function table lookup.
    private byte[][]
     
    private float[][]
     
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Constructor.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    private byte
    Noise: The noise output is taken from intermediate bits of a 23-bit shift register which is clocked by bit 19 of the accumulator.
    (Package privat) void
    SID clocking - 1 cycle.
    private void
    clockNoise(boolean clock)
     
    float
    Return the waveform offset.
    float
    output(WaveformGenerator ring_modulator)
    12-bit waveform output.
    private byte
    readOSC(int ringAccumulator, int myAccumulator)
    Calculate OSC3 bitstate from the analog values.
    byte
     
    (Package privat) byte
    Read OSC3 value (6581, not latched/delayed version)
    (Package privat) byte
    Read OSC3 value (8580, 1-clock latched version).
    (Package privat) void
    SID reset.
    (Package privat) void
    setWftable(float[][] newWftable, float[] newDac, byte[][] newWfdigital)
     
    (Package privat) void
    Synchronize oscillators.
    (Package privat) void
    writeCONTROL_REG(WaveformGenerator ring_modulator, byte control)
    Register functions.
    (Package privat) void
    writeFREQ_HI(byte freq_hi)
    Register functions.
    (Package privat) void
    writeFREQ_LO(byte freq_lo)
    Register functions.
    (Package privat) void
    writePW_HI(byte pw_hi)
    Register functions.
    (Package privat) void
    writePW_LO(byte pw_lo)
    Register functions.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • wftable

      private float[][] wftable
    • wfdigital

      private byte[][] wfdigital
    • dac

      private float[] dac
    • accumulator

      private int accumulator
      Current and previous accumulator value.
    • accumulator_prev

      private int accumulator_prev
      Current and previous accumulator value.
    • noiseShiftRegister

      private int noiseShiftRegister
      Value in noise XOR register.
    • noiseShiftRegisterTtl

      private int noiseShiftRegisterTtl
      Time until the Noise XOR register is overwritten.
    • previous

      private byte previous
      Cached digital value of OSC3.
    • previous_dac

      private float previous_dac
      Cached analog value of OSC3
    • freq

      private int freq
      Fout = (Fn*Fclk/16777216)Hz
    • pw

      private int pw
      PWout = (PWn/40.95)%
    • waveform

      private int waveform
      The control register right-shifted 4 bits; used for output function table lookup.
    • test

      private boolean test
      The control register bits. Gate is handled by EnvelopeGenerator.
    • ring

      private boolean ring
      The control register bits. Gate is handled by EnvelopeGenerator.
    • sync

      private boolean sync
      The control register bits. Gate is handled by EnvelopeGenerator.
  • Konstruktordetails

    • WaveformGenerator

      WaveformGenerator()
      Constructor.
  • Methodendetails

    • setWftable

      void setWftable(float[][] newWftable, float[] newDac, byte[][] newWfdigital)
    • clock

      void clock()
      SID clocking - 1 cycle.
    • synchronize

      void synchronize(WaveformGenerator syncDest, WaveformGenerator syncSource)
      Synchronize oscillators. This must be done after all the oscillators have been clock()'ed since the oscillators operate in parallel. Note that the oscillators must be clocked exactly on the cycle when the MSB is set high for hard sync to operate correctly. See SID.clock().
      Parameter:
      syncDest - The oscillator I am syncing
      syncSource - The oscillator syncing me.
    • output

      public float output(WaveformGenerator ring_modulator)
      12-bit waveform output. Select one of 16 possible combinations of waveforms.
      Parameter:
      ring_modulator - The oscillator ring-modulating me.
      Gibt zurück:
      output from waveformgenerator
    • writeFREQ_LO

      void writeFREQ_LO(byte freq_lo)
      Register functions.
      Parameter:
      freq_lo - low 8 bits of frequency
    • writeFREQ_HI

      void writeFREQ_HI(byte freq_hi)
      Register functions.
      Parameter:
      freq_hi - high 8 bits of frequency
    • writePW_LO

      void writePW_LO(byte pw_lo)
      Register functions.

      The original form was (acc >> 12) >= pw, where truth value is not affected by the contents of the low 12 bits. Therefore, the lowest bits must be zero in the new formulation acc >= (pw << 12).

      Parameter:
      pw_lo - low 8 bits of pulse width
    • writePW_HI

      void writePW_HI(byte pw_hi)
      Register functions.
      Parameter:
      pw_hi - high 8 bits of pulse width
    • writeCONTROL_REG

      void writeCONTROL_REG(WaveformGenerator ring_modulator, byte control)
      Register functions.
      Parameter:
      ring_modulator - ring-modulator modulating me.
      control - control register value
    • readOSC6581

      byte readOSC6581(WaveformGenerator ring_modulator)
      Read OSC3 value (6581, not latched/delayed version)
      Parameter:
      ring_modulator - The ring modulating partner of this waveform
      Gibt zurück:
      OSC3 value
    • readOSC8580

      byte readOSC8580(WaveformGenerator ring_modulator)
      Read OSC3 value (8580, 1-clock latched version). Waveforms 0 and 8 and above are not appropriately delayed by 1 clock. It should not be noticeable for 0 and > 8, but noise is not correctly delayed.
      Parameter:
      ring_modulator - The ring modulating partner of this waveform
      Gibt zurück:
      OSC3 value
    • readOSC

      public byte readOSC(ChipModel model)
    • readOSC

      private byte readOSC(int ringAccumulator, int myAccumulator)
      Calculate OSC3 bitstate from the analog values.
    • clockNoise

      private void clockNoise(boolean clock)
    • calculateCurrentNoiseValue

      private byte calculateCurrentNoiseValue()
      Noise: The noise output is taken from intermediate bits of a 23-bit shift register which is clocked by bit 19 of the accumulator. NB! The output is actually delayed 2 cycles after bit 19 is set high. This is not modeled.

      Operation: Calculate an EOR result, shift register, set bit 0 = result.

                               ------------------------>--------------------
                               |                                            |
                          ----EOR----                                       |
                          |         |                                       |
                          2 2 2 1 1 1 1 1 1 1 1 1 1                         |
        Register bits:    2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 <---
                          |   |       |     |   |       |     |   |
        OSC3 bits  :      7   6       5     4   3       2     1   0
       

      Since the waveform output is 12 bits, the output is left-shifted 4 times.

    • reset

      void reset()
      SID reset.
    • getZeroLevel

      public float getZeroLevel()
      Return the waveform offset. The zero level is ideally 0x800.
      Gibt zurück:
      the waveform offset