2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
32 extern inline void LockFiltersRead(ALCdevice
*device
);
33 extern inline void UnlockFiltersRead(ALCdevice
*device
);
34 extern inline void LockFiltersWrite(ALCdevice
*device
);
35 extern inline void UnlockFiltersWrite(ALCdevice
*device
);
36 extern inline struct ALfilter
*LookupFilter(ALCdevice
*device
, ALuint id
);
37 extern inline struct ALfilter
*RemoveFilter(ALCdevice
*device
, ALuint id
);
38 extern inline void ALfilterState_clear(ALfilterState
*filter
);
39 extern inline void ALfilterState_copyParams(ALfilterState
*restrict dst
, const ALfilterState
*restrict src
);
40 extern inline void ALfilterState_processPassthru(ALfilterState
*filter
, const ALfloat
*restrict src
, ALsizei numsamples
);
41 extern inline ALfloat
calc_rcpQ_from_slope(ALfloat gain
, ALfloat slope
);
42 extern inline ALfloat
calc_rcpQ_from_bandwidth(ALfloat f0norm
, ALfloat bandwidth
);
44 static void InitFilterParams(ALfilter
*filter
, ALenum type
);
47 AL_API ALvoid AL_APIENTRY
alGenFilters(ALsizei n
, ALuint
*filters
)
54 context
= GetContextRef();
58 SETERR_GOTO(context
, AL_INVALID_VALUE
, 0, "Generating negative filters", done
);
60 device
= context
->Device
;
61 for(cur
= 0;cur
< n
;cur
++)
63 ALfilter
*filter
= al_calloc(16, sizeof(ALfilter
));
66 alDeleteFilters(cur
, filters
);
67 SETERR_GOTO(context
, AL_OUT_OF_MEMORY
, 0, "Failed to allocate filter object", done
);
69 InitFilterParams(filter
, AL_FILTER_NULL
);
71 err
= NewThunkEntry(&filter
->id
);
72 if(err
== AL_NO_ERROR
)
73 err
= InsertUIntMapEntry(&device
->FilterMap
, filter
->id
, filter
);
74 if(err
!= AL_NO_ERROR
)
76 FreeThunkEntry(filter
->id
);
77 memset(filter
, 0, sizeof(ALfilter
));
80 alDeleteFilters(cur
, filters
);
81 SETERR_GOTO(context
, err
, 0, "Failed ot set filter ID", done
);
84 filters
[cur
] = filter
->id
;
88 ALCcontext_DecRef(context
);
91 AL_API ALvoid AL_APIENTRY
alDeleteFilters(ALsizei n
, const ALuint
*filters
)
98 context
= GetContextRef();
101 device
= context
->Device
;
102 LockFiltersWrite(device
);
104 SETERR_GOTO(context
, AL_INVALID_VALUE
, 0, "Deleting negative filters", done
);
107 if(filters
[i
] && LookupFilter(device
, filters
[i
]) == NULL
)
108 SETERR_GOTO(context
, AL_INVALID_NAME
, filters
[i
], "Invalid filter ID", done
);
112 if((filter
=RemoveFilter(device
, filters
[i
])) == NULL
)
114 FreeThunkEntry(filter
->id
);
116 memset(filter
, 0, sizeof(*filter
));
121 UnlockFiltersWrite(device
);
122 ALCcontext_DecRef(context
);
125 AL_API ALboolean AL_APIENTRY
alIsFilter(ALuint filter
)
130 Context
= GetContextRef();
131 if(!Context
) return AL_FALSE
;
133 LockFiltersRead(Context
->Device
);
134 result
= ((!filter
|| LookupFilter(Context
->Device
, filter
)) ?
136 UnlockFiltersRead(Context
->Device
);
138 ALCcontext_DecRef(Context
);
143 AL_API ALvoid AL_APIENTRY
alFilteri(ALuint filter
, ALenum param
, ALint value
)
149 Context
= GetContextRef();
152 Device
= Context
->Device
;
153 LockFiltersWrite(Device
);
154 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
155 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
158 if(param
== AL_FILTER_TYPE
)
160 if(value
== AL_FILTER_NULL
|| value
== AL_FILTER_LOWPASS
||
161 value
== AL_FILTER_HIGHPASS
|| value
== AL_FILTER_BANDPASS
)
162 InitFilterParams(ALFilter
, value
);
164 alSetError(Context
, AL_INVALID_VALUE
, filter
, "Filter type not supported");
168 /* Call the appropriate handler */
169 V(ALFilter
,setParami
)(Context
, param
, value
);
172 UnlockFiltersWrite(Device
);
174 ALCcontext_DecRef(Context
);
177 AL_API ALvoid AL_APIENTRY
alFilteriv(ALuint filter
, ALenum param
, const ALint
*values
)
186 alFilteri(filter
, param
, values
[0]);
190 Context
= GetContextRef();
193 Device
= Context
->Device
;
194 LockFiltersWrite(Device
);
195 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
196 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
199 /* Call the appropriate handler */
200 V(ALFilter
,setParamiv
)(Context
, param
, values
);
202 UnlockFiltersWrite(Device
);
204 ALCcontext_DecRef(Context
);
207 AL_API ALvoid AL_APIENTRY
alFilterf(ALuint filter
, ALenum param
, ALfloat value
)
213 Context
= GetContextRef();
216 Device
= Context
->Device
;
217 LockFiltersWrite(Device
);
218 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
219 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
222 /* Call the appropriate handler */
223 V(ALFilter
,setParamf
)(Context
, param
, value
);
225 UnlockFiltersWrite(Device
);
227 ALCcontext_DecRef(Context
);
230 AL_API ALvoid AL_APIENTRY
alFilterfv(ALuint filter
, ALenum param
, const ALfloat
*values
)
236 Context
= GetContextRef();
239 Device
= Context
->Device
;
240 LockFiltersWrite(Device
);
241 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
242 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
245 /* Call the appropriate handler */
246 V(ALFilter
,setParamfv
)(Context
, param
, values
);
248 UnlockFiltersWrite(Device
);
250 ALCcontext_DecRef(Context
);
253 AL_API ALvoid AL_APIENTRY
alGetFilteri(ALuint filter
, ALenum param
, ALint
*value
)
259 Context
= GetContextRef();
262 Device
= Context
->Device
;
263 LockFiltersRead(Device
);
264 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
265 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
268 if(param
== AL_FILTER_TYPE
)
269 *value
= ALFilter
->type
;
272 /* Call the appropriate handler */
273 V(ALFilter
,getParami
)(Context
, param
, value
);
276 UnlockFiltersRead(Device
);
278 ALCcontext_DecRef(Context
);
281 AL_API ALvoid AL_APIENTRY
alGetFilteriv(ALuint filter
, ALenum param
, ALint
*values
)
290 alGetFilteri(filter
, param
, values
);
294 Context
= GetContextRef();
297 Device
= Context
->Device
;
298 LockFiltersRead(Device
);
299 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
300 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
303 /* Call the appropriate handler */
304 V(ALFilter
,getParamiv
)(Context
, param
, values
);
306 UnlockFiltersRead(Device
);
308 ALCcontext_DecRef(Context
);
311 AL_API ALvoid AL_APIENTRY
alGetFilterf(ALuint filter
, ALenum param
, ALfloat
*value
)
317 Context
= GetContextRef();
320 Device
= Context
->Device
;
321 LockFiltersRead(Device
);
322 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
323 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
326 /* Call the appropriate handler */
327 V(ALFilter
,getParamf
)(Context
, param
, value
);
329 UnlockFiltersRead(Device
);
331 ALCcontext_DecRef(Context
);
334 AL_API ALvoid AL_APIENTRY
alGetFilterfv(ALuint filter
, ALenum param
, ALfloat
*values
)
340 Context
= GetContextRef();
343 Device
= Context
->Device
;
344 LockFiltersRead(Device
);
345 if((ALFilter
=LookupFilter(Device
, filter
)) == NULL
)
346 alSetError(Context
, AL_INVALID_NAME
, filter
, "Invalid filter ID");
349 /* Call the appropriate handler */
350 V(ALFilter
,getParamfv
)(Context
, param
, values
);
352 UnlockFiltersRead(Device
);
354 ALCcontext_DecRef(Context
);
358 void ALfilterState_setParams(ALfilterState
*filter
, ALfilterType type
, ALfloat gain
, ALfloat f0norm
, ALfloat rcpQ
)
360 ALfloat alpha
, sqrtgain_alpha_2
;
361 ALfloat w0
, sin_w0
, cos_w0
;
362 ALfloat a
[3] = { 1.0f
, 0.0f
, 0.0f
};
363 ALfloat b
[3] = { 1.0f
, 0.0f
, 0.0f
};
365 // Limit gain to -100dB
366 assert(gain
> 0.00001f
);
371 alpha
= sin_w0
/2.0f
* rcpQ
;
373 /* Calculate filter coefficients depending on filter type */
376 case ALfilterType_HighShelf
:
377 sqrtgain_alpha_2
= 2.0f
* sqrtf(gain
) * alpha
;
378 b
[0] = gain
*((gain
+1.0f
) + (gain
-1.0f
)*cos_w0
+ sqrtgain_alpha_2
);
379 b
[1] = -2.0f
*gain
*((gain
-1.0f
) + (gain
+1.0f
)*cos_w0
);
380 b
[2] = gain
*((gain
+1.0f
) + (gain
-1.0f
)*cos_w0
- sqrtgain_alpha_2
);
381 a
[0] = (gain
+1.0f
) - (gain
-1.0f
)*cos_w0
+ sqrtgain_alpha_2
;
382 a
[1] = 2.0f
* ((gain
-1.0f
) - (gain
+1.0f
)*cos_w0
);
383 a
[2] = (gain
+1.0f
) - (gain
-1.0f
)*cos_w0
- sqrtgain_alpha_2
;
385 case ALfilterType_LowShelf
:
386 sqrtgain_alpha_2
= 2.0f
* sqrtf(gain
) * alpha
;
387 b
[0] = gain
*((gain
+1.0f
) - (gain
-1.0f
)*cos_w0
+ sqrtgain_alpha_2
);
388 b
[1] = 2.0f
*gain
*((gain
-1.0f
) - (gain
+1.0f
)*cos_w0
);
389 b
[2] = gain
*((gain
+1.0f
) - (gain
-1.0f
)*cos_w0
- sqrtgain_alpha_2
);
390 a
[0] = (gain
+1.0f
) + (gain
-1.0f
)*cos_w0
+ sqrtgain_alpha_2
;
391 a
[1] = -2.0f
* ((gain
-1.0f
) + (gain
+1.0f
)*cos_w0
);
392 a
[2] = (gain
+1.0f
) + (gain
-1.0f
)*cos_w0
- sqrtgain_alpha_2
;
394 case ALfilterType_Peaking
:
396 b
[0] = 1.0f
+ alpha
* gain
;
397 b
[1] = -2.0f
* cos_w0
;
398 b
[2] = 1.0f
- alpha
* gain
;
399 a
[0] = 1.0f
+ alpha
/ gain
;
400 a
[1] = -2.0f
* cos_w0
;
401 a
[2] = 1.0f
- alpha
/ gain
;
404 case ALfilterType_LowPass
:
405 b
[0] = (1.0f
- cos_w0
) / 2.0f
;
406 b
[1] = 1.0f
- cos_w0
;
407 b
[2] = (1.0f
- cos_w0
) / 2.0f
;
409 a
[1] = -2.0f
* cos_w0
;
412 case ALfilterType_HighPass
:
413 b
[0] = (1.0f
+ cos_w0
) / 2.0f
;
414 b
[1] = -(1.0f
+ cos_w0
);
415 b
[2] = (1.0f
+ cos_w0
) / 2.0f
;
417 a
[1] = -2.0f
* cos_w0
;
420 case ALfilterType_BandPass
:
425 a
[1] = -2.0f
* cos_w0
;
430 filter
->a1
= a
[1] / a
[0];
431 filter
->a2
= a
[2] / a
[0];
432 filter
->b0
= b
[0] / a
[0];
433 filter
->b1
= b
[1] / a
[0];
434 filter
->b2
= b
[2] / a
[0];
438 static void ALlowpass_setParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
UNUSED(val
))
439 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass integer property"); }
440 static void ALlowpass_setParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), const ALint
*UNUSED(vals
))
441 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass integer-vector property"); }
442 static void ALlowpass_setParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat val
)
446 case AL_LOWPASS_GAIN
:
447 if(!(val
>= AL_LOWPASS_MIN_GAIN
&& val
<= AL_LOWPASS_MAX_GAIN
))
448 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "Low-pass gain out of range",);
452 case AL_LOWPASS_GAINHF
:
453 if(!(val
>= AL_LOWPASS_MIN_GAINHF
&& val
<= AL_LOWPASS_MAX_GAINHF
))
454 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "Low-pass gainhf out of range",);
455 filter
->GainHF
= val
;
459 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass float property");
462 static void ALlowpass_setParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, const ALfloat
*vals
)
463 { ALlowpass_setParamf(filter
, context
, param
, vals
[0]); }
465 static void ALlowpass_getParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(val
))
466 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass integer property"); }
467 static void ALlowpass_getParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(vals
))
468 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass integer-vector property"); }
469 static void ALlowpass_getParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*val
)
473 case AL_LOWPASS_GAIN
:
477 case AL_LOWPASS_GAINHF
:
478 *val
= filter
->GainHF
;
482 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid low-pass float property");
485 static void ALlowpass_getParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*vals
)
486 { ALlowpass_getParamf(filter
, context
, param
, vals
); }
488 DEFINE_ALFILTER_VTABLE(ALlowpass
);
491 static void ALhighpass_setParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
UNUSED(val
))
492 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass integer property"); }
493 static void ALhighpass_setParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), const ALint
*UNUSED(vals
))
494 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass integer-vector property"); }
495 static void ALhighpass_setParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat val
)
499 case AL_HIGHPASS_GAIN
:
500 if(!(val
>= AL_HIGHPASS_MIN_GAIN
&& val
<= AL_HIGHPASS_MAX_GAIN
))
501 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "High-pass gain out of range",);
505 case AL_HIGHPASS_GAINLF
:
506 if(!(val
>= AL_HIGHPASS_MIN_GAINLF
&& val
<= AL_HIGHPASS_MAX_GAINLF
))
507 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "High-pass gainlf out of range",);
508 filter
->GainLF
= val
;
512 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass float property");
515 static void ALhighpass_setParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, const ALfloat
*vals
)
516 { ALhighpass_setParamf(filter
, context
, param
, vals
[0]); }
518 static void ALhighpass_getParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(val
))
519 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass integer property"); }
520 static void ALhighpass_getParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(vals
))
521 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass integer-vector property"); }
522 static void ALhighpass_getParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*val
)
526 case AL_HIGHPASS_GAIN
:
530 case AL_HIGHPASS_GAINLF
:
531 *val
= filter
->GainLF
;
535 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid high-pass float property");
538 static void ALhighpass_getParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*vals
)
539 { ALhighpass_getParamf(filter
, context
, param
, vals
); }
541 DEFINE_ALFILTER_VTABLE(ALhighpass
);
544 static void ALbandpass_setParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
UNUSED(val
))
545 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass integer property"); }
546 static void ALbandpass_setParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), const ALint
*UNUSED(vals
))
547 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass integer-vector property"); }
548 static void ALbandpass_setParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat val
)
552 case AL_BANDPASS_GAIN
:
553 if(!(val
>= AL_BANDPASS_MIN_GAIN
&& val
<= AL_BANDPASS_MAX_GAIN
))
554 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "Band-pass gain out of range",);
558 case AL_BANDPASS_GAINHF
:
559 if(!(val
>= AL_BANDPASS_MIN_GAINHF
&& val
<= AL_BANDPASS_MAX_GAINHF
))
560 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "Band-pass gainhf out of range",);
561 filter
->GainHF
= val
;
564 case AL_BANDPASS_GAINLF
:
565 if(!(val
>= AL_BANDPASS_MIN_GAINLF
&& val
<= AL_BANDPASS_MAX_GAINLF
))
566 SETERR_RETURN(context
, AL_INVALID_VALUE
, filter
->id
, "Band-pass gainlf out of range",);
567 filter
->GainLF
= val
;
571 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass float property");
574 static void ALbandpass_setParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, const ALfloat
*vals
)
575 { ALbandpass_setParamf(filter
, context
, param
, vals
[0]); }
577 static void ALbandpass_getParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(val
))
578 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass integer property"); }
579 static void ALbandpass_getParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(vals
))
580 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass integer-vector property"); }
581 static void ALbandpass_getParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*val
)
585 case AL_BANDPASS_GAIN
:
589 case AL_BANDPASS_GAINHF
:
590 *val
= filter
->GainHF
;
593 case AL_BANDPASS_GAINLF
:
594 *val
= filter
->GainLF
;
598 alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid band-pass float property");
601 static void ALbandpass_getParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*vals
)
602 { ALbandpass_getParamf(filter
, context
, param
, vals
); }
604 DEFINE_ALFILTER_VTABLE(ALbandpass
);
607 static void ALnullfilter_setParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
UNUSED(val
))
608 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
609 static void ALnullfilter_setParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), const ALint
*UNUSED(vals
))
610 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
611 static void ALnullfilter_setParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALfloat
UNUSED(val
))
612 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
613 static void ALnullfilter_setParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), const ALfloat
*UNUSED(vals
))
614 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
616 static void ALnullfilter_getParami(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(val
))
617 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
618 static void ALnullfilter_getParamiv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALint
*UNUSED(vals
))
619 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
620 static void ALnullfilter_getParamf(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALfloat
*UNUSED(val
))
621 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
622 static void ALnullfilter_getParamfv(ALfilter
*filter
, ALCcontext
*context
, ALenum
UNUSED(param
), ALfloat
*UNUSED(vals
))
623 { alSetError(context
, AL_INVALID_ENUM
, filter
->id
, "Invalid null filter property"); }
625 DEFINE_ALFILTER_VTABLE(ALnullfilter
);
628 ALvoid
ReleaseALFilters(ALCdevice
*device
)
631 for(i
= 0;i
< device
->FilterMap
.size
;i
++)
633 ALfilter
*temp
= device
->FilterMap
.values
[i
];
634 device
->FilterMap
.values
[i
] = NULL
;
636 // Release filter structure
637 FreeThunkEntry(temp
->id
);
638 memset(temp
, 0, sizeof(ALfilter
));
644 static void InitFilterParams(ALfilter
*filter
, ALenum type
)
646 if(type
== AL_FILTER_LOWPASS
)
648 filter
->Gain
= AL_LOWPASS_DEFAULT_GAIN
;
649 filter
->GainHF
= AL_LOWPASS_DEFAULT_GAINHF
;
650 filter
->HFReference
= LOWPASSFREQREF
;
651 filter
->GainLF
= 1.0f
;
652 filter
->LFReference
= HIGHPASSFREQREF
;
653 filter
->vtbl
= &ALlowpass_vtable
;
655 else if(type
== AL_FILTER_HIGHPASS
)
657 filter
->Gain
= AL_HIGHPASS_DEFAULT_GAIN
;
658 filter
->GainHF
= 1.0f
;
659 filter
->HFReference
= LOWPASSFREQREF
;
660 filter
->GainLF
= AL_HIGHPASS_DEFAULT_GAINLF
;
661 filter
->LFReference
= HIGHPASSFREQREF
;
662 filter
->vtbl
= &ALhighpass_vtable
;
664 else if(type
== AL_FILTER_BANDPASS
)
666 filter
->Gain
= AL_BANDPASS_DEFAULT_GAIN
;
667 filter
->GainHF
= AL_BANDPASS_DEFAULT_GAINHF
;
668 filter
->HFReference
= LOWPASSFREQREF
;
669 filter
->GainLF
= AL_BANDPASS_DEFAULT_GAINLF
;
670 filter
->LFReference
= HIGHPASSFREQREF
;
671 filter
->vtbl
= &ALbandpass_vtable
;
676 filter
->GainHF
= 1.0f
;
677 filter
->HFReference
= LOWPASSFREQREF
;
678 filter
->GainLF
= 1.0f
;
679 filter
->LFReference
= HIGHPASSFREQREF
;
680 filter
->vtbl
= &ALnullfilter_vtable
;