libsidplayfp  0.3.5
Voice.h
1 /*
2  * This file is part of reSID, a MOS6581 SID emulator engine.
3  * Copyright (C) 2004 Dag Lem <resid@nimrod.no>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * @author Ken Händel
20  *
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 
30 namespace reSIDfp
31 {
32 
41 class Voice {
42 
43 public:
44  WaveformGenerator* wave;
45 
46  EnvelopeGenerator* envelope;
47 
48 public:
63  RESID_INLINE
64  int output(const WaveformGenerator* ringModulator) const {
65  return wave->output(ringModulator) * envelope->output();
66  }
67 
71  Voice() :
72  wave(new WaveformGenerator()),
73  envelope(new EnvelopeGenerator()) {}
74 
75  ~Voice() {
76  delete wave;
77  delete envelope;
78  }
79 
80  // ----------------------------------------------------------------------------
81  // Register functions.
82  // ----------------------------------------------------------------------------
83 
90  void writeCONTROL_REG(const unsigned char control) {
91  wave->writeCONTROL_REG(control);
92  envelope->writeCONTROL_REG(control);
93  }
94 
98  void reset() {
99  wave->reset();
100  envelope->reset();
101  }
102 };
103 
104 } // namespace reSIDfp
105 
106 #endif