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.traits;
18 import godot.core;
19 import godot.c;
20 import godot.d.bind;
21 import godot.d.reference;
22 import godot.globalenums;
23 import godot.object;
24 import godot.classdb;
25 import godot.audioeffect;
26 import godot.resource;
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 an $(D AudioEffectLimiter) is probably better).
34 - In voice channels to ensure they sound as balanced as possible.
35 - Sidechained. This can reduce the sound level sidechained with another audio bus for threshold detection. This technique is common in video game mixing to the level of music and 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 	package(godot) 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 GDNativeClassBinding
48 	{
49 		__gshared:
50 		@GodotName("get_attack_us") GodotMethod!(double) getAttackUs;
51 		@GodotName("get_gain") GodotMethod!(double) getGain;
52 		@GodotName("get_mix") GodotMethod!(double) getMix;
53 		@GodotName("get_ratio") GodotMethod!(double) getRatio;
54 		@GodotName("get_release_ms") GodotMethod!(double) getReleaseMs;
55 		@GodotName("get_sidechain") GodotMethod!(String) getSidechain;
56 		@GodotName("get_threshold") GodotMethod!(double) getThreshold;
57 		@GodotName("set_attack_us") GodotMethod!(void, double) setAttackUs;
58 		@GodotName("set_gain") GodotMethod!(void, double) setGain;
59 		@GodotName("set_mix") GodotMethod!(void, double) setMix;
60 		@GodotName("set_ratio") GodotMethod!(void, double) setRatio;
61 		@GodotName("set_release_ms") GodotMethod!(void, double) setReleaseMs;
62 		@GodotName("set_sidechain") GodotMethod!(void, String) setSidechain;
63 		@GodotName("set_threshold") GodotMethod!(void, double) setThreshold;
64 	}
65 	/// 
66 	pragma(inline, true) bool opEquals(in AudioEffectCompressor other) const
67 	{ return _godot_object.ptr is other._godot_object.ptr; }
68 	/// 
69 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
70 	{ _godot_object.ptr = n; return null; }
71 	/// 
72 	pragma(inline, true) bool opEquals(typeof(null) n) const
73 	{ return _godot_object.ptr is n; }
74 	/// 
75 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
76 	mixin baseCasts;
77 	/// Construct a new instance of AudioEffectCompressor.
78 	/// Note: use `memnew!AudioEffectCompressor` instead.
79 	static AudioEffectCompressor _new()
80 	{
81 		static godot_class_constructor constructor;
82 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioEffectCompressor");
83 		if(constructor is null) return typeof(this).init;
84 		return cast(AudioEffectCompressor)(constructor());
85 	}
86 	@disable new(size_t s);
87 	/**
88 	
89 	*/
90 	double getAttackUs() const
91 	{
92 		checkClassBinding!(typeof(this))();
93 		return ptrcall!(double)(GDNativeClassBinding.getAttackUs, _godot_object);
94 	}
95 	/**
96 	
97 	*/
98 	double getGain() const
99 	{
100 		checkClassBinding!(typeof(this))();
101 		return ptrcall!(double)(GDNativeClassBinding.getGain, _godot_object);
102 	}
103 	/**
104 	
105 	*/
106 	double getMix() const
107 	{
108 		checkClassBinding!(typeof(this))();
109 		return ptrcall!(double)(GDNativeClassBinding.getMix, _godot_object);
110 	}
111 	/**
112 	
113 	*/
114 	double getRatio() const
115 	{
116 		checkClassBinding!(typeof(this))();
117 		return ptrcall!(double)(GDNativeClassBinding.getRatio, _godot_object);
118 	}
119 	/**
120 	
121 	*/
122 	double getReleaseMs() const
123 	{
124 		checkClassBinding!(typeof(this))();
125 		return ptrcall!(double)(GDNativeClassBinding.getReleaseMs, _godot_object);
126 	}
127 	/**
128 	
129 	*/
130 	String getSidechain() const
131 	{
132 		checkClassBinding!(typeof(this))();
133 		return ptrcall!(String)(GDNativeClassBinding.getSidechain, _godot_object);
134 	}
135 	/**
136 	
137 	*/
138 	double getThreshold() const
139 	{
140 		checkClassBinding!(typeof(this))();
141 		return ptrcall!(double)(GDNativeClassBinding.getThreshold, _godot_object);
142 	}
143 	/**
144 	
145 	*/
146 	void setAttackUs(in double attack_us)
147 	{
148 		checkClassBinding!(typeof(this))();
149 		ptrcall!(void)(GDNativeClassBinding.setAttackUs, _godot_object, attack_us);
150 	}
151 	/**
152 	
153 	*/
154 	void setGain(in double gain)
155 	{
156 		checkClassBinding!(typeof(this))();
157 		ptrcall!(void)(GDNativeClassBinding.setGain, _godot_object, gain);
158 	}
159 	/**
160 	
161 	*/
162 	void setMix(in double mix)
163 	{
164 		checkClassBinding!(typeof(this))();
165 		ptrcall!(void)(GDNativeClassBinding.setMix, _godot_object, mix);
166 	}
167 	/**
168 	
169 	*/
170 	void setRatio(in double ratio)
171 	{
172 		checkClassBinding!(typeof(this))();
173 		ptrcall!(void)(GDNativeClassBinding.setRatio, _godot_object, ratio);
174 	}
175 	/**
176 	
177 	*/
178 	void setReleaseMs(in double release_ms)
179 	{
180 		checkClassBinding!(typeof(this))();
181 		ptrcall!(void)(GDNativeClassBinding.setReleaseMs, _godot_object, release_ms);
182 	}
183 	/**
184 	
185 	*/
186 	void setSidechain(in String sidechain)
187 	{
188 		checkClassBinding!(typeof(this))();
189 		ptrcall!(void)(GDNativeClassBinding.setSidechain, _godot_object, sidechain);
190 	}
191 	/**
192 	
193 	*/
194 	void setThreshold(in double threshold)
195 	{
196 		checkClassBinding!(typeof(this))();
197 		ptrcall!(void)(GDNativeClassBinding.setThreshold, _godot_object, threshold);
198 	}
199 	/**
200 	Compressor's reaction time when the signal exceeds the threshold, in microseconds. Value can range from 20 to 2000.
201 	*/
202 	@property double attackUs()
203 	{
204 		return getAttackUs();
205 	}
206 	/// ditto
207 	@property void attackUs(double v)
208 	{
209 		setAttackUs(v);
210 	}
211 	/**
212 	Gain applied to the output signal.
213 	*/
214 	@property double gain()
215 	{
216 		return getGain();
217 	}
218 	/// ditto
219 	@property void gain(double v)
220 	{
221 		setGain(v);
222 	}
223 	/**
224 	Balance between original signal and effect signal. Value can range from 0 (totally dry) to 1 (totally wet).
225 	*/
226 	@property double mix()
227 	{
228 		return getMix();
229 	}
230 	/// ditto
231 	@property void mix(double v)
232 	{
233 		setMix(v);
234 	}
235 	/**
236 	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.
237 	*/
238 	@property double ratio()
239 	{
240 		return getRatio();
241 	}
242 	/// ditto
243 	@property void ratio(double v)
244 	{
245 		setRatio(v);
246 	}
247 	/**
248 	Compressor's delay time to stop reducing the signal after the signal level falls below the threshold, in milliseconds. Value can range from 20 to 2000.
249 	*/
250 	@property double releaseMs()
251 	{
252 		return getReleaseMs();
253 	}
254 	/// ditto
255 	@property void releaseMs(double v)
256 	{
257 		setReleaseMs(v);
258 	}
259 	/**
260 	Reduce the sound level using another audio bus for threshold detection.
261 	*/
262 	@property String sidechain()
263 	{
264 		return getSidechain();
265 	}
266 	/// ditto
267 	@property void sidechain(String v)
268 	{
269 		setSidechain(v);
270 	}
271 	/**
272 	The level above which compression is applied to the audio. Value can range from -60 to 0.
273 	*/
274 	@property double threshold()
275 	{
276 		return getThreshold();
277 	}
278 	/// ditto
279 	@property void threshold(double v)
280 	{
281 		setThreshold(v);
282 	}
283 }