FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
soundeffect.h
Go to the documentation of this file.
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 #ifndef FIFE_SOUNDEFFECT_H
23 #define FIFE_SOUNDEFFECT_H
24 
25 // Standard C++ library includes
26 
27 // Platform specific includes
28 
29 // 3rd party library includes
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
36 
37 #include "audio/fife_openal.h"
38 #include "audio/soundconfig.h"
39 
40 namespace FIFE {
41 
42  class SoundFilter;
43 
46  class SoundEffect {
47  public:
50  SoundEffect();
51 
54  virtual ~SoundEffect();
55 
58  ALuint getEffectId() const;
59 
62  void setSlotId(ALuint slot);
63 
66  ALuint getSlotId();
67 
72 
76  void setEnabled(bool enabled);
77 
80  bool isEnabled() const;
81 
85  void setFilter(SoundFilter* filter);
86 
90 
91  protected:
93  ALuint m_effect;
95  ALuint m_slot;
99  bool m_enabled;
102  };
103 
106  class Reverb : public SoundEffect {
107  public:
110  Reverb();
111 
116  void setDensity(float value);
117 
120  float getDensity() const;
121 
125  void setDiffusion(float value);
126 
129  float getDiffusion() const;
130 
134  void setGain(float value);
135 
138  float getGain() const;
139 
143  void setGainHf(float value);
144 
147  float getGainHf() const;
148 
152  void setDecayTime(float value);
153 
156  float getDecayTime() const;
157 
162  void setDecayHfRatio(float value);
163 
166  float getDecayHfRatio() const;
167 
172  void setReflectionsGain(float value);
173 
176  float getReflectionsGain() const;
177 
182  void setReflectionsDelay(float value);
183 
186  float getReflectionsDelay() const;
187 
191  void setLateReverbGain(float value);
192 
195  float getLateReverbGain() const;
196 
201  void setLateReverbDelay(float value);
202 
205  float getLateReverbDelay() const;
206 
211  void setAirAbsorptionGainHf(float value);
212 
215  float getAirAbsorptionGainHf() const;
216 
221  void setRoomRolloffFactor(float value);
222 
225  float getRoomRolloffFactor() const;
226 
231  void setDecayHfLimit(bool value);
232 
235  bool isDecayHfLimit() const;
236 
237  private:
238  float m_density;
239  float m_diffusion;
240  float m_gain;
241  float m_gainHf;
242  float m_decayTime;
251  };
252 
256  class Chorus : public SoundEffect {
257  public:
260  Chorus();
261 
265  void setWaveformTriangle(bool value);
266 
269  bool isWaveformTriangle() const;
270 
274  void setPhase(int32_t value);
275 
278  int32_t getPhase() const;
279 
284  void setRate(float value);
285 
288  float getRate() const;
289 
293  void setDepth(float value);
294 
297  float getDepth() const;
298 
303  void setFeedback(float value);
304 
307  float getFeedback() const;
308 
313  void setDelay(float value);
314 
317  float getDelay() const;
318 
319  private:
321  int32_t m_phase;
322  float m_rate;
323  float m_depth;
324  float m_feedback;
325  float m_delay;
326  };
327 
331  class Distortion : public SoundEffect {
332  public:
335  Distortion();
336 
340  void setEdge(float value);
341 
344  float getEdge() const;
345 
349  void setGain(float value);
350 
353  float getGain() const;
354 
359  void setLowpassCutoff(float value);
360 
363  float getLowpassCutoff() const;
364 
369  void setEqCenter(float value);
370 
373  float getEqCenter() const;
374 
378  void setEqBandwidth(float value);
379 
382  float getEqBandwidth() const;
383 
384  private:
385  float m_edge;
386  float m_gain;
388  float m_eqCenter;
390  };
391 
395  class Echo : public SoundEffect {
396  public:
399  Echo();
400 
404  void setDelay(float value);
405 
408  float getDelay() const;
409 
413  void setLrDelay(float value);
414 
417  float getLrDelay() const;
418 
422  void setDamping(float value);
423 
426  float getDamping() const;
427 
431  void setFeedback(float value);
432 
435  float getFeedback() const;
436 
440  void setSpread(float value);
441 
444  float getSpread() const;
445 
446  private:
447  float m_delay;
448  float m_lrDelay;
449  float m_damping;
450  float m_feedback;
451  float m_spread;
452  };
453 
456  class Flanger : public SoundEffect {
457  public:
460  Flanger();
461 
466  void setWaveformTriangle(bool value);
467 
470  bool isWaveformTriangle() const;
471 
476  void setPhase(int32_t value);
477 
480  int32_t getPhase() const;
481 
486  void setRate(float value);
487 
490  float getRate() const;
491 
495  void setDepth(float value);
496 
499  float getDepth() const;
500 
505  void setFeedback(float value);
506 
509  float getFeedback() const;
510 
515  void setDelay(float value);
516 
519  float getDelay() const;
520 
521  private:
523  int32_t m_phase;
524  float m_rate;
525  float m_depth;
526  float m_feedback;
527  float m_delay;
528  };
529 
533  class FrequencyShifter : public SoundEffect {
534  public:
538 
543  void setFrequency(float value);
544 
547  float getFrequency() const;
548 
553  void setLeftDirection(uint8_t value);
554 
557  uint8_t getLeftDirection() const;
558 
563  void setRightDirection(uint8_t value);
564 
567  uint8_t getRightDirection() const;
568 
569  private:
570  float m_frequency;
573  };
574 
582  class VocalMorpher : public SoundEffect {
583  public:
586  VocalMorpher();
587 
591  void setPhonemeA(uint16_t value);
592 
595  uint16_t getPhonemeA() const;
596 
600  void setPhonemeB(uint16_t value);
601 
604  uint16_t getPhonemeB() const;
605 
610  void setPhonemeCoarseA(int16_t value);
611 
614  int16_t getPhonemeCoarseA() const;
615 
620  void setPhonemeCoarseB(int16_t value);
621 
624  int16_t getPhonemeCoarseB() const;
625 
630  void setWaveform(uint8_t value);
631 
634  uint8_t getWaveform() const;
635 
640  void setRate(float value);
641 
644  float getRate() const;
645 
646  private:
652  float m_rate;
653  };
654 
658  class PitchShifter : public SoundEffect {
659  public:
662  PitchShifter();
663 
668  void setCoarseTune(int16_t value);
669 
672  int16_t getCoarseTune() const;
673 
678  void setFineTune(int16_t value);
679 
682  int16_t getFineTune() const;
683 
684  private:
685  int16_t m_coarseTune;
686  int16_t m_fineTune;
687  };
688 
692  class RingModulator : public SoundEffect {
693  public:
696  RingModulator();
697 
701  void setFrequency(float value);
702 
705  float getFrequency() const;
706 
711  void setHighpassCutoff(float value);
712 
715  float getHighpassCutoff() const;
716 
720  void setWaveform(uint8_t value);
721  uint8_t getWaveform() const;
722 
723  private:
724  float m_frequency;
727  };
728 
732  class Autowah : public SoundEffect {
733  public:
736  Autowah();
737 
742  void setAttackTime(float value);
743 
746  float getAttackTime() const;
747 
752  void setReleaseTime(float value);
753 
756  float getReleaseTime() const;
757 
762  void setResonance(float value);
763 
766  float getResonance() const;
767 
772  void setPeakGain(float value);
773 
776  float getPeakGain() const;
777 
778  private:
781  float m_resonance;
782  float m_peakGain;
783  };
784 
788  class Compressor : public SoundEffect {
789  public:
792  Compressor();
793 
797  void setCompressor(bool value);
798 
801  bool isCompressor() const;
802 
803  private:
804  bool m_active;
805  };
806 
810  class Equalizer : public SoundEffect {
811  public:
814  Equalizer();
815 
819  void setLowGain(float value);
820 
823  float getLowGain() const;
824 
828  void setLowCutoff(float value);
829 
832  float getLowCutoff() const;
833 
837  void setMid1Gain(float value);
838 
841  float getMid1Gain() const;
842 
846  void setMid1Center(float value);
847 
850  float getMid1Center() const;
851 
855  void setMid1Width(float value);
856 
859  float getMid1Width() const;
860 
864  void setMid2Gain(float value);
865 
868  float getMid2Gain() const;
869 
873  void setMid2Center(float value);
874 
877  float getMid2Center() const;
878 
882  void setMid2Width(float value);
883 
886  float getMid2Width() const;
887 
891  void setHighGain(float value);
892 
895  float getHighGain() const;
896 
900  void setHighCutoff(float value);
901 
904  float getHighCutoff() const;
905 
906  private:
907  float m_lowGain;
908  float m_lowCutoff;
909  float m_mid1Gain;
911  float m_mid1Width;
912  float m_mid2Gain;
914  float m_mid2Width;
915  float m_highGain;
917  };
918 
922  class EaxReverb : public SoundEffect {
923  public:
926  EaxReverb();
927 
932  void setDensity(float value);
933 
936  float getDensity() const;
937 
941  void setDiffusion(float value);
942 
945  float getDiffusion() const;
946 
950  void setGain(float value);
951 
954  float getGain() const;
955 
959  void setGainHf(float value);
960 
963  float getGainHf() const;
964 
968  void setGainLf(float value);
969 
972  float getGainLf() const;
973 
977  void setDecayTime(float value);
978 
981  float getDecayTime() const;
982 
987  void setDecayHfRatio(float value);
988 
991  float getDecayHfRatio() const;
992 
997  void setDecayLfRatio(float value);
998 
1001  float getDecayLfRatio() const;
1002 
1007  void setReflectionsGain(float value);
1008 
1011  float getReflectionsGain() const;
1012 
1017  void setReflectionsDelay(float value);
1018 
1021  float getReflectionsDelay() const;
1022 
1029  void setReflectionsPan(const AudioSpaceCoordinate& coordinate);
1030 
1033  AudioSpaceCoordinate getReflectionsPan() const;
1034 
1038  void setLateReverbGain(float value);
1039 
1042  float getLateReverbGain() const;
1043 
1048  void setLateReverbDelay(float value);
1049 
1052  float getLateReverbDelay() const;
1053 
1059  void setLateReverbPan(const AudioSpaceCoordinate& coordinate);
1060 
1063  AudioSpaceCoordinate getLateReverbPan() const;
1064 
1069  void setEchoTime(float value);
1070 
1073  float getEchoTime() const;
1074 
1079  void setEchoDepth(float value);
1080 
1083  float getEchoDepth() const;
1084 
1088  void setModulationTime(float value);
1089 
1092  float getModulationTime() const;
1093 
1097  void setModulationDepth(float value);
1098 
1101  float getModulationDepth() const;
1102 
1107  void setAirAbsorptionGainHf(float value);
1108 
1111  float getAirAbsorptionGainHf() const;
1112 
1118  void setHfReference(float value);
1119 
1122  float getHfReference() const;
1123 
1130  void setLfReference(float value);
1131 
1134  float getLfReference() const;
1135 
1140  void setRoomRolloffFactor(float value);
1141 
1144  float getRoomRolloffFactor() const;
1145 
1150  void setDecayHfLimit(bool value);
1151 
1154  bool isDecayHfLimit() const;
1155 
1159  void loadPreset(const EFXEAXREVERBPROPERTIES& prop);
1160  private:
1161  float m_density;
1163  float m_gain;
1164  float m_gainHf;
1165  float m_gainLf;
1175  float m_echoTime;
1184  };
1185 }
1186 #endif
The distortion effect simulates turning up (overdriving) the gain stage on a guitar amplifier or addi...
Definition: soundeffect.h:331
void setEnabled(bool enabled)
Enables or disables the effect.
Definition: soundeffect.cpp:75
float m_releaseTime
Definition: soundeffect.h:780
int32_t m_phase
Definition: soundeffect.h:523
float m_lateReverbDelay
Definition: soundeffect.h:1173
float m_decayHfRatio
Definition: soundeffect.h:243
The Automatic Gain Control effect performs the same task as a studio compressor – evening out the aud...
Definition: soundeffect.h:788
ALuint m_slot
Effect slot id;.
Definition: soundeffect.h:95
bool m_waveformTriangle
Definition: soundeffect.h:522
float m_airAbsorptionGainHf
Definition: soundeffect.h:248
SoundEffectType m_effectType
Sound effect type.
Definition: soundeffect.h:97
SoundFilter * getFilter()
Return sound filter or NULL.
Definition: soundeffect.cpp:87
AudioSpaceCoordinate m_reflectionsPan
Definition: soundeffect.h:1171
The vocal morpher consists of a pair of 4-band formant filters, used to impose vocal tract effects up...
Definition: soundeffect.h:582
Base class for Efx sound effects.
Definition: soundeffect.h:46
The class defines filters.
Definition: soundfilter.h:43
float m_reflectionsGain
Definition: soundeffect.h:1169
float m_roomRolloffFactor
Definition: soundeffect.h:1182
The chorus effect essentially replays the input audio accompanied by another slightly delayed version...
Definition: soundeffect.h:256
float m_reflectionsDelay
Definition: soundeffect.h:245
float m_peakGain
Definition: soundeffect.h:782
float m_modulationDepth
Definition: soundeffect.h:1178
ALuint getEffectId() const
Return the OpenAL effect handle.
Definition: soundeffect.cpp:59
float m_reflectionsDelay
Definition: soundeffect.h:1170
float m_lateReverbGain
Definition: soundeffect.h:246
float m_airAbsorptionGainHf
Definition: soundeffect.h:1179
ALuint getSlotId()
Return the OpenAL auxiliary slot handle.
Definition: soundeffect.cpp:67
SoundEffectType getEffectType() const
Return sound effect type.
Definition: soundeffect.cpp:71
bool m_waveformTriangle
Definition: soundeffect.h:320
unsigned char uint8_t
Definition: core.h:38
bool m_enabled
Effect enabled.
Definition: soundeffect.h:99
float m_lrDelay
Definition: soundeffect.h:448
The Equalizer providing tonal control over four different adjustable frequency ranges.
Definition: soundeffect.h:810
float m_gainHf
Definition: soundeffect.h:241
The frequency shifter is a single-sideband modulator, which translates all the component frequencies ...
Definition: soundeffect.h:533
The Auto-wah effect emulates the sound of a wah-wah pedal used with an electric guitar, or a mute on a brass instrument.
Definition: soundeffect.h:732
void setFilter(SoundFilter *filter)
Sets the additional sound filter.
Definition: soundeffect.cpp:83
float m_density
Definition: soundeffect.h:238
float m_lateReverbGain
Definition: soundeffect.h:1172
SoundFilter * m_filter
Additional filter effect.
Definition: soundeffect.h:101
SoundEffect()
Constructor.
Definition: soundeffect.cpp:45
int16_t m_phonemeCoarseA
Definition: soundeffect.h:649
float m_feedback
Definition: soundeffect.h:526
unsigned short uint16_t
Definition: core.h:39
float m_decayTime
Definition: soundeffect.h:242
float m_modulationTime
Definition: soundeffect.h:1177
ALuint m_effect
Effect object id.
Definition: soundeffect.h:93
float m_reflectionsGain
Definition: soundeffect.h:244
float m_roomRolloffFactor
Definition: soundeffect.h:249
The flanger effect creates a “tearing” or “whooshing” sound.
Definition: soundeffect.h:456
SoundEffectType
Sound effect type.
Definition: soundconfig.h:48
float m_feedback
Definition: soundeffect.h:450
The environmental reverberation effect.
Definition: soundeffect.h:106
AudioSpaceCoordinate m_lateReverbPan
Definition: soundeffect.h:1174
The ring modulator multiplies an input signal by a carrier signal in the time domain, resulting in tremolo or inharmonic effects.
Definition: soundeffect.h:692
The EAX Reverb is similar to Reverb but supports more options.
Definition: soundeffect.h:922
The echo effect generates discrete, delayed instances of the input signal.
Definition: soundeffect.h:395
float m_attackTime
Definition: soundeffect.h:779
float m_spread
Definition: soundeffect.h:451
float m_diffusion
Definition: soundeffect.h:239
float m_resonance
Definition: soundeffect.h:781
bool isEnabled() const
Return true if the effect is enabled, false otherwise.
Definition: soundeffect.cpp:79
void setSlotId(ALuint slot)
Sets the OpenAL auxiliary slot handle.
Definition: soundeffect.cpp:63
The pitch shifter applies time-invariant pitch shifting to the input signal, over a one octave range ...
Definition: soundeffect.h:658
float m_damping
Definition: soundeffect.h:449
float m_lateReverbDelay
Definition: soundeffect.h:247
float m_delay
Definition: soundeffect.h:447
bool m_decayHfLimit
Definition: soundeffect.h:250
int32_t m_phase
Definition: soundeffect.h:321
float m_feedback
Definition: soundeffect.h:324
int16_t m_phonemeCoarseB
Definition: soundeffect.h:650
virtual ~SoundEffect()
Destructor.
Definition: soundeffect.cpp:55