xref: /haiku/headers/os/game/GameSound.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		GameSound.h
23 //	Author:			Christopher ML Zumwalt May (zummy@users.sf.net)
24 //	Description:	Base class for play sounds using the game kit
25 //------------------------------------------------------------------------------
26 
27 #ifndef _GAMESOUND_H
28 #define _GAMESOUND_H
29 
30 // Standard Includes -----------------------------------------------------------
31 
32 // System Includes -------------------------------------------------------------
33 #include <GameSoundDefs.h>
34 #include <new>
35 
36 // Project Includes ------------------------------------------------------------
37 
38 // Local Includes --------------------------------------------------------------
39 
40 // Local Defines ---------------------------------------------------------------
41 
42 // Globals ---------------------------------------------------------------------
43 class BGameSoundDevice;
44 
45 // BGameSound class -------------------------------------------------------------
46 class BGameSound
47 {
48 public:
49 									BGameSound(BGameSoundDevice * device = NULL);
50 	virtual							~BGameSound();
51 
52 	virtual	BGameSound *			Clone() const = 0;
53 			status_t				InitCheck() const;
54 
55 			// BGameSound attributes
56 			BGameSoundDevice *		Device() const;
57 			gs_id					ID() const;
58 			const gs_audio_format & Format() const;		//	only valid after Init()
59 
60 			// Playing sounds
61 	virtual	status_t				StartPlaying();
62 	virtual	bool					IsPlaying();
63 	virtual	status_t				StopPlaying();
64 
65 
66 			// Modifing the playback
67 			status_t				SetGain(float gain,
68 											bigtime_t duration = 0);	//	ramp duration in seconds
69 			status_t				SetPan(float pan,
70 											bigtime_t duration = 0);	//	ramp duration in seconds
71 			float					Gain();
72 			float					Pan();
73 
74 	virtual	status_t				SetAttributes(gs_attribute * inAttributes,
75 													size_t inAttributeCount);
76 	virtual	status_t				GetAttributes(gs_attribute * outAttributes,
77 													size_t inAttributeCount);
78 
79 			void * 					operator new(size_t size);
80 			void *					operator new(size_t size,
81 										const std::nothrow_t &) throw();
82 			void					operator delete(void * ptr);
83 #if !__MWERKS__
84 			//	there's a bug in MWCC under R4.1 and earlier
85 			void					operator delete(void * ptr,
86 										const std::nothrow_t &) throw();
87 #endif
88 
89 			static	status_t		SetMemoryPoolSize(size_t in_poolSize);
90 			static	status_t		LockMemoryPool(bool in_lockInCore);
91 			static	int32			SetMaxSoundCount(int32 in_maxCount);
92 
93 			virtual	status_t 		Perform(int32 selector, void * data);
94 protected:
95 
96 			status_t				SetInitError(status_t in_initError);
97 			status_t				Init(gs_id handle);
98 
99 									BGameSound(const BGameSound & other);
100 			BGameSound &			operator=(const BGameSound & other);
101 
102 private:
103 			BGameSoundDevice*		fDevice;
104 			status_t				fInitError;
105 
106 			gs_audio_format			fFormat;
107 			gs_id					fSound;
108 
109 	/* leave these declarations private unless you plan on actually implementing and using them. */
110 	BGameSound();
111 
112 	/* fbc data and virtuals */
113 
114 	uint32 _reserved_BGameSound_[16];
115 
116 virtual	status_t _Reserved_BGameSound_0(int32 arg, ...);
117 virtual	status_t _Reserved_BGameSound_1(int32 arg, ...);
118 virtual	status_t _Reserved_BGameSound_2(int32 arg, ...);
119 virtual	status_t _Reserved_BGameSound_3(int32 arg, ...);
120 virtual	status_t _Reserved_BGameSound_4(int32 arg, ...);
121 virtual	status_t _Reserved_BGameSound_5(int32 arg, ...);
122 virtual	status_t _Reserved_BGameSound_6(int32 arg, ...);
123 virtual	status_t _Reserved_BGameSound_7(int32 arg, ...);
124 virtual	status_t _Reserved_BGameSound_8(int32 arg, ...);
125 virtual	status_t _Reserved_BGameSound_9(int32 arg, ...);
126 virtual	status_t _Reserved_BGameSound_10(int32 arg, ...);
127 virtual	status_t _Reserved_BGameSound_11(int32 arg, ...);
128 virtual	status_t _Reserved_BGameSound_12(int32 arg, ...);
129 virtual	status_t _Reserved_BGameSound_13(int32 arg, ...);
130 virtual	status_t _Reserved_BGameSound_14(int32 arg, ...);
131 virtual	status_t _Reserved_BGameSound_15(int32 arg, ...);
132 virtual	status_t _Reserved_BGameSound_16(int32 arg, ...);
133 virtual	status_t _Reserved_BGameSound_17(int32 arg, ...);
134 virtual	status_t _Reserved_BGameSound_18(int32 arg, ...);
135 virtual	status_t _Reserved_BGameSound_19(int32 arg, ...);
136 virtual	status_t _Reserved_BGameSound_20(int32 arg, ...);
137 virtual	status_t _Reserved_BGameSound_21(int32 arg, ...);
138 virtual	status_t _Reserved_BGameSound_22(int32 arg, ...);
139 virtual	status_t _Reserved_BGameSound_23(int32 arg, ...);
140 virtual	status_t _Reserved_BGameSound_24(int32 arg, ...);
141 virtual	status_t _Reserved_BGameSound_25(int32 arg, ...);
142 virtual	status_t _Reserved_BGameSound_26(int32 arg, ...);
143 virtual	status_t _Reserved_BGameSound_27(int32 arg, ...);
144 virtual	status_t _Reserved_BGameSound_28(int32 arg, ...);
145 virtual	status_t _Reserved_BGameSound_29(int32 arg, ...);
146 virtual	status_t _Reserved_BGameSound_30(int32 arg, ...);
147 virtual	status_t _Reserved_BGameSound_31(int32 arg, ...);
148 virtual	status_t _Reserved_BGameSound_32(int32 arg, ...);
149 virtual	status_t _Reserved_BGameSound_33(int32 arg, ...);
150 virtual	status_t _Reserved_BGameSound_34(int32 arg, ...);
151 virtual	status_t _Reserved_BGameSound_35(int32 arg, ...);
152 virtual	status_t _Reserved_BGameSound_36(int32 arg, ...);
153 virtual	status_t _Reserved_BGameSound_37(int32 arg, ...);
154 virtual	status_t _Reserved_BGameSound_38(int32 arg, ...);
155 virtual	status_t _Reserved_BGameSound_39(int32 arg, ...);
156 virtual	status_t _Reserved_BGameSound_40(int32 arg, ...);
157 virtual	status_t _Reserved_BGameSound_41(int32 arg, ...);
158 virtual	status_t _Reserved_BGameSound_42(int32 arg, ...);
159 virtual	status_t _Reserved_BGameSound_43(int32 arg, ...);
160 virtual	status_t _Reserved_BGameSound_44(int32 arg, ...);
161 virtual	status_t _Reserved_BGameSound_45(int32 arg, ...);
162 virtual	status_t _Reserved_BGameSound_46(int32 arg, ...);
163 virtual	status_t _Reserved_BGameSound_47(int32 arg, ...);
164 
165 };
166 
167 
168 #endif	//	_GAME_SOUND_H
169