1 /** 2 Adds a Compressor audio effect to an Audio bus. 3 Reduces sounds that exceed a certain threshold level, smooths out the dynamics and increases the overall volume. 4 5 Copyright: 6 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 7 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 8 Copyright (c) 2017-2018 Godot-D contributors 9 10 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 11 12 13 */ 14 module godot.audioeffectcompressor; 15 import std.meta : AliasSeq, staticIndexOf; 16 import std.traits : Unqual; 17 import godot.d.meta; 18 import godot.core; 19 import godot.c; 20 import godot.d.bind; 21 import godot.d.reference; 22 import godot.object; 23 import godot.classdb; 24 import godot.audioeffect; 25 import godot.resource; 26 import godot.reference; 27 /** 28 Adds a Compressor audio effect to an Audio bus. 29 Reduces sounds that exceed a certain threshold level, smooths out the dynamics and increases the overall volume. 30 31 Dynamic range compressor reduces the level of the sound when the amplitude goes over a certain threshold in Decibels. One of the main uses of a compressor is to increase the dynamic range by clipping as little as possible (when sound goes over 0dB). 32 Compressor has many uses in the mix: 33 - In the Master bus to compress the whole output (Although a $(D AudioEffectLimiter) is probably better) 34 - In voice channels to ensure they sound as balanced as possible. 35 - Sidechained. Sidechained, which can reduce the sound level sidechained with another audio bus for threshold detection.. This technique is very common in video game mixing to download the level of Music/SFX while voices are being heard. 36 - Accentuates transients by using a wider attack, making effects sound more punchy. 37 */ 38 @GodotBaseClass struct AudioEffectCompressor 39 { 40 enum string _GODOT_internal_name = "AudioEffectCompressor"; 41 public: 42 @nogc nothrow: 43 union { godot_object _godot_object; AudioEffect _GODOT_base; } 44 alias _GODOT_base this; 45 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 46 package(godot) __gshared bool _classBindingInitialized = false; 47 package(godot) static struct _classBinding 48 { 49 __gshared: 50 @GodotName("set_threshold") GodotMethod!(void, double) setThreshold; 51 @GodotName("get_threshold") GodotMethod!(double) getThreshold; 52 @GodotName("set_ratio") GodotMethod!(void, double) setRatio; 53 @GodotName("get_ratio") GodotMethod!(double) getRatio; 54 @GodotName("set_gain") GodotMethod!(void, double) setGain; 55 @GodotName("get_gain") GodotMethod!(double) getGain; 56 @GodotName("set_attack_us") GodotMethod!(void, double) setAttackUs; 57 @GodotName("get_attack_us") GodotMethod!(double) getAttackUs; 58 @GodotName("set_release_ms") GodotMethod!(void, double) setReleaseMs; 59 @GodotName("get_release_ms") GodotMethod!(double) getReleaseMs; 60 @GodotName("set_mix") GodotMethod!(void, double) setMix; 61 @GodotName("get_mix") GodotMethod!(double) getMix; 62 @GodotName("set_sidechain") GodotMethod!(void, String) setSidechain; 63 @GodotName("get_sidechain") GodotMethod!(String) getSidechain; 64 } 65 bool opEquals(in AudioEffectCompressor other) const { return _godot_object.ptr is other._godot_object.ptr; } 66 AudioEffectCompressor opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 67 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 68 mixin baseCasts; 69 static AudioEffectCompressor _new() 70 { 71 static godot_class_constructor constructor; 72 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioEffectCompressor"); 73 if(constructor is null) return typeof(this).init; 74 return cast(AudioEffectCompressor)(constructor()); 75 } 76 @disable new(size_t s); 77 /** 78 79 */ 80 void setThreshold(in double threshold) 81 { 82 checkClassBinding!(typeof(this))(); 83 ptrcall!(void)(_classBinding.setThreshold, _godot_object, threshold); 84 } 85 /** 86 87 */ 88 double getThreshold() const 89 { 90 checkClassBinding!(typeof(this))(); 91 return ptrcall!(double)(_classBinding.getThreshold, _godot_object); 92 } 93 /** 94 95 */ 96 void setRatio(in double ratio) 97 { 98 checkClassBinding!(typeof(this))(); 99 ptrcall!(void)(_classBinding.setRatio, _godot_object, ratio); 100 } 101 /** 102 103 */ 104 double getRatio() const 105 { 106 checkClassBinding!(typeof(this))(); 107 return ptrcall!(double)(_classBinding.getRatio, _godot_object); 108 } 109 /** 110 111 */ 112 void setGain(in double gain) 113 { 114 checkClassBinding!(typeof(this))(); 115 ptrcall!(void)(_classBinding.setGain, _godot_object, gain); 116 } 117 /** 118 119 */ 120 double getGain() const 121 { 122 checkClassBinding!(typeof(this))(); 123 return ptrcall!(double)(_classBinding.getGain, _godot_object); 124 } 125 /** 126 127 */ 128 void setAttackUs(in double attack_us) 129 { 130 checkClassBinding!(typeof(this))(); 131 ptrcall!(void)(_classBinding.setAttackUs, _godot_object, attack_us); 132 } 133 /** 134 135 */ 136 double getAttackUs() const 137 { 138 checkClassBinding!(typeof(this))(); 139 return ptrcall!(double)(_classBinding.getAttackUs, _godot_object); 140 } 141 /** 142 143 */ 144 void setReleaseMs(in double release_ms) 145 { 146 checkClassBinding!(typeof(this))(); 147 ptrcall!(void)(_classBinding.setReleaseMs, _godot_object, release_ms); 148 } 149 /** 150 151 */ 152 double getReleaseMs() const 153 { 154 checkClassBinding!(typeof(this))(); 155 return ptrcall!(double)(_classBinding.getReleaseMs, _godot_object); 156 } 157 /** 158 159 */ 160 void setMix(in double mix) 161 { 162 checkClassBinding!(typeof(this))(); 163 ptrcall!(void)(_classBinding.setMix, _godot_object, mix); 164 } 165 /** 166 167 */ 168 double getMix() const 169 { 170 checkClassBinding!(typeof(this))(); 171 return ptrcall!(double)(_classBinding.getMix, _godot_object); 172 } 173 /** 174 175 */ 176 void setSidechain(StringArg0)(in StringArg0 sidechain) 177 { 178 checkClassBinding!(typeof(this))(); 179 ptrcall!(void)(_classBinding.setSidechain, _godot_object, sidechain); 180 } 181 /** 182 183 */ 184 String getSidechain() const 185 { 186 checkClassBinding!(typeof(this))(); 187 return ptrcall!(String)(_classBinding.getSidechain, _godot_object); 188 } 189 /** 190 The level above which compression is applied to the audio. Value can range from -60 to 0. Default value: `0`. 191 */ 192 @property double threshold() 193 { 194 return getThreshold(); 195 } 196 /// ditto 197 @property void threshold(double v) 198 { 199 setThreshold(v); 200 } 201 /** 202 Amount of compression applied to the audio once it passes the threshold level. The higher the ratio the more the loud parts of the audio will be compressed. Value can range from 1 to 48. Default value: `4`. 203 */ 204 @property double ratio() 205 { 206 return getRatio(); 207 } 208 /// ditto 209 @property void ratio(double v) 210 { 211 setRatio(v); 212 } 213 /** 214 Gain applied to the output signal. 215 */ 216 @property double gain() 217 { 218 return getGain(); 219 } 220 /// ditto 221 @property void gain(double v) 222 { 223 setGain(v); 224 } 225 /** 226 Compressor's reaction time when the signal exceeds the threshold. Value can range from 20 to 2000. Default value: `20ms`. 227 */ 228 @property double attackUs() 229 { 230 return getAttackUs(); 231 } 232 /// ditto 233 @property void attackUs(double v) 234 { 235 setAttackUs(v); 236 } 237 /** 238 Compressor's delay time to stop reducing the signal after the signal level falls below the threshold. Value can range from 20 to 2000. Default value: `250ms`. 239 */ 240 @property double releaseMs() 241 { 242 return getReleaseMs(); 243 } 244 /// ditto 245 @property void releaseMs(double v) 246 { 247 setReleaseMs(v); 248 } 249 /** 250 Balance between original signal and effect signal. Value can range from 0 (totally dry) to 1 (totally wet). Default value: `1`. 251 */ 252 @property double mix() 253 { 254 return getMix(); 255 } 256 /// ditto 257 @property void mix(double v) 258 { 259 setMix(v); 260 } 261 /** 262 Reduce the sound level using another audio bus for threshold detection. 263 */ 264 @property String sidechain() 265 { 266 return getSidechain(); 267 } 268 /// ditto 269 @property void sidechain(String v) 270 { 271 setSidechain(v); 272 } 273 }