Package builder.resid.residfp
Klasse WaveformGenerator
java.lang.Object
builder.resid.residfp.WaveformGenerator
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
FelderModifizierer und TypFeldBeschreibungprivate intCurrent and previous accumulator value.private intCurrent and previous accumulator value.private float[]private intFout = (Fn*Fclk/16777216)Hzprivate intValue in noise XOR register.private intTime until Noise XOR register is overwritten.private byteCached digital value of OSC3.private floatCached analog value of OSC3private intPWout = (PWn/40.95)%private booleanThe control register bits.private booleanThe control register bits.private booleanThe control register bits.private intThe control register right-shifted 4 bits; used for output function table lookup.private byte[][]private float[][] -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprivate byteNoise: The noise output is taken from intermediate bits of a 23-bit shift register which is clocked by bit 19 of the accumulator.protected voidclock()SID clocking - 1 cycle.private voidclockNoise(boolean clock) floatReturn the waveform offset.floatoutput(WaveformGenerator ring_modulator) 12-bit waveform output.private bytereadOSC(int ringAccumulator, int myAccumulator) Calculate OSC3 bitstate from the analog values.byteprotected bytereadOSC6581(WaveformGenerator ring_modulator) Read OSC3 value (6581, not latched/delayed version)protected bytereadOSC8580(WaveformGenerator ring_modulator) Read OSC3 value (8580, 1-clock latched version).protected voidreset()SID reset.protected voidsetWftable(float[][] newWftable, float[] newDac, byte[][] newWfdigital) protected voidsynchronize(WaveformGenerator syncDest, WaveformGenerator syncSource) Synchronize oscillators.protected voidwriteCONTROL_REG(WaveformGenerator ring_modulator, byte control) Register functions.protected voidwriteFREQ_HI(byte freq_hi) Register functions.protected voidwriteFREQ_LO(byte freq_lo) Register functions.protected voidwritePW_HI(byte pw_hi) Register functions.protected voidwritePW_LO(byte pw_lo) Register functions.
-
Felddetails
-
wftable
private float[][] wftable -
wfdigital
private byte[][] wfdigital -
dac
private float[] dac -
accumulator
private int accumulatorCurrent and previous accumulator value. -
accumulator_prev
private int accumulator_prevCurrent and previous accumulator value. -
noiseShiftRegister
private int noiseShiftRegisterValue in noise XOR register. -
noiseShiftRegisterTtl
private int noiseShiftRegisterTtlTime until Noise XOR register is overwritten. -
previous
private byte previousCached digital value of OSC3. -
previous_dac
private float previous_dacCached analog value of OSC3 -
freq
private int freqFout = (Fn*Fclk/16777216)Hz -
pw
private int pwPWout = (PWn/40.95)% -
waveform
private int waveformThe control register right-shifted 4 bits; used for output function table lookup. -
test
private boolean testThe control register bits. Gate is handled by EnvelopeGenerator. -
ring
private boolean ringThe control register bits. Gate is handled by EnvelopeGenerator. -
sync
private boolean syncThe control register bits. Gate is handled by EnvelopeGenerator.
-
-
Konstruktordetails
-
WaveformGenerator
protected WaveformGenerator()Constructor.
-
-
Methodendetails
-
setWftable
protected void setWftable(float[][] newWftable, float[] newDac, byte[][] newWfdigital) -
clock
protected void clock()SID clocking - 1 cycle. -
synchronize
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 syncingsyncSource- The oscillator syncing me.
-
output
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
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
Register functions.- Parameter:
ring_modulator- ring-modulator modulating me.control- control register value
-
readOSC6581
Read OSC3 value (6581, not latched/delayed version)- Parameter:
ring_modulator- The ring modulating partner of this waveform- Gibt zurück:
- OSC3 value
-
readOSC8580
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
-
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 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 0Since waveform output is 12 bits the output is left-shifted 4 times. -
reset
protected void reset()SID reset. -
getZeroLevel
public float getZeroLevel()Return the waveform offset. The zero level is ideally 0x800.- Gibt zurück:
- the waveform offset
-