1 //============================================================================
2 //
3 //   SSSS    tt          lll  lll
4 //  SS  SS   tt           ll   ll
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
10 //
11 // Copyright (c) 1995-1998 by Bradford W. Mott
12 //
13 // See the file "license" for information on usage and redistribution of
14 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 //
16 // $Id: SndXBOX.hxx,v 1.1.1.1 2001/12/27 19:54:32 bwmott Exp $
17 //============================================================================
18 
19 #ifndef SOUNDXBOX_HXX
20 #define SOUNDXBOX_HXX
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 #ifdef __cplusplus
28 }
29 #endif
30 
31 
32 #include <XBApp.h>
33 #include <Dsound.h>
34 
35 /**
36   This class implements the sound API for the XBOX operating system
37   using a sound-blaster card.
38 
39   @author  Bradford W. Mott
40   @version $Id: SndXBOX.hxx,v 1.1.1.1 2001/12/27 19:54:32 bwmott Exp $
41 */
42 class SoundXBOX
43 {
44   public:
45     /**
46       Create a new sound object
47     */
48     SoundXBOX();
49 	void init( ) ;
50 	void cleanup() ;
51 	int process( int isThrottled ) ;
52 	int dsound_init() ;
53 	void insertSilence( int samples ) ;
54 	void dsound_destroy_buffers() ;
55 	int dsound_create_buffers() ;
56 	int osd_start_audio_stream(int stereo) ;
57 	void osd_stop_audio_stream(void) ;
58 	void osd_set_mastervolume(int _attenuation) ;
59 	void copy_sample_data( unsigned char *data, int bytes_to_copy) ;
60 	int osd_update_audio_stream(unsigned char *buffer) ;
61 	int bytes_in_stream_buffer(void) ;
62 	void update_sample_adjustment(int buffered) ;
63     virtual void pause(bool state);
64 	void adjust_volume( int volchange ) ;
65 
66     /**
67       Destructor
68     */
69     virtual ~SoundXBOX();
70 
71   public:
72 	int							attenuation ;
73 	int					current_adjustment ;
74 	int					m_fps ;
75 	FILE				*sndfile ;
76 // DirectSound objects
77 	LPDIRECTSOUND8		dsound ;
78 
79 // global sample tracking
80 	double				samples_per_frame;
81 	double				samples_left_over;
82 	UINT32				samples_this_frame;
83 	UINT32              samples_to_read ;
84 	signed short		*m_mixbuf ;
85 	int					m_bDanger ;
86 	int					m_nVolume ;
87 
88 // sound buffers
89 	LPDIRECTSOUNDBUFFER8	stream_buffer ;
90 	UINT32				stream_buffer_size;
91 	UINT32				stream_buffer_in;
92 	UINT32				m_totalBytesWritten ;
93 	CXBApplication      *m_ptrapp ;
94 	byte				*m_pSoundBufferData ;
95 	DWORD				m_dwWritePos ;
96 	DWORD               m_dwOldTick ;
97 	DWORD               m_dwNewTick ;
98 
99 // descriptors and formats
100 	DSBUFFERDESC			stream_desc;
101 	WAVEFORMATEX			stream_format;
102 
103 // sample rate adjustments
104 	int					lower_thresh;
105 	int					upper_thresh;
106 
107 
108   private:
109     // Indicates if the sound system was initialized
110     bool myEnabled;
111 };
112 #endif
113 
114