Voice.h
/*
* This file is part of libsidplayfp, a SID player engine.
*
* Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
* Copyright 2007-2010 Antti Lankila
* Copyright 2004 Dag Lem <resid@nimrod.no>
*
* 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.
*
* 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.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef VOICE_H
#define VOICE_H
#include "siddefs-fp.h"
#include "WaveformGenerator.h"
#include "EnvelopeGenerator.h"
namespace reSIDfp
{
class Voice
{
private:
WaveformGenerator* waveformGenerator;
EnvelopeGenerator* envelopeGenerator;
public:
RESID_INLINE
int output(const WaveformGenerator* ringModulator) const
{
return waveformGenerator->output(ringModulator) * envelopeGenerator->output();
}
Voice() :
waveformGenerator(new WaveformGenerator()),
envelopeGenerator(new EnvelopeGenerator()) {}
~Voice()
{
delete waveformGenerator;
delete envelopeGenerator;
}
WaveformGenerator* wave() const { return waveformGenerator; }
EnvelopeGenerator* envelope() const { return envelopeGenerator; }
void writeCONTROL_REG(unsigned char control)
{
waveformGenerator->writeCONTROL_REG(control);
envelopeGenerator->writeCONTROL_REG(control);
}
void reset()
{
waveformGenerator->reset();
envelopeGenerator->reset();
}
};
} // namespace reSIDfp
#endif
reSIDfp::Voice::Voice
Voice()
Definition: Voice.h:67
reSIDfp::Voice::reset
void reset()
Definition: Voice.h:95
reSIDfp::WaveformGenerator::writeCONTROL_REG
void writeCONTROL_REG(unsigned char control)
Definition: WaveformGenerator.cpp:135
reSIDfp::Voice::output
RESID_INLINE int output(const WaveformGenerator *ringModulator) const
Definition: Voice.h:59
reSIDfp::Voice
Definition: Voice.h:36
reSIDfp::EnvelopeGenerator::output
short output() const
Definition: EnvelopeGenerator.h:143
reSIDfp::Voice::writeCONTROL_REG
void writeCONTROL_REG(unsigned char control)
Definition: Voice.h:86
reSIDfp::WaveformGenerator::output
short output(const WaveformGenerator *ringModulator)
Definition: WaveformGenerator.h:319
reSIDfp::WaveformGenerator::reset
void reset()
Definition: WaveformGenerator.cpp:202
reSIDfp::EnvelopeGenerator::reset
void reset()
Definition: EnvelopeGenerator.cpp:120
reSIDfp::EnvelopeGenerator
Definition: EnvelopeGenerator.h:42
reSIDfp::WaveformGenerator
Definition: WaveformGenerator.h:86
reSIDfp::EnvelopeGenerator::writeCONTROL_REG
void writeCONTROL_REG(unsigned char control)
Definition: EnvelopeGenerator.cpp:141