1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>source_al.cpp</h1><a href="source__al_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025
00026 <font class="preprocessor">#include "<a class="code" href="stdopenal_8h.html">stdopenal.h</a>"</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="source__al_8h.html">source_al.h</a>"</font>
00029
00030 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00031
00032
00033 <font class="keyword">namespace </font>NLSOUND {
00034
00035
00036 <font class="comment">// Currently, the OpenAL headers are different between Windows and Linux versions !</font>
00037 <font class="preprocessor">#ifdef NL_OS_UNIX</font>
00038 <font class="preprocessor"></font><font class="preprocessor">#define alGetSourcei alGetSourceiv</font>
00039 <font class="preprocessor"></font><font class="preprocessor">#define alGetSourcef alGetSourcefv</font>
00040 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00041 <font class="preprocessor"></font>
00042
00043 <font class="comment">/*</font>
00044 <font class="comment"> * Constructor</font>
00045 <font class="comment"> */</font>
<a name="l00046"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#a0">00046</a> CSourceAL::CSourceAL( ALuint sourcename ) : ISource(), _SourceName(sourcename)
00047 {}
00048
00049
00050 <font class="comment">/*</font>
00051 <font class="comment"> * Destructor</font>
00052 <font class="comment"> */</font>
<a name="l00053"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#a1">00053</a> CSourceAL::~CSourceAL()
00054 {
00055 CSoundDriverAL *sdal = CSoundDriverAL::instance();
00056 sdal->removeSource( <font class="keyword">this</font> );
00057 }
00058
00059
00060 <font class="comment">/* Set the buffer that will be played (no streaming)</font>
00061 <font class="comment"> * If the buffer is stereo, the source mode becomes stereo and the source relative mode is on,</font>
00062 <font class="comment"> * otherwise the source is considered as a 3D source.</font>
00063 <font class="comment"> */</font>
<a name="l00064"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z975_0">00064</a> <font class="keywordtype">void</font> CSourceAL::setStaticBuffer( IBuffer *buffer )
00065 {
00066 ISource::setStaticBuffer( buffer );
00067
00068 <font class="comment">// Stop source</font>
00069 alSourceStop( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a> );
00070 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00071
00072 <font class="comment">// Set buffer</font>
00073 <font class="keywordflow">if</font> ( buffer == NULL )
00074 {
00075 alSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_BUFFER, AL_NONE );
00076 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00077 }
00078 <font class="keywordflow">else</font>
00079 {
00080 CBufferAL *bufferAL = dynamic_cast<CBufferAL*>(buffer);
00081 alSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_BUFFER, bufferAL->bufferName() );
00082 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00083
00084 <font class="comment">// Set relative mode if the buffer is stereo</font>
00085 <a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_10">setSourceRelativeMode</a>( bufferAL->isStereo() );
00086 }
00087 }
00088
00089
00090 <font class="comment">/*</font>
00091 <font class="comment"> * Set looping on/off for future playbacks (default: off)</font>
00092 <font class="comment"> */</font>
<a name="l00093"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_0">00093</a> <font class="keywordtype">void</font> CSourceAL::setLooping( <font class="keywordtype">bool</font> <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> )
00094 {
00095 alSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_LOOPING, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>?AL_TRUE:AL_FALSE );
00096 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00097 }
00098
00099
00100 <font class="comment">/*</font>
00101 <font class="comment"> * Return the looping state</font>
00102 <font class="comment"> */</font>
<a name="l00103"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_1">00103</a> <font class="keywordtype">bool</font> CSourceAL::getLooping()<font class="keyword"> const</font>
00104 <font class="keyword"></font>{
00105 ALint b;
00106 alGetSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_LOOPING, &b );
00107 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00108 <font class="keywordflow">return</font> ( b == AL_TRUE );
00109 }
00110
00111
00112 <font class="comment">/*</font>
00113 <font class="comment"> * Play the static buffer (or stream in and play)</font>
00114 <font class="comment"> */</font>
<a name="l00115"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_2">00115</a> <font class="keywordtype">bool</font> CSourceAL::play()
00116 {
00117 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1ISource.html#n0">_Buffer</a> != NULL )
00118 {
00119 <font class="comment">// Static playing mode</font>
00120 alSourcePlay( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a> );
00121 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00122 }
00123 <font class="keywordflow">else</font>
00124 {
00125 <font class="comment">// Streaming mode</font>
00126 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"AM: Cannot play null buffer; streaming not implemented"</font> );
00127 <a class="code" href="debug_8h.html#a12">nlstop</a>;
00128 }
00129
00130 <font class="comment">// TODO : return a correct value, depending on alSourcePlay result.</font>
00131 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00132 }
00133
00134
00135 <font class="comment">/*</font>
00136 <font class="comment"> * Stop playing</font>
00137 <font class="comment"> */</font>
<a name="l00138"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_3">00138</a> <font class="keywordtype">void</font> CSourceAL::stop()
00139 {
00140 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1ISource.html#n0">_Buffer</a> != NULL )
00141 {
00142 <font class="comment">// Static playing mode</font>
00143 alSourceStop( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a> );
00144 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00145 }
00146 <font class="keywordflow">else</font>
00147 {
00148 <font class="comment">// Streaming mode</font>
00149 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"AM: Cannot stop null buffer; streaming not implemented"</font> );
00150 <font class="comment">//nlstop;</font>
00151 }
00152 }
00153
00154
00155 <font class="comment">/*</font>
00156 <font class="comment"> * Pause. Call play() to resume.</font>
00157 <font class="comment"> */</font>
<a name="l00158"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_4">00158</a> <font class="keywordtype">void</font> CSourceAL::pause()
00159 {
00160 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1ISource.html#n0">_Buffer</a> != NULL )
00161 {
00162 <font class="comment">// Static playing mode</font>
00163 alSourcePause( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a> );
00164 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00165 }
00166 <font class="keywordflow">else</font>
00167 {
00168 <font class="comment">// Streaming mode</font>
00169 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"AM: Cannot pause null buffer; streaming not implemented"</font> );
00170 <a class="code" href="debug_8h.html#a12">nlstop</a>;
00171 }
00172 }
00173
00174
00175 <font class="comment">/*</font>
00176 <font class="comment"> * Return the playing state</font>
00177 <font class="comment"> */</font>
<a name="l00178"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_5">00178</a> <font class="keywordtype">bool</font> CSourceAL::isPlaying()<font class="keyword"> const</font>
00179 <font class="keyword"></font>{
00180 ALint srcstate;
00181 alGetSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_SOURCE_STATE, &srcstate );
00182 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00183 <font class="keywordflow">return</font> (srcstate == AL_PLAYING);
00184 }
00185
00186
00187 <font class="comment">/*</font>
00188 <font class="comment"> * Return true if playing is finished or stop() has been called.</font>
00189 <font class="comment"> */</font>
<a name="l00190"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_6">00190</a> <font class="keywordtype">bool</font> CSourceAL::isStopped()<font class="keyword"> const</font>
00191 <font class="keyword"></font>{
00192 ALint srcstate;
00193 alGetSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_SOURCE_STATE, &srcstate );
00194 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00195 <font class="keywordflow">return</font> (srcstate == AL_STOPPED);
00196 }
00197
00198
00199 <font class="comment">/*</font>
00200 <font class="comment"> * Update the source (e.g. continue to stream the data in)</font>
00201 <font class="comment"> */</font>
<a name="l00202"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z976_7">00202</a> <font class="keywordtype">void</font> CSourceAL::update()
00203 {
00204 <font class="comment">// Streaming not implemented</font>
00205 }
00206
00207
00208
00209 <font class="comment">/* Set the position vector.</font>
00210 <font class="comment"> * 3D mode -> 3D position</font>
00211 <font class="comment"> * st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0</font>
00212 <font class="comment"> */</font>
<a name="l00213"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_0">00213</a> <font class="keywordtype">void</font> CSourceAL::setPos( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& pos )
00214 {
00215 <a class="code" href="classNLSOUND_1_1CSourceAL.html#o1">_Pos</a> = pos;
00216 <font class="comment">// Coordinate system: conversion from NeL to OpenAL/GL:</font>
00217 alSource3f( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_POSITION, pos.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, pos.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, -pos.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> );
00218 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00219 }
00220
00221
00222 <font class="comment">/* Get the position vector.</font>
00223 <font class="comment"> * See setPos() for details.</font>
00224 <font class="comment"> */</font>
<a name="l00225"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_1">00225</a> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &CSourceAL::getPos()<font class="keyword"> const</font>
00226 <font class="keyword"></font>{
00227 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CSourceAL.html#o1">_Pos</a>;
00228 <font class="comment">/*</font>
00229 <font class="comment"> ALfloat v[3];</font>
00230 <font class="comment"> alGetSourcefv( _SourceName, AL_POSITION, v );</font>
00231 <font class="comment"> TestALError();</font>
00232 <font class="comment"> // Coordsys conversion</font>
00233 <font class="comment"> pos.set( v[0], -v[2], v[1] );</font>
00234 <font class="comment">*/</font>
00235 }
00236
00237
00238 <font class="comment">/*</font>
00239 <font class="comment"> * Set the velocity vector (3D mode only)</font>
00240 <font class="comment"> */</font>
<a name="l00241"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_2">00241</a> <font class="keywordtype">void</font> CSourceAL::setVelocity( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& vel, <font class="keywordtype">bool</font> deferred )
00242 {
00243 <font class="comment">// Coordsys conversion</font>
00244 alSource3f( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_VELOCITY, vel.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, vel.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, -vel.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> );
00245 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00246 }
00247
00248
00249 <font class="comment">/*</font>
00250 <font class="comment"> * Get the velocity vector</font>
00251 <font class="comment"> */</font>
<a name="l00252"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_3">00252</a> <font class="keywordtype">void</font> CSourceAL::getVelocity( <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& vel )<font class="keyword"> const</font>
00253 <font class="keyword"></font>{
00254 ALfloat <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[3];
00255 alGetSourcefv( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_VELOCITY, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> );
00256 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00257 <font class="comment">// Coordsys conversion</font>
00258 vel.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>( <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0], -<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2], <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1] );
00259 }
00260
00261
00262 <font class="comment">/*</font>
00263 <font class="comment"> * Set the direction vector (3D mode only)</font>
00264 <font class="comment"> */</font>
<a name="l00265"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_4">00265</a> <font class="keywordtype">void</font> CSourceAL::setDirection( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& dir )
00266 {
00267 <font class="comment">// Coordsys conversion</font>
00268 alSource3f( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_DIRECTION, dir.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, dir.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>, -dir.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> );
00269 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00270 }
00271
00272
00273 <font class="comment">/*</font>
00274 <font class="comment"> * Get the direction vector</font>
00275 <font class="comment"> */</font>
<a name="l00276"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_5">00276</a> <font class="keywordtype">void</font> CSourceAL::getDirection( <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& dir )<font class="keyword"> const</font>
00277 <font class="keyword"></font>{
00278 ALfloat <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[3];
00279 alGetSourcefv( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_DIRECTION, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> );
00280 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00281 <font class="comment">// Coordsys conversion</font>
00282 dir.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>( <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0], -<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[2], <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[1] );
00283 }
00284
00285
00286 <font class="comment">/* Set the gain (volume value inside [0 , 1]).</font>
00287 <font class="comment"> * 0.0 -> silence</font>
00288 <font class="comment"> * 0.5 -> -6dB</font>
00289 <font class="comment"> * 1.0 -> no attenuation</font>
00290 <font class="comment"> * values > 1 (amplification) not supported by most drivers</font>
00291 <font class="comment"> */</font>
<a name="l00292"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_6">00292</a> <font class="keywordtype">void</font> CSourceAL::setGain( <font class="keywordtype">float</font> gain )
00293 {
00294 <a class="code" href="debug_8h.html#a6">nlassert</a>( (gain >= 0.0f) && (gain <= 1.0f ) );
00295 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_GAIN, gain );
00296 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00297 }
00298
00299
00300 <font class="comment">/*</font>
00301 <font class="comment"> * Get the gain</font>
00302 <font class="comment"> */</font>
<a name="l00303"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_7">00303</a> <font class="keywordtype">float</font> CSourceAL::getGain()<font class="keyword"> const</font>
00304 <font class="keyword"></font>{
00305 ALfloat gain;
00306 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_GAIN, &gain );
00307 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00308 <font class="keywordflow">return</font> gain;
00309 }
00310
00311
00312 <font class="comment">/* Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift</font>
00313 <font class="comment"> * of one octave. 0 is not a legal value.</font>
00314 <font class="comment"> */</font>
<a name="l00315"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_8">00315</a> <font class="keywordtype">void</font> CSourceAL::setPitch( <font class="keywordtype">float</font> pitch )
00316 {
00317 <a class="code" href="debug_8h.html#a6">nlassert</a>( (pitch > 0) && (pitch <= 1.0f ) );
00318 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_PITCH, pitch );
00319 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00320 }
00321
00322
00323 <font class="comment">/*</font>
00324 <font class="comment"> * Get the pitch</font>
00325 <font class="comment"> */</font>
<a name="l00326"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_9">00326</a> <font class="keywordtype">float</font> CSourceAL::getPitch()<font class="keyword"> const</font>
00327 <font class="keyword"></font>{
00328 ALfloat pitch;
00329 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_PITCH, &pitch );
00330 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00331 <font class="keywordflow">return</font> pitch;
00332 }
00333
00334
00335 <font class="comment">/*</font>
00336 <font class="comment"> * Set the source relative mode. If true, positions are interpreted relative to the listener position.</font>
00337 <font class="comment"> */</font>
<a name="l00338"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_10">00338</a> <font class="keywordtype">void</font> CSourceAL::setSourceRelativeMode( <font class="keywordtype">bool</font> mode )
00339 {
00340 alSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_SOURCE_RELATIVE, mode?AL_TRUE:AL_FALSE );
00341 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00342 }
00343
00344
00345 <font class="comment">/*</font>
00346 <font class="comment"> * Get the source relative mode (3D mode only)</font>
00347 <font class="comment"> */</font>
<a name="l00348"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_11">00348</a> <font class="keywordtype">bool</font> CSourceAL::getSourceRelativeMode()<font class="keyword"> const</font>
00349 <font class="keyword"></font>{
00350 ALint b;
00351 alGetSourcei( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_SOURCE_RELATIVE, &b );
00352 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00353 <font class="keywordflow">return</font> (b==AL_TRUE);
00354 }
00355
00356
00357 <font class="comment">/*</font>
00358 <font class="comment"> * Set the min and max distances (3D mode only)</font>
00359 <font class="comment"> */</font>
<a name="l00360"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_12">00360</a> <font class="keywordtype">void</font> CSourceAL::setMinMaxDistances( <font class="keywordtype">float</font> mindist, <font class="keywordtype">float</font> maxdist, <font class="keywordtype">bool</font> deferred )
00361 {
00362 <a class="code" href="debug_8h.html#a6">nlassert</a>( (mindist >= 0.0f) && (maxdist >= 0.0f) );
00363 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_REFERENCE_DISTANCE, mindist );
00364 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_MAX_DISTANCE, maxdist );
00365 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00366 }
00367
00368
00369 <font class="comment">/*</font>
00370 <font class="comment"> * Get the min and max distances</font>
00371 <font class="comment"> */</font>
<a name="l00372"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_13">00372</a> <font class="keywordtype">void</font> CSourceAL::getMinMaxDistances( <font class="keywordtype">float</font>& mindist, <font class="keywordtype">float</font>& maxdist )<font class="keyword"> const</font>
00373 <font class="keyword"></font>{
00374 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_REFERENCE_DISTANCE, &mindist );
00375 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_MAX_DISTANCE, &maxdist );
00376 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00377 }
00378
00379
00380 <font class="comment">/*</font>
00381 <font class="comment"> * Set the cone angles (in radian) and gain (in [0 , 1]) (3D mode only)</font>
00382 <font class="comment"> */</font>
<a name="l00383"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_14">00383</a> <font class="keywordtype">void</font> CSourceAL::setCone( <font class="keywordtype">float</font> innerAngle, <font class="keywordtype">float</font> outerAngle, <font class="keywordtype">float</font> outerGain )
00384 {
00385 <a class="code" href="debug_8h.html#a6">nlassert</a>( (outerGain >= 0.0f) && (outerGain <= 1.0f ) );
00386 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_INNER_ANGLE, <a class="code" href="namespaceNLMISC.html#a227">radToDeg</a>(innerAngle) );
00387 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_OUTER_ANGLE, <a class="code" href="namespaceNLMISC.html#a227">radToDeg</a>(outerAngle) );
00388 alSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_OUTER_GAIN, outerGain );
00389 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00390 }
00391
00392
00393 <font class="comment">/*</font>
00394 <font class="comment"> * Get the cone angles (in radian)</font>
00395 <font class="comment"> */</font>
<a name="l00396"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_15">00396</a> <font class="keywordtype">void</font> CSourceAL::getCone( <font class="keywordtype">float</font>& innerAngle, <font class="keywordtype">float</font>& outerAngle, <font class="keywordtype">float</font>& outerGain )<font class="keyword"> const</font>
00397 <font class="keyword"></font>{
00398 <font class="keywordtype">float</font> ina, outa;
00399 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_INNER_ANGLE, &ina );
00400 innerAngle = <a class="code" href="namespaceNLMISC.html#a226">degToRad</a>(ina);
00401 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_OUTER_ANGLE, &outa );
00402 outerAngle = <a class="code" href="namespaceNLMISC.html#a226">degToRad</a>(outa);
00403 alGetSourcef( <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, AL_CONE_OUTER_GAIN, &outerGain );
00404 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
00405 }
00406
00407
00408 <font class="comment">/*</font>
00409 <font class="comment"> * Set any EAX source property if EAX available</font>
00410 <font class="comment"> */</font>
<a name="l00411"></a><a class="code" href="classNLSOUND_1_1CSourceAL.html#z977_16">00411</a> <font class="keywordtype">void</font> CSourceAL::setEAXProperty( uint prop, <font class="keywordtype">void</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, uint valuesize )
00412 {
00413 <font class="preprocessor">#ifdef EAX_AVAILABLE</font>
00414 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( EAXSetProp != NULL )
00415 {
00416 EAXSetProp( &DSPROPSETID_EAX_SourceProperties, prop, <a class="code" href="classNLSOUND_1_1CSourceAL.html#o0">_SourceName</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, valuesize );
00417 }
00418 <font class="preprocessor">#endif</font>
00419 <font class="preprocessor"></font>}
00420
00421
00422 } <font class="comment">// NLSOUND</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|