Debian Codegraph @

src/engine/platform/sound/sid2/voice.h

raw
1 // ---------------------------------------------------------------------------
2 // This file is part of reSID, a MOS6581_2 SID2 emulator engine.
3 // Copyright (C) 2004 Dag Lem <[email protected]>
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
20
21 #include "siddefs.h"
22 #include "wave.h"
23 #include "envelope.h"
24
25 class Voice2
26 {
27 public:
28 Voice2();
29
30 void set_chip_model(chip_model2 model);
31 void set_sync_source(Voice2*);
32 void reset();
33
34 void writeCONTROL_REG(reg8);
35
36 // Amplitude modulated waveform output.
37 // Range [-2048*255, 2047*255].
38 RESID_INLINE sound_sample output();
39 RESID_INLINE sound_sample getDC();
40
41 protected:
42 WaveformGenerator2 wave;
43 EnvelopeGenerator2 envelope;
44
45 // Waveform D/A zero level.
46 sound_sample wave_zero;
47
48 // Multiplying D/A DC offset.
49 sound_sample voice_DC;
50
51 friend class SID2;
52 };
53
54
55 // ----------------------------------------------------------------------------
56 // Inline functions.
57 // The following function is defined inline because it is called every
58 // time a sample is calculated.
59 // ----------------------------------------------------------------------------
60
61 #if RESID_INLINING || defined(__VOICE_CC__)
62
63 // ----------------------------------------------------------------------------
64 // Amplitude modulated waveform output.
65 // Ideal range [-2048*255, 2047*255].
66 // ----------------------------------------------------------------------------
67 RESID_INLINE
68 sound_sample Voice2::output()
69 {
70 // Multiply oscillator output with envelope output.
71 return (wave.output() - wave_zero)*envelope.output();
72 }
73
74 RESID_INLINE
75 sound_sample Voice2::getDC()
76 {
77 return voice_DC;
78 }
79
80 #endif // RESID_INLINING || defined(__VOICE_CC__)
81