libsidplayfp 1.8.8
Voice.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2004 Dag Lem <resid@nimrod.no>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef VOICE_H
24#define VOICE_H
25
26#include "siddefs-fp.h"
27#include "WaveformGenerator.h"
28#include "EnvelopeGenerator.h"
29
30namespace reSIDfp
31{
32
36class Voice
37{
38private:
39 WaveformGenerator* waveformGenerator;
40
41 EnvelopeGenerator* envelopeGenerator;
42
43public:
58 RESID_INLINE
59 int output(const WaveformGenerator* ringModulator) const
60 {
61 return waveformGenerator->output(ringModulator) * envelopeGenerator->output();
62 }
63
68 waveformGenerator(new WaveformGenerator()),
69 envelopeGenerator(new EnvelopeGenerator()) {}
70
71 ~Voice()
72 {
73 delete waveformGenerator;
74 delete envelopeGenerator;
75 }
76
77 WaveformGenerator* wave() const { return waveformGenerator; }
78
79 EnvelopeGenerator* envelope() const { return envelopeGenerator; }
80
86 void writeCONTROL_REG(unsigned char control)
87 {
88 waveformGenerator->writeCONTROL_REG(control);
89 envelopeGenerator->writeCONTROL_REG(control);
90 }
91
95 void reset()
96 {
97 waveformGenerator->reset();
98 envelopeGenerator->reset();
99 }
100};
101
102} // namespace reSIDfp
103
104#endif
Definition: EnvelopeGenerator.h:43
void reset()
Definition: EnvelopeGenerator.cpp:120
void writeCONTROL_REG(unsigned char control)
Definition: EnvelopeGenerator.cpp:141
short output() const
Definition: EnvelopeGenerator.h:143
Definition: Voice.h:37
Voice()
Definition: Voice.h:67
void writeCONTROL_REG(unsigned char control)
Definition: Voice.h:86
void reset()
Definition: Voice.h:95
RESID_INLINE int output(const WaveformGenerator *ringModulator) const
Definition: Voice.h:59
Definition: WaveformGenerator.h:87
void writeCONTROL_REG(unsigned char control)
Definition: WaveformGenerator.cpp:135
short output(const WaveformGenerator *ringModulator)
Definition: WaveformGenerator.h:319
void reset()
Definition: WaveformGenerator.cpp:202