1
//============================================================================
5
// SS tttttt eeee ll ll aaaa
6
// SSSS tt ee ee ll ll aa
7
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
// SS SS tt ee ll ll aa aa
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2005 by Bradford W. Mott
13
// See the file "license" for information on usage and redistribution of
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: TIASnd.hxx,v 1.4 2006/01/06 00:31:56 stephena Exp $
17
//============================================================================
25
This class implements a fairly accurate emulation of the TIA sound
28
@author Bradford W. Mott
29
@version $Id: TIASnd.hxx,v 1.4 2006/01/06 00:31:56 stephena Exp $
35
Create a new TIA Sound object using the specified output frequency
37
TIASound(Int32 outputFrequency = 31400, Int32 tiaFrequency = 31400,
47
Reset the sound emulation to its power-on state
52
Set the frequency output samples should be generated at
54
void outputFrequency(Int32 freq);
57
Set the frequency the of the TIA device
59
void tiaFrequency(Int32 freq);
62
Selects the number of audio channels per sample (1 = mono, 2 = stereo)
64
void channels(uInt32 number);
67
Set volume clipping (decrease volume range by half to eliminate popping)
69
void clipVolume(bool clip);
73
Sets the specified sound register to the given value
75
@param address Register address
76
@param value Value to store in the register
78
void set(uInt16 address, uInt8 value);
81
Gets the specified sound register's value
83
@param address Register address
85
uInt8 get(uInt16 address);
88
Create sound samples based on the current sound register settings
89
in the specified buffer. NOTE: If channels is set to stereo then
90
the buffer will need to be twice as long as the number of samples.
92
@param buffer The location to store generated samples
93
@param samples The number of samples to generate
95
void process(uInt8* buffer, uInt32 samples);
98
Set the volume of the samples created (0-100)
100
void volume(uInt32 percent);
104
Frequency divider class which outputs 1 after "divide-by" clocks. This
105
is used to divide the main frequency by the values 1 to 32.
112
myDivideByValue = myCounter = 0;
115
void set(uInt32 divideBy)
117
myDivideByValue = divideBy;
122
if(++myCounter > myDivideByValue)
131
uInt32 myDivideByValue;
140
FreqDiv myFreqDiv[2]; // Frequency dividers
141
uInt8 myP4[2]; // 4-bit register LFSR (lower 4 bits used)
142
uInt8 myP5[2]; // 5-bit register LFSR (lower 5 bits used)
144
Int32 myOutputFrequency;
145
Int32 myTIAFrequency;
147
Int32 myOutputCounter;
148
uInt32 myVolumePercentage;