Klasse WaveformGenerator

java.lang.Object
builder.resid.resid.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. Java port of the reSID 1.0 waveformgenerator by Dag Lem.
Autor:
Ken Händel, Dag Lem, Antti Lankila
  • Felddetails

    • model_wave

      private final short[][] model_wave
    • dac

      private final short[] dac
    • accumulator

      protected int accumulator
      Current and previous accumulator value.
    • accumulator_prev

      protected int accumulator_prev
      Current and previous accumulator value.
    • msb_rising

      private boolean msb_rising
    • freq

      protected int freq
    • pw

      private int pw
    • shift_register

      private int shift_register
    • shift_register_reset

      private int shift_register_reset
    • shift_pipeline

      private int shift_pipeline
    • ring_msb_mask

      private int ring_msb_mask
    • no_noise

      private int no_noise
    • noise_output

      private int noise_output
    • no_noise_or_noise_output

      private int no_noise_or_noise_output
    • no_pulse

      private int no_pulse
    • pulse_output

      private int pulse_output
    • waveform

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

      protected boolean test
      The control register bits. Gate is handled by EnvelopeGenerator.
    • sync

      protected boolean sync
    • floating_output_ttl

      private int floating_output_ttl
    • wave

      private short[] wave
    • waveform_output

      private int waveform_output
  • Konstruktordetails

    • WaveformGenerator

      protected WaveformGenerator()
      Constructor.
  • Methodendetails

    • setWaveformModels

      protected void setWaveformModels(short[][] models)
    • setChipModel

      protected void setChipModel(ChipModel chipModel)
      Set nonlinearity parameter for imperfect analog DAC emulation. 1.0 means perfect 8580-like linearity, values between 0.95 - 0.97 are probably realistic 6581 nonlinearity values.
      Parameter:
      chipModel - The ChipModel to use.
    • clock

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

      protected void synchronize(WaveformGenerator syncDest, WaveformGenerator syncSource)
      Synchronize oscillators. This must be done after all the oscillators have been clock()'ed, so that they are in the same state.
      Parameter:
      syncDest - The oscillator I am syncing
      syncSource - The oscillator syncing me.
    • clock_shift_register

      private void clock_shift_register()
    • write_shift_register

      private void write_shift_register()
    • reset_shift_register

      private void reset_shift_register()
    • set_noise_output

      private void set_noise_output()
    • output

      public short output(WaveformGenerator ringModulator)
      12-bit waveform output.
      Parameter:
      ringModulator - The oscillator ring-modulating me.
      Gibt zurück:
      output from waveformgenerator
    • readOSC

      public byte readOSC(int ringAccumulator, int myAccumulator)
      Read OSC3 value (6581, not latched/delayed version)
      Gibt zurück:
      OSC3 value
    • readOSC6581

      protected 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

      protected 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)
    • writeFREQ_LO

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

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

      protected 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

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

      protected void writeCONTROL_REG(byte control)
      Register functions.
      Parameter:
      control - control register value
    • reset

      protected void reset()
      SID reset.