libsidplayfp 1.0.3
|
00001 /* 00002 * This file is part of libsidplayfp, a SID player engine. 00003 * 00004 * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> 00005 * Copyright 2007-2010 Antti Lankila 00006 * Copyright 2004 Dag Lem <resid@nimrod.no> 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef VOICE_H 00024 #define VOICE_H 00025 00026 #include "siddefs-fp.h" 00027 #include "WaveformGenerator.h" 00028 #include "EnvelopeGenerator.h" 00029 00030 namespace reSIDfp 00031 { 00032 00041 class Voice 00042 { 00043 private: 00044 WaveformGenerator* waveformGenerator; 00045 00046 EnvelopeGenerator* envelopeGenerator; 00047 00048 public: 00063 RESID_INLINE 00064 int output(const WaveformGenerator* ringModulator) const 00065 { 00066 return waveformGenerator->output(ringModulator) * envelopeGenerator->output(); 00067 } 00068 00072 Voice() : 00073 waveformGenerator(new WaveformGenerator()), 00074 envelopeGenerator(new EnvelopeGenerator()) {} 00075 00076 ~Voice() 00077 { 00078 delete waveformGenerator; 00079 delete envelopeGenerator; 00080 } 00081 00082 WaveformGenerator* wave() const { return waveformGenerator; } 00083 00084 EnvelopeGenerator* envelope() const { return envelopeGenerator; } 00085 00086 // ---------------------------------------------------------------------------- 00087 // Register functions. 00088 // ---------------------------------------------------------------------------- 00089 00095 void writeCONTROL_REG(unsigned char control) 00096 { 00097 waveformGenerator->writeCONTROL_REG(control); 00098 envelopeGenerator->writeCONTROL_REG(control); 00099 } 00100 00104 void reset() 00105 { 00106 waveformGenerator->reset(); 00107 envelopeGenerator->reset(); 00108 } 00109 }; 00110 00111 } // namespace reSIDfp 00112 00113 #endif