public class WaveformGenerator extends Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
accumulator |
protected int |
freq
Fout = (Fn*Fclk/16777216)Hz
|
protected boolean |
msb_rising
Tell whether the accumulator MSB was set high on this cycle.
|
protected int |
pw
PWout = (PWn/40.95)%
|
protected int |
ring_mod
The remaining control register bits.
|
protected int |
shift_register |
protected int |
sync
The remaining control register bits.
|
protected WaveformGenerator |
sync_dest |
protected WaveformGenerator |
sync_source |
protected int |
test
The remaining control register bits.
|
protected int |
waveform
The control register right-shifted 4 bits; used for output function table
lookup.
|
| Constructor and Description |
|---|
WaveformGenerator()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clock()
SID clocking - 1 cycle.
|
void |
clock(int delta_t)
SID clocking - delta_t cycles.
|
protected int |
output____()
No waveform: Zero output.
|
protected int |
output___T()
Triangle: The upper 12 bits of the accumulator are used.
|
protected int |
output__S_()
Sawtooth: The output is identical to the upper 12 bits of the
accumulator.
|
protected int |
output__ST()
Combined waveforms: By combining waveforms, the bits of each waveform are
effectively short circuited.
|
protected int |
output_P__()
Pulse: The upper 12 bits of the accumulator are used.
|
protected int |
output_P_T()
Combined waveforms: By combining waveforms, the bits of each waveform are
effectively short circuited.
|
protected int |
output_PS_()
Combined waveforms: By combining waveforms, the bits of each waveform are
effectively short circuited.
|
protected int |
output_PST()
Combined waveforms: By combining waveforms, the bits of each waveform are
effectively short circuited.
|
int |
output()
12-bit waveform output.
|
protected int |
outputN___()
Noise: The noise output is taken from intermediate bits of a 23-bit shift
register which is clocked by bit 19 of the accumulator.
|
protected int |
outputN__T()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputN_S_()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputN_ST()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputNP__()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputNP_T()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputNPS_()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
protected int |
outputNPST()
Combined waveforms including noise: All waveform combinations including
noise output zero after a few cycles.
|
int |
readOSC() |
void |
reset()
SID reset.
|
void |
set_chip_model(ISIDDefs.chip_model model)
Set chip model.
|
void |
set_sync_source(WaveformGenerator source)
Set sync source.
|
void |
synchronize()
Synchronize oscillators.
|
void |
writeCONTROL_REG(int control)
Register functions.
|
void |
writeFREQ_HI(int freq_hi)
Register functions.
|
void |
writeFREQ_LO(int freq_lo)
Register functions.
|
void |
writePW_HI(int pw_hi)
Register functions.
|
void |
writePW_LO(int pw_lo)
Register functions.
|
protected WaveformGenerator sync_source
protected WaveformGenerator sync_dest
protected boolean msb_rising
protected int accumulator
protected int shift_register
protected int freq
protected int pw
protected int waveform
protected int test
protected int ring_mod
protected int sync
public void set_sync_source(WaveformGenerator source)
source - sync sourcepublic void set_chip_model(ISIDDefs.chip_model model)
model - chip modelpublic void writeFREQ_LO(int freq_lo)
freq_lo - public void writeFREQ_HI(int freq_hi)
freq_hi - public void writePW_LO(int pw_lo)
pw_lo - public void writePW_HI(int pw_hi)
pw_hi - public void writeCONTROL_REG(int control)
control - public int readOSC()
public void reset()
public void clock()
public void clock(int delta_t)
public void synchronize()
protected int output____()
protected int output___T()
protected int output__S_()
protected int output_P__()
NB! The output is actually delayed one cycle after the compare. This is not modeled.
The test bit, when set to one, holds the pulse waveform output at 0xfff regardless of the pulse width setting.
protected int outputN___()
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 0
Since waveform output is 12 bits the output is left-shifted 4 times.protected int output__ST()
Example:
1 1
Bit # 1 0 9 8 7 6 5 4 3 2 1 0
-----------------------
Sawtooth 0 0 0 1 1 1 1 1 1 0 0 0
Triangle 0 0 1 1 1 1 1 1 0 0 0 0
AND 0 0 0 1 1 1 1 1 0 0 0 0
Output 0 0 0 0 1 1 1 0 0 0 0 0
This behavior would be quite difficult to model exactly, since the SID in
this case does not act as a digital state machine. Tests show that minor
(1 bit) differences can actually occur in the output from otherwise
identical samples from OSC3 when waveforms are combined. To further
complicate the situation the output changes slightly with time (more
neighboring bits are successively set) when the 12-bit waveform registers
are kept unchanged.
It is probably possible to come up with a valid model for the behavior, however this would be far too slow for practical use since it would have to be based on the mutual influence of individual bits.
The output is instead approximated by using the upper bits of the accumulator as an index to look up the combined output in a table containing actual combined waveform samples from OSC3. These samples are 8 bit, so 4 bits of waveform resolution is lost. All OSC3 samples are taken with FREQ=0x1000, adding a 1 to the upper 12 bits of the accumulator each cycle for a sample period of 4096 cycles.
Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample.
Pulse+Triangle: The triangle output is right-shifted and used to look up an OSC3 sample. The sample is output if the pulse output is on. The reason for using the triangle output as the index is to handle ring modulation. Only the first half of the sample is used, which should be OK since the triangle waveform has half the resolution of the accumulator.
Pulse+Sawtooth: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
Pulse+Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
protected int output_P_T()
Example:
1 1
Bit # 1 0 9 8 7 6 5 4 3 2 1 0
-----------------------
Sawtooth 0 0 0 1 1 1 1 1 1 0 0 0
Triangle 0 0 1 1 1 1 1 1 0 0 0 0
AND 0 0 0 1 1 1 1 1 0 0 0 0
Output 0 0 0 0 1 1 1 0 0 0 0 0
This behavior would be quite difficult to model exactly, since the SID in
this case does not act as a digital state machine. Tests show that minor
(1 bit) differences can actually occur in the output from otherwise
identical samples from OSC3 when waveforms are combined. To further
complicate the situation the output changes slightly with time (more
neighboring bits are successively set) when the 12-bit waveform registers
are kept unchanged.
It is probably possible to come up with a valid model for the behavior, however this would be far too slow for practical use since it would have to be based on the mutual influence of individual bits.
The output is instead approximated by using the upper bits of the accumulator as an index to look up the combined output in a table containing actual combined waveform samples from OSC3. These samples are 8 bit, so 4 bits of waveform resolution is lost. All OSC3 samples are taken with FREQ=0x1000, adding a 1 to the upper 12 bits of the accumulator each cycle for a sample period of 4096 cycles.
Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample.
Pulse+Triangle: The triangle output is right-shifted and used to look up an OSC3 sample. The sample is output if the pulse output is on. The reason for using the triangle output as the index is to handle ring modulation. Only the first half of the sample is used, which should be OK since the triangle waveform has half the resolution of the accumulator.
Pulse+Sawtooth: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
Pulse+Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
protected int output_PS_()
Example:
1 1
Bit # 1 0 9 8 7 6 5 4 3 2 1 0
-----------------------
Sawtooth 0 0 0 1 1 1 1 1 1 0 0 0
Triangle 0 0 1 1 1 1 1 1 0 0 0 0
AND 0 0 0 1 1 1 1 1 0 0 0 0
Output 0 0 0 0 1 1 1 0 0 0 0 0
This behavior would be quite difficult to model exactly, since the SID in
this case does not act as a digital state machine. Tests show that minor
(1 bit) differences can actually occur in the output from otherwise
identical samples from OSC3 when waveforms are combined. To further
complicate the situation the output changes slightly with time (more
neighboring bits are successively set) when the 12-bit waveform registers
are kept unchanged.
It is probably possible to come up with a valid model for the behavior, however this would be far too slow for practical use since it would have to be based on the mutual influence of individual bits.
The output is instead approximated by using the upper bits of the accumulator as an index to look up the combined output in a table containing actual combined waveform samples from OSC3. These samples are 8 bit, so 4 bits of waveform resolution is lost. All OSC3 samples are taken with FREQ=0x1000, adding a 1 to the upper 12 bits of the accumulator each cycle for a sample period of 4096 cycles.
Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample.
Pulse+Triangle: The triangle output is right-shifted and used to look up an OSC3 sample. The sample is output if the pulse output is on. The reason for using the triangle output as the index is to handle ring modulation. Only the first half of the sample is used, which should be OK since the triangle waveform has half the resolution of the accumulator.
Pulse+Sawtooth: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
Pulse+Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
protected int output_PST()
Example:
1 1
Bit # 1 0 9 8 7 6 5 4 3 2 1 0
-----------------------
Sawtooth 0 0 0 1 1 1 1 1 1 0 0 0
Triangle 0 0 1 1 1 1 1 1 0 0 0 0
AND 0 0 0 1 1 1 1 1 0 0 0 0
Output 0 0 0 0 1 1 1 0 0 0 0 0
This behavior would be quite difficult to model exactly, since the SID in
this case does not act as a digital state machine. Tests show that minor
(1 bit) differences can actually occur in the output from otherwise
identical samples from OSC3 when waveforms are combined. To further
complicate the situation the output changes slightly with time (more
neighboring bits are successively set) when the 12-bit waveform registers
are kept unchanged.
It is probably possible to come up with a valid model for the behavior, however this would be far too slow for practical use since it would have to be based on the mutual influence of individual bits.
The output is instead approximated by using the upper bits of the accumulator as an index to look up the combined output in a table containing actual combined waveform samples from OSC3. These samples are 8 bit, so 4 bits of waveform resolution is lost. All OSC3 samples are taken with FREQ=0x1000, adding a 1 to the upper 12 bits of the accumulator each cycle for a sample period of 4096 cycles.
Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample.
Pulse+Triangle: The triangle output is right-shifted and used to look up an OSC3 sample. The sample is output if the pulse output is on. The reason for using the triangle output as the index is to handle ring modulation. Only the first half of the sample is used, which should be OK since the triangle waveform has half the resolution of the accumulator.
Pulse+Sawtooth: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
Pulse+Sawtooth+Triangle: The sawtooth output is used to look up an OSC3 sample. The sample is output if the pulse output is on.
protected int outputN__T()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputN_S_()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputN_ST()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputNP__()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputNP_T()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputNPS_()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
protected int outputNPST()
NB! The effects of such combinations are not fully explored. It is claimed that the shift register may be filled with zeroes and locked up, which seems to be true.
We have not attempted to model this behavior, suffice to say that there is very little audible output from waveform combinations including noise. We hope that nobody is actually using it.
public int output()
Copyright © 2014. All rights reserved.