1 /**
2 Captures audio from an audio bus in real-time.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.audioeffectcapture;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.audioeffect;
25 import godot.resource;
26 /**
27 Captures audio from an audio bus in real-time.
28 
29 AudioEffectCapture is an AudioEffect which copies all audio frames from the attached audio effect bus into its internal ring buffer.
30 Application code should consume these audio frames from this ring buffer using $(D getBuffer) and process it as needed, for example to capture data from a microphone, implement application defined effects, or to transmit audio over the network.
31 */
32 @GodotBaseClass struct AudioEffectCapture
33 {
34 	package(godot) enum string _GODOT_internal_name = "AudioEffectCapture";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ AudioEffect _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("can_get_buffer") GodotMethod!(bool, long) canGetBuffer;
45 		@GodotName("clear_buffer") GodotMethod!(void) clearBuffer;
46 		@GodotName("get_buffer") GodotMethod!(PoolVector2Array, long) getBuffer;
47 		@GodotName("get_buffer_length") GodotMethod!(double) getBufferLength;
48 		@GodotName("get_buffer_length_frames") GodotMethod!(long) getBufferLengthFrames;
49 		@GodotName("get_discarded_frames") GodotMethod!(long) getDiscardedFrames;
50 		@GodotName("get_frames_available") GodotMethod!(long) getFramesAvailable;
51 		@GodotName("get_pushed_frames") GodotMethod!(long) getPushedFrames;
52 		@GodotName("set_buffer_length") GodotMethod!(void, double) setBufferLength;
53 	}
54 	/// 
55 	pragma(inline, true) bool opEquals(in AudioEffectCapture other) const
56 	{ return _godot_object.ptr is other._godot_object.ptr; }
57 	/// 
58 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
59 	{ _godot_object.ptr = n; return null; }
60 	/// 
61 	pragma(inline, true) bool opEquals(typeof(null) n) const
62 	{ return _godot_object.ptr is n; }
63 	/// 
64 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
65 	mixin baseCasts;
66 	/// Construct a new instance of AudioEffectCapture.
67 	/// Note: use `memnew!AudioEffectCapture` instead.
68 	static AudioEffectCapture _new()
69 	{
70 		static godot_class_constructor constructor;
71 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioEffectCapture");
72 		if(constructor is null) return typeof(this).init;
73 		return cast(AudioEffectCapture)(constructor());
74 	}
75 	@disable new(size_t s);
76 	/**
77 	Returns `true` if at least `frames` audio frames are available to read in the internal ring buffer.
78 	*/
79 	bool canGetBuffer(in long frames) const
80 	{
81 		checkClassBinding!(typeof(this))();
82 		return ptrcall!(bool)(GDNativeClassBinding.canGetBuffer, _godot_object, frames);
83 	}
84 	/**
85 	Clears the internal ring buffer.
86 	*/
87 	void clearBuffer()
88 	{
89 		checkClassBinding!(typeof(this))();
90 		ptrcall!(void)(GDNativeClassBinding.clearBuffer, _godot_object);
91 	}
92 	/**
93 	Gets the next `frames` audio samples from the internal ring buffer.
94 	Returns a $(D PoolVector2Array) containing exactly `frames` audio samples if available, or an empty $(D PoolVector2Array) if insufficient data was available.
95 	*/
96 	PoolVector2Array getBuffer(in long frames)
97 	{
98 		checkClassBinding!(typeof(this))();
99 		return ptrcall!(PoolVector2Array)(GDNativeClassBinding.getBuffer, _godot_object, frames);
100 	}
101 	/**
102 	
103 	*/
104 	double getBufferLength()
105 	{
106 		checkClassBinding!(typeof(this))();
107 		return ptrcall!(double)(GDNativeClassBinding.getBufferLength, _godot_object);
108 	}
109 	/**
110 	Returns the total size of the internal ring buffer in frames.
111 	*/
112 	long getBufferLengthFrames() const
113 	{
114 		checkClassBinding!(typeof(this))();
115 		return ptrcall!(long)(GDNativeClassBinding.getBufferLengthFrames, _godot_object);
116 	}
117 	/**
118 	Returns the number of audio frames discarded from the audio bus due to full buffer.
119 	*/
120 	long getDiscardedFrames() const
121 	{
122 		checkClassBinding!(typeof(this))();
123 		return ptrcall!(long)(GDNativeClassBinding.getDiscardedFrames, _godot_object);
124 	}
125 	/**
126 	Returns the number of frames available to read using $(D getBuffer).
127 	*/
128 	long getFramesAvailable() const
129 	{
130 		checkClassBinding!(typeof(this))();
131 		return ptrcall!(long)(GDNativeClassBinding.getFramesAvailable, _godot_object);
132 	}
133 	/**
134 	Returns the number of audio frames inserted from the audio bus.
135 	*/
136 	long getPushedFrames() const
137 	{
138 		checkClassBinding!(typeof(this))();
139 		return ptrcall!(long)(GDNativeClassBinding.getPushedFrames, _godot_object);
140 	}
141 	/**
142 	
143 	*/
144 	void setBufferLength(in double buffer_length_seconds)
145 	{
146 		checkClassBinding!(typeof(this))();
147 		ptrcall!(void)(GDNativeClassBinding.setBufferLength, _godot_object, buffer_length_seconds);
148 	}
149 	/**
150 	Length of the internal ring buffer, in seconds. Setting the buffer length will have no effect if already initialized.
151 	*/
152 	@property double bufferLength()
153 	{
154 		return getBufferLength();
155 	}
156 	/// ditto
157 	@property void bufferLength(double v)
158 	{
159 		setBufferLength(v);
160 	}
161 }