| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
// Standard C++ library includes |
| 23 |
#include <algorithm> |
| 24 |
|
| 25 |
// Platform specific includes |
| 26 |
|
| 27 |
// 3rd party library includes |
| 28 |
|
| 29 |
// FIFE includes |
| 30 |
// These includes are split up in two parts, separated by one empty line |
| 31 |
// First block: files included from the FIFE root src directory |
| 32 |
// Second block: files included from the same folder |
| 33 |
#include "util/log/logger.h" |
| 34 |
#include "util/base/exception.h" |
| 35 |
|
| 36 |
#include "soundeffect.h" |
| 37 |
|
| 38 |
namespace FIFE { |
| 39 |
/** Logger to use for this source file. |
| 40 |
* @relates Logger |
| 41 |
*/ |
| 42 |
static Logger _log(LM_AUDIO); |
| 43 |
|
| 44 |
|
| 45 |
SoundEffect::SoundEffect() : |
| 46 |
m_effect(0), |
| 47 |
m_slot(0), |
| 48 |
m_effectType(SE_EFFECT_NULL), |
| 49 |
m_enabled(false), |
| 50 |
m_filter(NULL) { |
| 51 |
|
| 52 |
alGenEffects(1, &m_effect); |
| 53 |
} |
| 54 |
|
| 55 |
SoundEffect::~SoundEffect() { |
| 56 |
alDeleteEffects(1, &m_effect); |
| 57 |
} |
| 58 |
|
| 59 |
ALuint SoundEffect::getEffectId() const { |
| 60 |
return m_effect; |
| 61 |
} |
| 62 |
|
| 63 |
void SoundEffect::setSlotId(ALuint slot) { |
| 64 |
m_slot = slot; |
| 65 |
} |
| 66 |
|
| 67 |
ALuint SoundEffect::getSlotId() { |
| 68 |
return m_slot; |
| 69 |
} |
| 70 |
|
| 71 |
SoundEffectType SoundEffect::getEffectType() const { |
| 72 |
return m_effectType; |
| 73 |
} |
| 74 |
|
| 75 |
void SoundEffect::setEnabled(bool enabled) { |
| 76 |
m_enabled = enabled; |
| 77 |
} |
| 78 |
|
| 79 |
bool SoundEffect::isEnabled() const { |
| 80 |
return m_enabled; |
| 81 |
} |
| 82 |
|
| 83 |
void SoundEffect::setFilter(SoundFilter* filter) { |
| 84 |
m_filter = filter; |
| 85 |
} |
| 86 |
|
| 87 |
SoundFilter* SoundEffect::getFilter() { |
| 88 |
return m_filter; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
Reverb::Reverb() : |
| 93 |
m_density(1.0f), |
| 94 |
m_diffusion(1.0f), |
| 95 |
m_gain(0.32f), |
| 96 |
m_gainHf(0.89f), |
| 97 |
m_decayTime(1.49f), |
| 98 |
m_decayHfRatio(0.83f), |
| 99 |
m_reflectionsGain(0.05f), |
| 100 |
m_reflectionsDelay(0.007f), |
| 101 |
m_lateReverbGain(1.26f), |
| 102 |
m_lateReverbDelay(0.011f), |
| 103 |
m_airAbsorptionGainHf(0.994f), |
| 104 |
m_roomRolloffFactor(0.0f), |
| 105 |
m_decayHfLimit(true) { |
| 106 |
|
| 107 |
m_effectType = SE_EFFECT_REVERB; |
| 108 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); |
| 109 |
} |
| 110 |
|
| 111 |
void Reverb::setDensity(float value) { |
| 112 |
value = std::min(value, 1.0f); |
| 113 |
value = std::max(value, 0.0f); |
| 114 |
m_density = value; |
| 115 |
alEffectf(m_effect, AL_REVERB_DENSITY, m_density); |
| 116 |
} |
| 117 |
|
| 118 |
float Reverb::getDensity() const { |
| 119 |
return m_density; |
| 120 |
} |
| 121 |
|
| 122 |
void Reverb::setDiffusion(float value) { |
| 123 |
value = std::min(value, 1.0f); |
| 124 |
value = std::max(value, 0.0f); |
| 125 |
m_diffusion = value; |
| 126 |
alEffectf(m_effect, AL_REVERB_DIFFUSION, m_diffusion); |
| 127 |
} |
| 128 |
|
| 129 |
float Reverb::getDiffusion() const { |
| 130 |
return m_diffusion; |
| 131 |
} |
| 132 |
|
| 133 |
void Reverb::setGain(float value) { |
| 134 |
value = std::min(value, 1.0f); |
| 135 |
value = std::max(value, 0.0f); |
| 136 |
m_gain = value; |
| 137 |
alEffectf(m_effect, AL_REVERB_GAIN, m_gain); |
| 138 |
} |
| 139 |
|
| 140 |
float Reverb::getGain() const { |
| 141 |
return m_gain; |
| 142 |
} |
| 143 |
|
| 144 |
void Reverb::setGainHf(float value) { |
| 145 |
value = std::min(value, 1.0f); |
| 146 |
value = std::max(value, 0.0f); |
| 147 |
m_gainHf = value; |
| 148 |
alEffectf(m_effect, AL_REVERB_GAINHF, m_gainHf); |
| 149 |
} |
| 150 |
|
| 151 |
float Reverb::getGainHf() const { |
| 152 |
return m_gainHf; |
| 153 |
} |
| 154 |
|
| 155 |
void Reverb::setDecayTime(float value) { |
| 156 |
value = std::min(value, 20.0f); |
| 157 |
value = std::max(value, 0.1f); |
| 158 |
m_decayTime = value; |
| 159 |
alEffectf(m_effect, AL_REVERB_DECAY_TIME, m_decayTime); |
| 160 |
} |
| 161 |
|
| 162 |
float Reverb::getDecayTime() const { |
| 163 |
return m_decayTime; |
| 164 |
} |
| 165 |
|
| 166 |
void Reverb::setDecayHfRatio(float value) { |
| 167 |
value = std::min(value, 2.0f); |
| 168 |
value = std::max(value, 0.1f); |
| 169 |
m_decayHfRatio = value; |
| 170 |
alEffectf(m_effect, AL_REVERB_DECAY_HFRATIO, m_decayHfRatio); |
| 171 |
} |
| 172 |
|
| 173 |
float Reverb::getDecayHfRatio() const { |
| 174 |
return m_decayHfRatio; |
| 175 |
} |
| 176 |
|
| 177 |
void Reverb::setReflectionsGain(float value) { |
| 178 |
value = std::min(value, 3.16f); |
| 179 |
value = std::max(value, 0.0f); |
| 180 |
m_reflectionsGain = value; |
| 181 |
alEffectf(m_effect, AL_REVERB_REFLECTIONS_GAIN, m_reflectionsGain); |
| 182 |
} |
| 183 |
|
| 184 |
float Reverb::getReflectionsGain() const { |
| 185 |
return m_reflectionsGain; |
| 186 |
} |
| 187 |
|
| 188 |
void Reverb::setReflectionsDelay(float value) { |
| 189 |
value = std::min(value, 0.3f); |
| 190 |
value = std::max(value, 0.0f); |
| 191 |
m_reflectionsDelay = value; |
| 192 |
alEffectf(m_effect, AL_REVERB_REFLECTIONS_DELAY, m_reflectionsDelay); |
| 193 |
} |
| 194 |
|
| 195 |
float Reverb::getReflectionsDelay() const { |
| 196 |
return m_reflectionsDelay; |
| 197 |
} |
| 198 |
|
| 199 |
void Reverb::setLateReverbGain(float value) { |
| 200 |
value = std::min(value, 10.0f); |
| 201 |
value = std::max(value, 0.0f); |
| 202 |
m_lateReverbGain = value; |
| 203 |
alEffectf(m_effect, AL_REVERB_LATE_REVERB_GAIN, m_lateReverbGain); |
| 204 |
} |
| 205 |
|
| 206 |
float Reverb::getLateReverbGain() const { |
| 207 |
return m_lateReverbGain; |
| 208 |
} |
| 209 |
|
| 210 |
void Reverb::setLateReverbDelay(float value) { |
| 211 |
value = std::min(value, 0.1f); |
| 212 |
value = std::max(value, 0.0f); |
| 213 |
m_reflectionsDelay = value; |
| 214 |
alEffectf(m_effect, AL_REVERB_LATE_REVERB_DELAY, m_reflectionsDelay); |
| 215 |
} |
| 216 |
|
| 217 |
float Reverb::getLateReverbDelay() const { |
| 218 |
return m_reflectionsDelay; |
| 219 |
} |
| 220 |
|
| 221 |
void Reverb::setAirAbsorptionGainHf(float value) { |
| 222 |
value = std::min(value, 1.0f); |
| 223 |
value = std::max(value, 0.892f); |
| 224 |
m_airAbsorptionGainHf = value; |
| 225 |
alEffectf(m_effect, AL_REVERB_AIR_ABSORPTION_GAINHF, m_airAbsorptionGainHf); |
| 226 |
} |
| 227 |
|
| 228 |
float Reverb::getAirAbsorptionGainHf() const { |
| 229 |
return m_airAbsorptionGainHf; |
| 230 |
} |
| 231 |
|
| 232 |
void Reverb::setRoomRolloffFactor(float value) { |
| 233 |
value = std::min(value, 10.0f); |
| 234 |
value = std::max(value, 0.0f); |
| 235 |
m_roomRolloffFactor = value; |
| 236 |
alEffectf(m_effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, m_roomRolloffFactor); |
| 237 |
} |
| 238 |
|
| 239 |
float Reverb::getRoomRolloffFactor() const { |
| 240 |
return m_roomRolloffFactor; |
| 241 |
} |
| 242 |
|
| 243 |
void Reverb::setDecayHfLimit(bool value) { |
| 244 |
m_decayHfLimit = value; |
| 245 |
alEffecti(m_effect, AL_REVERB_DECAY_HFLIMIT, m_decayHfLimit ? AL_TRUE : AL_FALSE); |
| 246 |
} |
| 247 |
|
| 248 |
bool Reverb::isDecayHfLimit() const { |
| 249 |
return m_decayHfLimit; |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
Chorus::Chorus() : |
| 254 |
m_waveformTriangle(true), |
| 255 |
m_phase(90), |
| 256 |
m_rate(1.1f), |
| 257 |
m_depth(0.1f), |
| 258 |
m_feedback(0.25f), |
| 259 |
m_delay(0.016f) { |
| 260 |
m_effectType = SE_EFFECT_CHORUS; |
| 261 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_CHORUS); |
| 262 |
} |
| 263 |
|
| 264 |
void Chorus::setWaveformTriangle(bool value) { |
| 265 |
m_waveformTriangle = value; |
| 266 |
if (m_waveformTriangle) { |
| 267 |
alEffecti(m_effect, AL_CHORUS_WAVEFORM, AL_CHORUS_WAVEFORM_TRIANGLE); |
| 268 |
} else { |
| 269 |
alEffecti(m_effect, AL_CHORUS_WAVEFORM, AL_CHORUS_WAVEFORM_SINUSOID); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
bool Chorus::isWaveformTriangle() const { |
| 274 |
return m_waveformTriangle; |
| 275 |
} |
| 276 |
|
| 277 |
void Chorus::setPhase(int32_t value) { |
| 278 |
value = std::min(value, 180); |
| 279 |
value = std::max(value, -180); |
| 280 |
m_phase = value; |
| 281 |
alEffecti(m_effect, AL_CHORUS_PHASE, m_phase); |
| 282 |
} |
| 283 |
|
| 284 |
int32_t Chorus::getPhase() const { |
| 285 |
return m_phase; |
| 286 |
} |
| 287 |
|
| 288 |
void Chorus::setRate(float value) { |
| 289 |
value = std::min(value, 10.0f); |
| 290 |
value = std::max(value, 0.0f); |
| 291 |
m_rate = value; |
| 292 |
alEffectf(m_effect, AL_CHORUS_RATE, m_rate); |
| 293 |
} |
| 294 |
|
| 295 |
float Chorus::getRate() const { |
| 296 |
return m_rate; |
| 297 |
} |
| 298 |
|
| 299 |
void Chorus::setDepth(float value) { |
| 300 |
value = std::min(value, 1.0f); |
| 301 |
value = std::max(value, 0.0f); |
| 302 |
m_depth = value; |
| 303 |
alEffectf(m_effect, AL_CHORUS_DEPTH, m_depth); |
| 304 |
} |
| 305 |
|
| 306 |
float Chorus::getDepth() const { |
| 307 |
return m_depth; |
| 308 |
} |
| 309 |
|
| 310 |
void Chorus::setFeedback(float value) { |
| 311 |
value = std::min(value, 1.0f); |
| 312 |
value = std::max(value, -1.0f); |
| 313 |
m_feedback = value; |
| 314 |
alEffectf(m_effect, AL_CHORUS_FEEDBACK, m_feedback); |
| 315 |
} |
| 316 |
|
| 317 |
float Chorus::getFeedback() const { |
| 318 |
return m_feedback; |
| 319 |
} |
| 320 |
|
| 321 |
void Chorus::setDelay(float value) { |
| 322 |
value = std::min(value, 0.016f); |
| 323 |
value = std::max(value, 0.0f); |
| 324 |
m_delay = value; |
| 325 |
alEffectf(m_effect, AL_CHORUS_DELAY, m_delay); |
| 326 |
} |
| 327 |
|
| 328 |
float Chorus::getDelay() const { |
| 329 |
return m_delay; |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
Distortion::Distortion() : |
| 334 |
m_edge(0.2f), |
| 335 |
m_gain(0.05f), |
| 336 |
m_lowpassCutoff(8000.0f), |
| 337 |
m_eqCenter(3600.0f), |
| 338 |
m_eqBandwidth(3600.0f) { |
| 339 |
m_effectType = SE_EFFECT_DISTORTION; |
| 340 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_DISTORTION); |
| 341 |
} |
| 342 |
|
| 343 |
void Distortion::setEdge(float value) { |
| 344 |
value = std::min(value, 1.0f); |
| 345 |
value = std::max(value, 0.0f); |
| 346 |
m_edge = value; |
| 347 |
alEffectf(m_effect, AL_DISTORTION_EDGE, m_edge); |
| 348 |
} |
| 349 |
|
| 350 |
float Distortion::getEdge() const { |
| 351 |
return m_edge; |
| 352 |
} |
| 353 |
|
| 354 |
void Distortion::setGain(float value) { |
| 355 |
value = std::min(value, 1.0f); |
| 356 |
value = std::max(value, 0.01f); |
| 357 |
m_gain = value; |
| 358 |
alEffectf(m_effect, AL_DISTORTION_GAIN, m_gain); |
| 359 |
} |
| 360 |
|
| 361 |
float Distortion::getGain() const { |
| 362 |
return m_gain; |
| 363 |
} |
| 364 |
|
| 365 |
void Distortion::setLowpassCutoff(float value) { |
| 366 |
value = std::min(value, 24000.0f); |
| 367 |
value = std::max(value, 80.0f); |
| 368 |
m_lowpassCutoff = value; |
| 369 |
alEffectf(m_effect, AL_DISTORTION_LOWPASS_CUTOFF, m_lowpassCutoff); |
| 370 |
} |
| 371 |
|
| 372 |
float Distortion::getLowpassCutoff() const { |
| 373 |
return m_lowpassCutoff; |
| 374 |
} |
| 375 |
|
| 376 |
void Distortion::setEqCenter(float value) { |
| 377 |
value = std::min(value, 24000.0f); |
| 378 |
value = std::max(value, 80.0f); |
| 379 |
m_eqCenter = value; |
| 380 |
alEffectf(m_effect, AL_DISTORTION_EQCENTER, m_eqCenter); |
| 381 |
} |
| 382 |
|
| 383 |
float Distortion::getEqCenter() const { |
| 384 |
return m_eqCenter; |
| 385 |
} |
| 386 |
|
| 387 |
void Distortion::setEqBandwidth(float value) { |
| 388 |
value = std::min(value, 24000.0f); |
| 389 |
value = std::max(value, 80.0f); |
| 390 |
m_eqBandwidth = value; |
| 391 |
alEffectf(m_effect, AL_DISTORTION_EQBANDWIDTH, m_eqBandwidth); |
| 392 |
} |
| 393 |
|
| 394 |
float Distortion::getEqBandwidth() const { |
| 395 |
return m_eqBandwidth; |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
Echo::Echo() : |
| 400 |
m_delay(0.1f), |
| 401 |
m_lrDelay(0.1f), |
| 402 |
m_damping(0.5f), |
| 403 |
m_feedback(0.5f), |
| 404 |
m_spread(-1.0f) { |
| 405 |
m_effectType = SE_EFFECT_ECHO; |
| 406 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_ECHO); |
| 407 |
} |
| 408 |
|
| 409 |
void Echo::setDelay(float value) { |
| 410 |
value = std::min(value, 0.207f); |
| 411 |
value = std::max(value, 0.0f); |
| 412 |
m_delay = value; |
| 413 |
alEffectf(m_effect, AL_ECHO_DELAY, m_delay); |
| 414 |
} |
| 415 |
|
| 416 |
float Echo::getDelay() const { |
| 417 |
return m_delay; |
| 418 |
} |
| 419 |
|
| 420 |
void Echo::setLrDelay(float value) { |
| 421 |
value = std::min(value, 0.404f); |
| 422 |
value = std::max(value, 0.0f); |
| 423 |
m_lrDelay = value; |
| 424 |
alEffectf(m_effect, AL_ECHO_LRDELAY, m_lrDelay); |
| 425 |
} |
| 426 |
|
| 427 |
float Echo::getLrDelay() const { |
| 428 |
return m_lrDelay; |
| 429 |
} |
| 430 |
|
| 431 |
void Echo::setDamping(float value) { |
| 432 |
value = std::min(value, 0.99f); |
| 433 |
value = std::max(value, 0.0f); |
| 434 |
m_damping = value; |
| 435 |
alEffectf(m_effect, AL_ECHO_DAMPING, m_damping); |
| 436 |
} |
| 437 |
|
| 438 |
float Echo::getDamping() const { |
| 439 |
return m_damping; |
| 440 |
} |
| 441 |
|
| 442 |
void Echo::setFeedback(float value) { |
| 443 |
value = std::min(value, 1.0f); |
| 444 |
value = std::max(value, 0.0f); |
| 445 |
m_feedback = value; |
| 446 |
alEffectf(m_effect, AL_ECHO_FEEDBACK, m_feedback); |
| 447 |
} |
| 448 |
|
| 449 |
float Echo::getFeedback() const { |
| 450 |
return m_feedback; |
| 451 |
} |
| 452 |
|
| 453 |
void Echo::setSpread(float value) { |
| 454 |
value = std::min(value, 1.0f); |
| 455 |
value = std::max(value, -1.0f); |
| 456 |
m_spread = value; |
| 457 |
alEffectf(m_effect, AL_ECHO_SPREAD, m_spread); |
| 458 |
} |
| 459 |
|
| 460 |
float Echo::getSpread() const { |
| 461 |
return m_spread; |
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
Flanger::Flanger() : |
| 466 |
m_waveformTriangle(true), |
| 467 |
m_phase(0), |
| 468 |
m_rate(0.27f), |
| 469 |
m_depth(1.0f), |
| 470 |
m_feedback(-0.5f), |
| 471 |
m_delay(0.002f) { |
| 472 |
m_effectType = SE_EFFECT_FLANGER; |
| 473 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_FLANGER); |
| 474 |
} |
| 475 |
|
| 476 |
void Flanger::setWaveformTriangle(bool value) { |
| 477 |
m_waveformTriangle = value; |
| 478 |
if (m_waveformTriangle) { |
| 479 |
alEffecti(m_effect, AL_FLANGER_WAVEFORM, AL_FLANGER_WAVEFORM_TRIANGLE); |
| 480 |
} else { |
| 481 |
alEffecti(m_effect, AL_FLANGER_WAVEFORM, AL_FLANGER_WAVEFORM_SINUSOID); |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
bool Flanger::isWaveformTriangle() const { |
| 486 |
return m_waveformTriangle; |
| 487 |
} |
| 488 |
|
| 489 |
void Flanger::setPhase(int32_t value) { |
| 490 |
value = std::min(value, 180); |
| 491 |
value = std::max(value, -180); |
| 492 |
m_phase = value; |
| 493 |
alEffecti(m_effect, AL_FLANGER_PHASE, m_phase); |
| 494 |
} |
| 495 |
|
| 496 |
int32_t Flanger::getPhase() const { |
| 497 |
return m_phase; |
| 498 |
} |
| 499 |
|
| 500 |
void Flanger::setRate(float value) { |
| 501 |
value = std::min(value, 10.0f); |
| 502 |
value = std::max(value, 0.0f); |
| 503 |
m_rate = value; |
| 504 |
alEffectf(m_effect, AL_FLANGER_RATE, m_rate); |
| 505 |
} |
| 506 |
|
| 507 |
float Flanger::getRate() const { |
| 508 |
return m_rate; |
| 509 |
} |
| 510 |
|
| 511 |
void Flanger::setDepth(float value) { |
| 512 |
value = std::min(value, 1.0f); |
| 513 |
value = std::max(value, 0.0f); |
| 514 |
m_depth = value; |
| 515 |
alEffectf(m_effect, AL_FLANGER_DEPTH, m_depth); |
| 516 |
} |
| 517 |
|
| 518 |
float Flanger::getDepth() const { |
| 519 |
return m_depth; |
| 520 |
} |
| 521 |
|
| 522 |
void Flanger::setFeedback(float value) { |
| 523 |
value = std::min(value, 1.0f); |
| 524 |
value = std::max(value, -1.0f); |
| 525 |
m_feedback = value; |
| 526 |
alEffectf(m_effect, AL_FLANGER_FEEDBACK, m_feedback); |
| 527 |
} |
| 528 |
|
| 529 |
float Flanger::getFeedback() const { |
| 530 |
return m_feedback; |
| 531 |
} |
| 532 |
|
| 533 |
void Flanger::setDelay(float value) { |
| 534 |
value = std::min(value, 0.004f); |
| 535 |
value = std::max(value, 0.0f); |
| 536 |
m_delay = value; |
| 537 |
alEffectf(m_effect, AL_FLANGER_DELAY, m_delay); |
| 538 |
} |
| 539 |
|
| 540 |
float Flanger::getDelay() const { |
| 541 |
return m_delay; |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
FrequencyShifter::FrequencyShifter() : |
| 546 |
m_frequency(0.0f), |
| 547 |
m_leftDirection(0), |
| 548 |
m_rightDirection(0) { |
| 549 |
m_effectType = SE_EFFECT_FREQUENCY_SHIFTER; |
| 550 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_FREQUENCY_SHIFTER); |
| 551 |
} |
| 552 |
|
| 553 |
void FrequencyShifter::setFrequency(float value) { |
| 554 |
value = std::min(value, 24000.0f); |
| 555 |
value = std::max(value, 0.0f); |
| 556 |
m_frequency = value; |
| 557 |
alEffectf(m_effect, AL_FREQUENCY_SHIFTER_FREQUENCY, m_frequency); |
| 558 |
} |
| 559 |
|
| 560 |
float FrequencyShifter::getFrequency() const { |
| 561 |
return m_frequency; |
| 562 |
} |
| 563 |
|
| 564 |
void FrequencyShifter::setLeftDirection(uint8_t value) { |
| 565 |
value = std::min(value, uint8_t(2)); |
| 566 |
value = std::max(value, uint8_t(0)); |
| 567 |
m_leftDirection = value; |
| 568 |
alEffecti(m_effect, AL_FREQUENCY_SHIFTER_LEFT_DIRECTION, m_leftDirection); |
| 569 |
} |
| 570 |
|
| 571 |
uint8_t FrequencyShifter::getLeftDirection() const { |
| 572 |
return m_leftDirection; |
| 573 |
} |
| 574 |
|
| 575 |
void FrequencyShifter::setRightDirection(uint8_t value) { |
| 576 |
value = std::min(value, uint8_t(2)); |
| 577 |
value = std::max(value, uint8_t(0)); |
| 578 |
m_rightDirection = value; |
| 579 |
alEffecti(m_effect, AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION, m_rightDirection); |
| 580 |
} |
| 581 |
|
| 582 |
uint8_t FrequencyShifter::getRightDirection() const { |
| 583 |
return m_rightDirection; |
| 584 |
} |
| 585 |
|
| 586 |
|
| 587 |
VocalMorpher::VocalMorpher() : |
| 588 |
m_phonemeA(0), |
| 589 |
m_phonemeB(10), |
| 590 |
m_phonemeCoarseA(0), |
| 591 |
m_phonemeCoarseB(0), |
| 592 |
m_waveform(0), |
| 593 |
m_rate(1.41f) { |
| 594 |
m_effectType = SE_EFFECT_VOCAL_MORPHER; |
| 595 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_VOCAL_MORPHER); |
| 596 |
} |
| 597 |
|
| 598 |
void VocalMorpher::setPhonemeA(uint16_t value) { |
| 599 |
value = std::min(value, uint16_t(29)); |
| 600 |
value = std::max(value, uint16_t(0)); |
| 601 |
m_phonemeA = value; |
| 602 |
alEffecti(m_effect, AL_VOCAL_MORPHER_PHONEMEA, m_phonemeA); |
| 603 |
} |
| 604 |
|
| 605 |
uint16_t VocalMorpher::getPhonemeA() const { |
| 606 |
return m_phonemeA; |
| 607 |
} |
| 608 |
|
| 609 |
void VocalMorpher::setPhonemeB(uint16_t value) { |
| 610 |
value = std::min(value, uint16_t(29)); |
| 611 |
value = std::max(value, uint16_t(0)); |
| 612 |
m_phonemeB = value; |
| 613 |
alEffecti(m_effect, AL_VOCAL_MORPHER_PHONEMEB, m_phonemeB); |
| 614 |
} |
| 615 |
|
| 616 |
uint16_t VocalMorpher::getPhonemeB() const { |
| 617 |
return m_phonemeB; |
| 618 |
} |
| 619 |
|
| 620 |
void VocalMorpher::setPhonemeCoarseA(int16_t value) { |
| 621 |
value = std::min(value, int16_t(24)); |
| 622 |
value = std::max(value, int16_t(-24)); |
| 623 |
m_phonemeCoarseA = value; |
| 624 |
alEffecti(m_effect, AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING, m_phonemeCoarseA); |
| 625 |
} |
| 626 |
|
| 627 |
int16_t VocalMorpher::getPhonemeCoarseA() const { |
| 628 |
return m_phonemeCoarseA; |
| 629 |
} |
| 630 |
|
| 631 |
void VocalMorpher::setPhonemeCoarseB(int16_t value) { |
| 632 |
value = std::min(value, int16_t(24)); |
| 633 |
value = std::max(value, int16_t(-24)); |
| 634 |
m_phonemeCoarseB = value; |
| 635 |
alEffecti(m_effect, AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING, m_phonemeCoarseB); |
| 636 |
} |
| 637 |
|
| 638 |
int16_t VocalMorpher::getPhonemeCoarseB() const { |
| 639 |
return m_phonemeCoarseB; |
| 640 |
} |
| 641 |
|
| 642 |
void VocalMorpher::setWaveform(uint8_t value) { |
| 643 |
value = std::min(value, uint8_t(2)); |
| 644 |
value = std::max(value, uint8_t(0)); |
| 645 |
m_waveform = value; |
| 646 |
alEffecti(m_effect, AL_VOCAL_MORPHER_WAVEFORM, m_waveform); |
| 647 |
} |
| 648 |
|
| 649 |
uint8_t VocalMorpher::getWaveform() const { |
| 650 |
return m_waveform; |
| 651 |
} |
| 652 |
|
| 653 |
void VocalMorpher::setRate(float value) { |
| 654 |
value = std::min(value, 10.0f); |
| 655 |
value = std::max(value, 0.0f); |
| 656 |
m_rate = value; |
| 657 |
alEffectf(m_effect, AL_VOCAL_MORPHER_RATE, m_rate); |
| 658 |
} |
| 659 |
|
| 660 |
float VocalMorpher::getRate() const { |
| 661 |
return m_rate; |
| 662 |
} |
| 663 |
|
| 664 |
|
| 665 |
PitchShifter::PitchShifter() : |
| 666 |
m_coarseTune(12), |
| 667 |
m_fineTune(0) { |
| 668 |
m_effectType = SE_EFFECT_PITCH_SHIFTER; |
| 669 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_PITCH_SHIFTER); |
| 670 |
} |
| 671 |
|
| 672 |
void PitchShifter::setCoarseTune(int16_t value) { |
| 673 |
value = std::min(value, int16_t(12)); |
| 674 |
value = std::max(value, int16_t(-12)); |
| 675 |
m_coarseTune = value; |
| 676 |
alEffecti(m_effect, AL_PITCH_SHIFTER_COARSE_TUNE, m_coarseTune); |
| 677 |
} |
| 678 |
|
| 679 |
int16_t PitchShifter::getCoarseTune() const { |
| 680 |
return m_coarseTune; |
| 681 |
} |
| 682 |
|
| 683 |
void PitchShifter::setFineTune(int16_t value) { |
| 684 |
value = std::min(value, int16_t(50)); |
| 685 |
value = std::max(value, int16_t(-50)); |
| 686 |
m_fineTune = value; |
| 687 |
alEffecti(m_effect, AL_PITCH_SHIFTER_FINE_TUNE, m_fineTune); |
| 688 |
} |
| 689 |
|
| 690 |
int16_t PitchShifter::getFineTune() const { |
| 691 |
return m_fineTune; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
RingModulator::RingModulator() : |
| 696 |
m_frequency(440.0f), |
| 697 |
m_highpassCutoff(800.0f), |
| 698 |
m_waveform(0) { |
| 699 |
m_effectType = SE_EFFECT_RING_MODULATOR; |
| 700 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_RING_MODULATOR); |
| 701 |
} |
| 702 |
|
| 703 |
void RingModulator::setFrequency(float value) { |
| 704 |
value = std::min(value, 8000.0f); |
| 705 |
value = std::max(value, 0.0f); |
| 706 |
m_frequency = value; |
| 707 |
alEffectf(m_effect, AL_RING_MODULATOR_FREQUENCY, m_frequency); |
| 708 |
} |
| 709 |
|
| 710 |
float RingModulator::getFrequency() const { |
| 711 |
return m_frequency; |
| 712 |
} |
| 713 |
|
| 714 |
void RingModulator::setHighpassCutoff(float value) { |
| 715 |
value = std::min(value, 24000.0f); |
| 716 |
value = std::max(value, 0.0f); |
| 717 |
m_highpassCutoff = value; |
| 718 |
alEffectf(m_effect, AL_RING_MODULATOR_HIGHPASS_CUTOFF, m_highpassCutoff); |
| 719 |
} |
| 720 |
|
| 721 |
float RingModulator::getHighpassCutoff() const { |
| 722 |
return m_highpassCutoff; |
| 723 |
} |
| 724 |
|
| 725 |
void RingModulator::setWaveform(uint8_t value) { |
| 726 |
value = std::min(value, uint8_t(2)); |
| 727 |
value = std::max(value, uint8_t(0)); |
| 728 |
m_waveform = value; |
| 729 |
alEffecti(m_effect, AL_RING_MODULATOR_WAVEFORM, m_waveform); |
| 730 |
} |
| 731 |
|
| 732 |
uint8_t RingModulator::getWaveform() const { |
| 733 |
return m_waveform; |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
Autowah::Autowah() : |
| 738 |
m_attackTime(0.06f), |
| 739 |
m_releaseTime(0.06f), |
| 740 |
m_resonance(1000.0f), |
| 741 |
m_peakGain(11.22f) { |
| 742 |
m_effectType = SE_EFFECT_AUTOWAH; |
| 743 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_AUTOWAH); |
| 744 |
} |
| 745 |
|
| 746 |
void Autowah::setAttackTime(float value) { |
| 747 |
value = std::min(value, 1.0f); |
| 748 |
value = std::max(value, 0.0001f); |
| 749 |
m_attackTime = value; |
| 750 |
alEffectf(m_effect, AL_AUTOWAH_ATTACK_TIME, m_attackTime); |
| 751 |
} |
| 752 |
|
| 753 |
float Autowah::getAttackTime() const { |
| 754 |
return m_attackTime; |
| 755 |
} |
| 756 |
|
| 757 |
void Autowah::setReleaseTime(float value) { |
| 758 |
value = std::min(value, 1.0f); |
| 759 |
value = std::max(value, 0.0001f); |
| 760 |
m_releaseTime = value; |
| 761 |
alEffectf(m_effect, AL_AUTOWAH_RELEASE_TIME, m_releaseTime); |
| 762 |
} |
| 763 |
|
| 764 |
float Autowah::getReleaseTime() const { |
| 765 |
return m_releaseTime; |
| 766 |
} |
| 767 |
|
| 768 |
void Autowah::setResonance(float value) { |
| 769 |
value = std::min(value, 1000.0f); |
| 770 |
value = std::max(value, 2.0f); |
| 771 |
m_resonance = value; |
| 772 |
alEffectf(m_effect, AL_AUTOWAH_RESONANCE, m_resonance); |
| 773 |
} |
| 774 |
|
| 775 |
float Autowah::getResonance() const { |
| 776 |
return m_resonance; |
| 777 |
} |
| 778 |
|
| 779 |
void Autowah::setPeakGain(float value) { |
| 780 |
value = std::min(value, 31621.0f); |
| 781 |
value = std::max(value, 0.00003f); |
| 782 |
m_peakGain = value; |
| 783 |
alEffectf(m_effect, AL_AUTOWAH_PEAK_GAIN, m_peakGain); |
| 784 |
} |
| 785 |
|
| 786 |
float Autowah::getPeakGain() const { |
| 787 |
return m_peakGain; |
| 788 |
} |
| 789 |
|
| 790 |
|
| 791 |
Compressor::Compressor() : |
| 792 |
m_active(true) { |
| 793 |
m_effectType = SE_EFFECT_COMPRESSOR; |
| 794 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_COMPRESSOR); |
| 795 |
} |
| 796 |
|
| 797 |
void Compressor::setCompressor(bool value) { |
| 798 |
m_active = value; |
| 799 |
alEffecti(m_effect, AL_COMPRESSOR_ONOFF, m_active ? AL_TRUE : AL_FALSE); |
| 800 |
} |
| 801 |
|
| 802 |
bool Compressor::isCompressor() const { |
| 803 |
return m_active; |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
Equalizer::Equalizer() : |
| 808 |
m_lowGain(1.0f), |
| 809 |
m_lowCutoff(200.0f), |
| 810 |
m_mid1Gain(1.0f), |
| 811 |
m_mid1Center(500.0f), |
| 812 |
m_mid1Width(1.0f), |
| 813 |
m_mid2Gain(1.0f), |
| 814 |
m_mid2Center(3000.0f), |
| 815 |
m_mid2Width(1.0f), |
| 816 |
m_highGain(1.0f), |
| 817 |
m_highCutoff(6000.0f) { |
| 818 |
m_effectType = SE_EFFECT_EQUALIZER; |
| 819 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER); |
| 820 |
} |
| 821 |
|
| 822 |
void Equalizer::setLowGain(float value) { |
| 823 |
value = std::min(value, 7.943f); |
| 824 |
value = std::max(value, 0.126f); |
| 825 |
m_lowGain = value; |
| 826 |
alEffectf(m_effect, AL_EQUALIZER_LOW_GAIN, m_lowGain); |
| 827 |
} |
| 828 |
|
| 829 |
float Equalizer::getLowGain() const { |
| 830 |
return m_lowGain; |
| 831 |
} |
| 832 |
|
| 833 |
void Equalizer::setLowCutoff(float value) { |
| 834 |
value = std::min(value, 800.0f); |
| 835 |
value = std::max(value, 50.0f); |
| 836 |
m_lowCutoff = value; |
| 837 |
alEffectf(m_effect, AL_EQUALIZER_LOW_CUTOFF, m_lowCutoff); |
| 838 |
} |
| 839 |
|
| 840 |
float Equalizer::getLowCutoff() const { |
| 841 |
return m_lowCutoff; |
| 842 |
} |
| 843 |
|
| 844 |
void Equalizer::setMid1Gain(float value) { |
| 845 |
value = std::min(value, 7.943f); |
| 846 |
value = std::max(value, 0.126f); |
| 847 |
m_mid1Gain = value; |
| 848 |
alEffectf(m_effect, AL_EQUALIZER_MID1_GAIN, m_mid1Gain); |
| 849 |
} |
| 850 |
|
| 851 |
float Equalizer::getMid1Gain() const { |
| 852 |
return m_mid1Gain; |
| 853 |
} |
| 854 |
|
| 855 |
void Equalizer::setMid1Center(float value) { |
| 856 |
value = std::min(value, 3000.0f); |
| 857 |
value = std::max(value, 200.0f); |
| 858 |
m_mid1Center = value; |
| 859 |
alEffectf(m_effect, AL_EQUALIZER_MID1_CENTER, m_mid1Center); |
| 860 |
} |
| 861 |
|
| 862 |
float Equalizer::getMid1Center() const { |
| 863 |
return m_mid1Center; |
| 864 |
} |
| 865 |
|
| 866 |
void Equalizer::setMid1Width(float value) { |
| 867 |
value = std::min(value, 1.0f); |
| 868 |
value = std::max(value, 0.01f); |
| 869 |
m_mid1Width = value; |
| 870 |
alEffectf(m_effect, AL_EQUALIZER_MID1_WIDTH, m_mid1Width); |
| 871 |
} |
| 872 |
|
| 873 |
float Equalizer::getMid1Width() const { |
| 874 |
return m_mid1Width; |
| 875 |
} |
| 876 |
|
| 877 |
void Equalizer::setMid2Gain(float value) { |
| 878 |
value = std::min(value, 7.943f); |
| 879 |
value = std::max(value, 0.126f); |
| 880 |
m_mid2Gain = value; |
| 881 |
alEffectf(m_effect, AL_EQUALIZER_MID2_GAIN, m_mid2Gain); |
| 882 |
} |
| 883 |
|
| 884 |
float Equalizer::getMid2Gain() const { |
| 885 |
return m_mid2Gain; |
| 886 |
} |
| 887 |
|
| 888 |
void Equalizer::setMid2Center(float value) { |
| 889 |
value = std::min(value, 8000.0f); |
| 890 |
value = std::max(value, 1000.0f); |
| 891 |
m_mid2Center = value; |
| 892 |
alEffectf(m_effect, AL_EQUALIZER_MID2_CENTER, m_mid2Center); |
| 893 |
} |
| 894 |
|
| 895 |
float Equalizer::getMid2Center() const { |
| 896 |
return m_mid2Center; |
| 897 |
} |
| 898 |
|
| 899 |
void Equalizer::setMid2Width(float value) { |
| 900 |
value = std::min(value, 1.0f); |
| 901 |
value = std::max(value, 0.01f); |
| 902 |
m_mid2Width = value; |
| 903 |
alEffectf(m_effect, AL_EQUALIZER_MID2_WIDTH, m_mid2Width); |
| 904 |
} |
| 905 |
|
| 906 |
float Equalizer::getMid2Width() const { |
| 907 |
return m_mid2Width; |
| 908 |
} |
| 909 |
|
| 910 |
void Equalizer::setHighGain(float value) { |
| 911 |
value = std::min(value, 7.943f); |
| 912 |
value = std::max(value, 0.126f); |
| 913 |
m_highGain = value; |
| 914 |
alEffectf(m_effect, AL_EQUALIZER_HIGH_GAIN, m_highGain); |
| 915 |
} |
| 916 |
|
| 917 |
float Equalizer::getHighGain() const { |
| 918 |
return m_highGain; |
| 919 |
} |
| 920 |
|
| 921 |
void Equalizer::setHighCutoff(float value) { |
| 922 |
value = std::min(value, 16000.0f); |
| 923 |
value = std::max(value, 4000.0f); |
| 924 |
m_highCutoff = value; |
| 925 |
alEffectf(m_effect, AL_EQUALIZER_HIGH_CUTOFF, m_highCutoff); |
| 926 |
} |
| 927 |
|
| 928 |
float Equalizer::getHighCutoff() const { |
| 929 |
return m_highCutoff; |
| 930 |
} |
| 931 |
|
| 932 |
|
| 933 |
EaxReverb::EaxReverb() : |
| 934 |
m_density(1.0f), |
| 935 |
m_diffusion(1.0f), |
| 936 |
m_gain(0.32f), |
| 937 |
m_gainHf(0.89f), |
| 938 |
m_gainLf(0.0f), |
| 939 |
m_decayTime(1.49f), |
| 940 |
m_decayHfRatio(0.83f), |
| 941 |
m_decayLfRatio(1.0f), |
| 942 |
m_reflectionsGain(0.05f), |
| 943 |
m_reflectionsDelay(0.007f), |
| 944 |
m_reflectionsPan(AudioSpaceCoordinate(0.0, 0.0, 0.0)), |
| 945 |
m_lateReverbGain(1.26f), |
| 946 |
m_lateReverbDelay(0.011f), |
| 947 |
m_lateReverbPan(AudioSpaceCoordinate(0.0, 0.0, 0.0)), |
| 948 |
m_echoTime(0.25f), |
| 949 |
m_echoDepth(0.0f), |
| 950 |
m_modulationTime(0.25f), |
| 951 |
m_modulationDepth(0.0f), |
| 952 |
m_airAbsorptionGainHf(0.994f), |
| 953 |
m_hfReference(5000.0f), |
| 954 |
m_lfReference(250.0f), |
| 955 |
m_roomRolloffFactor(0.0f), |
| 956 |
m_decayHfLimit(true) { |
| 957 |
|
| 958 |
m_effectType = SE_EFFECT_EAXREVERB; |
| 959 |
alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); |
| 960 |
} |
| 961 |
|
| 962 |
void EaxReverb::setDensity(float value) { |
| 963 |
value = std::min(value, 1.0f); |
| 964 |
value = std::max(value, 0.0f); |
| 965 |
m_density = value; |
| 966 |
alEffectf(m_effect, AL_EAXREVERB_DENSITY, m_density); |
| 967 |
} |
| 968 |
|
| 969 |
float EaxReverb::getDensity() const { |
| 970 |
return m_density; |
| 971 |
} |
| 972 |
|
| 973 |
void EaxReverb::setDiffusion(float value) { |
| 974 |
value = std::min(value, 1.0f); |
| 975 |
value = std::max(value, 0.0f); |
| 976 |
m_diffusion = value; |
| 977 |
alEffectf(m_effect, AL_EAXREVERB_DIFFUSION, m_diffusion); |
| 978 |
} |
| 979 |
|
| 980 |
float EaxReverb::getDiffusion() const { |
| 981 |
return m_diffusion; |
| 982 |
} |
| 983 |
|
| 984 |
void EaxReverb::setGain(float value) { |
| 985 |
value = std::min(value, 1.0f); |
| 986 |
value = std::max(value, 0.0f); |
| 987 |
m_gain = value; |
| 988 |
alEffectf(m_effect, AL_EAXREVERB_GAIN, m_gain); |
| 989 |
} |
| 990 |
|
| 991 |
float EaxReverb::getGain() const { |
| 992 |
return m_gain; |
| 993 |
} |
| 994 |
|
| 995 |
void EaxReverb::setGainHf(float value) { |
| 996 |
value = std::min(value, 1.0f); |
| 997 |
value = std::max(value, 0.0f); |
| 998 |
m_gainHf = value; |
| 999 |
alEffectf(m_effect, AL_EAXREVERB_GAINHF, m_gainHf); |
| 1000 |
} |
| 1001 |
|
| 1002 |
float EaxReverb::getGainHf() const { |
| 1003 |
return m_gainHf; |
| 1004 |
} |
| 1005 |
|
| 1006 |
void EaxReverb::setGainLf(float value) { |
| 1007 |
value = std::min(value, 1.0f); |
| 1008 |
value = std::max(value, 0.0f); |
| 1009 |
m_gainLf = value; |
| 1010 |
alEffectf(m_effect, AL_EAXREVERB_GAINLF, m_gainLf); |
| 1011 |
} |
| 1012 |
|
| 1013 |
float EaxReverb::getGainLf() const { |
| 1014 |
return m_gainLf; |
| 1015 |
} |
| 1016 |
|
| 1017 |
void EaxReverb::setDecayTime(float value) { |
| 1018 |
value = std::min(value, 20.0f); |
| 1019 |
value = std::max(value, 0.1f); |
| 1020 |
m_decayTime = value; |
| 1021 |
alEffectf(m_effect, AL_EAXREVERB_DECAY_TIME, m_decayTime); |
| 1022 |
} |
| 1023 |
|
| 1024 |
float EaxReverb::getDecayTime() const { |
| 1025 |
return m_decayTime; |
| 1026 |
} |
| 1027 |
|
| 1028 |
void EaxReverb::setDecayHfRatio(float value) { |
| 1029 |
value = std::min(value, 2.0f); |
| 1030 |
value = std::max(value, 0.1f); |
| 1031 |
m_decayHfRatio = value; |
| 1032 |
alEffectf(m_effect, AL_EAXREVERB_DECAY_HFRATIO, m_decayHfRatio); |
| 1033 |
} |
| 1034 |
|
| 1035 |
float EaxReverb::getDecayHfRatio() const { |
| 1036 |
return m_decayHfRatio; |
| 1037 |
} |
| 1038 |
|
| 1039 |
void EaxReverb::setDecayLfRatio(float value) { |
| 1040 |
value = std::min(value, 2.0f); |
| 1041 |
value = std::max(value, 0.1f); |
| 1042 |
m_decayLfRatio = value; |
| 1043 |
alEffectf(m_effect, AL_EAXREVERB_DECAY_LFRATIO, m_decayLfRatio); |
| 1044 |
} |
| 1045 |
|
| 1046 |
float EaxReverb::getDecayLfRatio() const { |
| 1047 |
return m_decayLfRatio; |
| 1048 |
} |
| 1049 |
|
| 1050 |
void EaxReverb::setReflectionsGain(float value) { |
| 1051 |
value = std::min(value, 3.16f); |
| 1052 |
value = std::max(value, 0.0f); |
| 1053 |
m_reflectionsGain = value; |
| 1054 |
alEffectf(m_effect, AL_EAXREVERB_REFLECTIONS_GAIN, m_reflectionsGain); |
| 1055 |
} |
| 1056 |
|
| 1057 |
float EaxReverb::getReflectionsGain() const { |
| 1058 |
return m_reflectionsGain; |
| 1059 |
} |
| 1060 |
|
| 1061 |
void EaxReverb::setReflectionsDelay(float value) { |
| 1062 |
value = std::min(value, 0.3f); |
| 1063 |
value = std::max(value, 0.0f); |
| 1064 |
m_reflectionsDelay = value; |
| 1065 |
alEffectf(m_effect, AL_EAXREVERB_REFLECTIONS_DELAY, m_reflectionsDelay); |
| 1066 |
} |
| 1067 |
|
| 1068 |
float EaxReverb::getReflectionsDelay() const { |
| 1069 |
return m_reflectionsDelay; |
| 1070 |
} |
| 1071 |
|
| 1072 |
void EaxReverb::setReflectionsPan(const AudioSpaceCoordinate& coordinate) { |
| 1073 |
m_reflectionsPan.x = std::min(coordinate.x, double(1.0)); |
| 1074 |
m_reflectionsPan.x = std::max(coordinate.x, double(-1.0)); |
| 1075 |
m_reflectionsPan.y = std::min(coordinate.y, double(1.0)); |
| 1076 |
m_reflectionsPan.y = std::max(coordinate.y, double(-1.0)); |
| 1077 |
m_reflectionsPan.z = std::min(coordinate.z, double(1.0)); |
| 1078 |
m_reflectionsPan.z = std::max(coordinate.z, double(-1.0)); |
| 1079 |
|
| 1080 |
ALfloat vec[3] = { static_cast<ALfloat>(m_reflectionsPan.x), |
| 1081 |
static_cast<ALfloat>(m_reflectionsPan.y), static_cast<ALfloat>(m_reflectionsPan.z)}; |
| 1082 |
alEffectfv(m_effect, AL_EAXREVERB_REFLECTIONS_PAN, vec); |
| 1083 |
} |
| 1084 |
|
| 1085 |
AudioSpaceCoordinate EaxReverb::getReflectionsPan() const { |
| 1086 |
return m_reflectionsPan; |
| 1087 |
} |
| 1088 |
|
| 1089 |
void EaxReverb::setLateReverbGain(float value) { |
| 1090 |
value = std::min(value, 10.0f); |
| 1091 |
value = std::max(value, 0.0f); |
| 1092 |
m_lateReverbGain = value; |
| 1093 |
alEffectf(m_effect, AL_EAXREVERB_LATE_REVERB_GAIN, m_lateReverbGain); |
| 1094 |
} |
| 1095 |
|
| 1096 |
float EaxReverb::getLateReverbGain() const { |
| 1097 |
return m_lateReverbGain; |
| 1098 |
} |
| 1099 |
|
| 1100 |
void EaxReverb::setLateReverbDelay(float value) { |
| 1101 |
value = std::min(value, 0.1f); |
| 1102 |
value = std::max(value, 0.0f); |
| 1103 |
m_reflectionsDelay = value; |
| 1104 |
alEffectf(m_effect, AL_EAXREVERB_LATE_REVERB_DELAY, m_reflectionsDelay); |
| 1105 |
} |
| 1106 |
|
| 1107 |
float EaxReverb::getLateReverbDelay() const { |
| 1108 |
return m_reflectionsDelay; |
| 1109 |
} |
| 1110 |
|
| 1111 |
void EaxReverb::setLateReverbPan(const AudioSpaceCoordinate& coordinate) { |
| 1112 |
m_lateReverbPan.x = std::min(coordinate.x, double(1.0)); |
| 1113 |
m_lateReverbPan.x = std::max(coordinate.x, double(-1.0)); |
| 1114 |
m_lateReverbPan.y = std::min(coordinate.y, double(1.0)); |
| 1115 |
m_lateReverbPan.y = std::max(coordinate.y, double(-1.0)); |
| 1116 |
m_lateReverbPan.z = std::min(coordinate.z, double(1.0)); |
| 1117 |
m_lateReverbPan.z = std::max(coordinate.z, double(-1.0)); |
| 1118 |
|
| 1119 |
ALfloat vec[3] = { static_cast<ALfloat>(m_lateReverbPan.x), |
| 1120 |
static_cast<ALfloat>(m_lateReverbPan.y), static_cast<ALfloat>(m_lateReverbPan.z) }; |
| 1121 |
alEffectfv(m_effect, AL_EAXREVERB_LATE_REVERB_PAN, vec); |
| 1122 |
} |
| 1123 |
|
| 1124 |
AudioSpaceCoordinate EaxReverb::getLateReverbPan() const { |
| 1125 |
return m_lateReverbPan; |
| 1126 |
} |
| 1127 |
|
| 1128 |
void EaxReverb::setEchoTime(float value) { |
| 1129 |
value = std::min(value, 0.25f); |
| 1130 |
value = std::max(value, 0.075f); |
| 1131 |
m_echoTime = value; |
| 1132 |
alEffectf(m_effect, AL_EAXREVERB_ECHO_TIME, m_echoTime); |
| 1133 |
} |
| 1134 |
|
| 1135 |
float EaxReverb::getEchoTime() const { |
| 1136 |
return m_echoTime; |
| 1137 |
} |
| 1138 |
|
| 1139 |
void EaxReverb::setEchoDepth(float value) { |
| 1140 |
value = std::min(value, 1.0f); |
| 1141 |
value = std::max(value, 0.0f); |
| 1142 |
m_echoDepth = value; |
| 1143 |
alEffectf(m_effect, AL_EAXREVERB_ECHO_DEPTH, m_echoDepth); |
| 1144 |
} |
| 1145 |
|
| 1146 |
float EaxReverb::getEchoDepth() const { |
| 1147 |
return m_echoDepth; |
| 1148 |
} |
| 1149 |
|
| 1150 |
void EaxReverb::setModulationTime(float value) { |
| 1151 |
value = std::min(value, 4.0f); |
| 1152 |
value = std::max(value, 0.04f); |
| 1153 |
m_modulationTime = value; |
| 1154 |
alEffectf(m_effect, AL_EAXREVERB_MODULATION_TIME, m_modulationTime); |
| 1155 |
} |
| 1156 |
|
| 1157 |
float EaxReverb::getModulationTime() const { |
| 1158 |
return m_modulationTime; |
| 1159 |
} |
| 1160 |
|
| 1161 |
void EaxReverb::setModulationDepth(float value) { |
| 1162 |
value = std::min(value, 1.0f); |
| 1163 |
value = std::max(value, 0.0f); |
| 1164 |
m_modulationDepth = value; |
| 1165 |
alEffectf(m_effect, AL_EAXREVERB_MODULATION_DEPTH, m_modulationDepth); |
| 1166 |
} |
| 1167 |
|
| 1168 |
float EaxReverb::getModulationDepth() const { |
| 1169 |
return m_modulationDepth; |
| 1170 |
} |
| 1171 |
|
| 1172 |
void EaxReverb::setAirAbsorptionGainHf(float value) { |
| 1173 |
value = std::min(value, 1.0f); |
| 1174 |
value = std::max(value, 0.892f); |
| 1175 |
m_airAbsorptionGainHf = value; |
| 1176 |
alEffectf(m_effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, m_airAbsorptionGainHf); |
| 1177 |
} |
| 1178 |
|
| 1179 |
float EaxReverb::getAirAbsorptionGainHf() const { |
| 1180 |
return m_airAbsorptionGainHf; |
| 1181 |
} |
| 1182 |
|
| 1183 |
void EaxReverb::setHfReference(float value) { |
| 1184 |
value = std::min(value, 20000.0f); |
| 1185 |
value = std::max(value, 1000.0f); |
| 1186 |
m_hfReference = value; |
| 1187 |
alEffectf(m_effect, AL_EAXREVERB_HFREFERENCE, m_hfReference); |
| 1188 |
} |
| 1189 |
|
| 1190 |
float EaxReverb::getHfReference() const { |
| 1191 |
return m_hfReference; |
| 1192 |
} |
| 1193 |
|
| 1194 |
void EaxReverb::setLfReference(float value) { |
| 1195 |
value = std::min(value, 1000.0f); |
| 1196 |
value = std::max(value, 20.0f); |
| 1197 |
m_lfReference = value; |
| 1198 |
alEffectf(m_effect, AL_EAXREVERB_LFREFERENCE, m_lfReference); |
| 1199 |
} |
| 1200 |
|
| 1201 |
float EaxReverb::getLfReference() const { |
| 1202 |
return m_lfReference; |
| 1203 |
} |
| 1204 |
|
| 1205 |
void EaxReverb::setRoomRolloffFactor(float value) { |
| 1206 |
value = std::min(value, 10.0f); |
| 1207 |
value = std::max(value, 0.0f); |
| 1208 |
m_roomRolloffFactor = value; |
| 1209 |
alEffectf(m_effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, m_roomRolloffFactor); |
| 1210 |
} |
| 1211 |
|
| 1212 |
float EaxReverb::getRoomRolloffFactor() const { |
| 1213 |
return m_roomRolloffFactor; |
| 1214 |
} |
| 1215 |
|
| 1216 |
void EaxReverb::setDecayHfLimit(bool value) { |
| 1217 |
m_decayHfLimit = value; |
| 1218 |
alEffecti(m_effect, AL_EAXREVERB_DECAY_HFLIMIT, m_decayHfLimit ? AL_TRUE : AL_FALSE); |
| 1219 |
} |
| 1220 |
|
| 1221 |
bool EaxReverb::isDecayHfLimit() const { |
| 1222 |
return m_decayHfLimit; |
| 1223 |
} |
| 1224 |
|
| 1225 |
void EaxReverb::loadPreset(const EFXEAXREVERBPROPERTIES& prop) { |
| 1226 |
// reflections and reverb pans are always 0 vectors, skip it |
| 1227 |
setDensity(prop.flDensity); |
| 1228 |
setDiffusion(prop.flDiffusion); |
| 1229 |
setGain(prop.flGain); |
| 1230 |
setGainHf(prop.flGainHF); |
| 1231 |
setGainLf(prop.flGainLF); |
| 1232 |
setDecayTime(prop.flDecayTime); |
| 1233 |
setDecayHfRatio(prop.flDecayHFRatio); |
| 1234 |
setDecayLfRatio(prop.flDecayLFRatio); |
| 1235 |
setReflectionsGain(prop.flReflectionsGain); |
| 1236 |
setReflectionsDelay(prop.flReflectionsDelay); |
| 1237 |
setLateReverbGain(prop.flLateReverbGain); |
| 1238 |
setLateReverbDelay(prop.flLateReverbDelay); |
| 1239 |
setEchoTime(prop.flEchoTime); |
| 1240 |
setEchoDepth(prop.flEchoDepth); |
| 1241 |
setModulationTime(prop.flModulationTime); |
| 1242 |
setModulationDepth(prop.flModulationDepth); |
| 1243 |
setAirAbsorptionGainHf(prop.flAirAbsorptionGainHF); |
| 1244 |
setHfReference(prop.flHFReference); |
| 1245 |
setLfReference(prop.flLFReference); |
| 1246 |
setRoomRolloffFactor(prop.flRoomRolloffFactor); |
| 1247 |
setDecayHfLimit(prop.iDecayHFLimit ? true : false); |
| 1248 |
} |
| 1249 |
|
| 1250 |
} //FIFE |