Voice.java
/**
* This file is part of reSID, a MOS6581 SID emulator engine.
* Copyright (C) 2004 Dag Lem <resid@nimrod.no>
* <p>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Ken Händel
*
*/
package builder.resid.resid;
/**
* Representation of SID voice block.
*
* @author Ken Händel
* @author Dag Lem
* @author Antti Lankila
*/
public final class Voice {
public final WaveformGenerator wave = new WaveformGenerator();
public final EnvelopeGenerator envelope = new EnvelopeGenerator();
/**
* Amplitude modulated waveform output.
* <p>
* The waveform DAC generates a voltage between 5 and 12 V corresponding to
* oscillator state 0 .. 4095.
* <p>
* The envelope DAC generates a voltage between waveform gen output and the 5V
* level, corresponding to envelope state 0 .. 255.
* <p>
* Ideal range [-2048*255, 2047*255].
*
* @param ringModulator Ring-modulator for waveform
* @return waveformgenerator output
*/
int output(final WaveformGenerator ringModulator) {
return wave.output(ringModulator) * envelope.output();
}
/**
* Internal SID.clock() path: one render per waveform clock. Extra/manual
* waveform renders use output() to retain literal latch/feedback effects.
*/
int outputClocked(final WaveformGenerator ringModulator) {
return wave.outputClocked(ringModulator) * envelope.output();
}
/**
* Constructor.
*/
Voice() {
}
// ----------------------------------------------------------------------------
// Register functions.
// ----------------------------------------------------------------------------
/**
* Register functions.
*
* @param control Control register value.
*/
public void writeCONTROL_REG(final byte control) {
wave.writeCONTROL_REG(control);
envelope.writeCONTROL_REG(control);
}
/**
* SID reset.
*/
public void reset() {
wave.reset();
envelope.reset();
}
}