1 /** 2 Plays audio. 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.audiostreamsample; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.audiostream; 24 import godot.resource; 25 import godot.reference; 26 /** 27 Plays audio. 28 29 Plays audio, can loop. 30 */ 31 @GodotBaseClass struct AudioStreamSample 32 { 33 enum string _GODOT_internal_name = "AudioStreamSample"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; AudioStream _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct _classBinding 41 { 42 __gshared: 43 @GodotName("set_data") GodotMethod!(void, PoolByteArray) setData; 44 @GodotName("get_data") GodotMethod!(PoolByteArray) getData; 45 @GodotName("set_format") GodotMethod!(void, long) setFormat; 46 @GodotName("get_format") GodotMethod!(AudioStreamSample.Format) getFormat; 47 @GodotName("set_loop_mode") GodotMethod!(void, long) setLoopMode; 48 @GodotName("get_loop_mode") GodotMethod!(AudioStreamSample.LoopMode) getLoopMode; 49 @GodotName("set_loop_begin") GodotMethod!(void, long) setLoopBegin; 50 @GodotName("get_loop_begin") GodotMethod!(long) getLoopBegin; 51 @GodotName("set_loop_end") GodotMethod!(void, long) setLoopEnd; 52 @GodotName("get_loop_end") GodotMethod!(long) getLoopEnd; 53 @GodotName("set_mix_rate") GodotMethod!(void, long) setMixRate; 54 @GodotName("get_mix_rate") GodotMethod!(long) getMixRate; 55 @GodotName("set_stereo") GodotMethod!(void, bool) setStereo; 56 @GodotName("is_stereo") GodotMethod!(bool) isStereo; 57 @GodotName("save_to_wav") GodotMethod!(void, String) saveToWav; 58 } 59 bool opEquals(in AudioStreamSample other) const { return _godot_object.ptr is other._godot_object.ptr; } 60 AudioStreamSample opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 61 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 62 mixin baseCasts; 63 static AudioStreamSample _new() 64 { 65 static godot_class_constructor constructor; 66 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioStreamSample"); 67 if(constructor is null) return typeof(this).init; 68 return cast(AudioStreamSample)(constructor()); 69 } 70 @disable new(size_t s); 71 /// 72 enum LoopMode : int 73 { 74 /** 75 Audio does not loop. 76 */ 77 loopDisabled = 0, 78 /** 79 Audio loops the data between loop_begin and loop_end playing forward only. 80 */ 81 loopForward = 1, 82 /** 83 Audio loops the data between loop_begin and loop_end playing back and forth. 84 */ 85 loopPingPong = 2, 86 } 87 /// 88 enum Format : int 89 { 90 /** 91 Audio codec 8 bit. 92 */ 93 format8Bits = 0, 94 /** 95 Audio codec 16 bit. 96 */ 97 format16Bits = 1, 98 /** 99 Audio codec IMA ADPCM. 100 */ 101 formatImaAdpcm = 2, 102 } 103 /// 104 enum Constants : int 105 { 106 loopDisabled = 0, 107 format8Bits = 0, 108 loopForward = 1, 109 format16Bits = 1, 110 formatImaAdpcm = 2, 111 loopPingPong = 2, 112 } 113 /** 114 115 */ 116 void setData(in PoolByteArray data) 117 { 118 checkClassBinding!(typeof(this))(); 119 ptrcall!(void)(_classBinding.setData, _godot_object, data); 120 } 121 /** 122 123 */ 124 PoolByteArray getData() const 125 { 126 checkClassBinding!(typeof(this))(); 127 return ptrcall!(PoolByteArray)(_classBinding.getData, _godot_object); 128 } 129 /** 130 131 */ 132 void setFormat(in long format) 133 { 134 checkClassBinding!(typeof(this))(); 135 ptrcall!(void)(_classBinding.setFormat, _godot_object, format); 136 } 137 /** 138 139 */ 140 AudioStreamSample.Format getFormat() const 141 { 142 checkClassBinding!(typeof(this))(); 143 return ptrcall!(AudioStreamSample.Format)(_classBinding.getFormat, _godot_object); 144 } 145 /** 146 147 */ 148 void setLoopMode(in long loop_mode) 149 { 150 checkClassBinding!(typeof(this))(); 151 ptrcall!(void)(_classBinding.setLoopMode, _godot_object, loop_mode); 152 } 153 /** 154 155 */ 156 AudioStreamSample.LoopMode getLoopMode() const 157 { 158 checkClassBinding!(typeof(this))(); 159 return ptrcall!(AudioStreamSample.LoopMode)(_classBinding.getLoopMode, _godot_object); 160 } 161 /** 162 163 */ 164 void setLoopBegin(in long loop_begin) 165 { 166 checkClassBinding!(typeof(this))(); 167 ptrcall!(void)(_classBinding.setLoopBegin, _godot_object, loop_begin); 168 } 169 /** 170 171 */ 172 long getLoopBegin() const 173 { 174 checkClassBinding!(typeof(this))(); 175 return ptrcall!(long)(_classBinding.getLoopBegin, _godot_object); 176 } 177 /** 178 179 */ 180 void setLoopEnd(in long loop_end) 181 { 182 checkClassBinding!(typeof(this))(); 183 ptrcall!(void)(_classBinding.setLoopEnd, _godot_object, loop_end); 184 } 185 /** 186 187 */ 188 long getLoopEnd() const 189 { 190 checkClassBinding!(typeof(this))(); 191 return ptrcall!(long)(_classBinding.getLoopEnd, _godot_object); 192 } 193 /** 194 195 */ 196 void setMixRate(in long mix_rate) 197 { 198 checkClassBinding!(typeof(this))(); 199 ptrcall!(void)(_classBinding.setMixRate, _godot_object, mix_rate); 200 } 201 /** 202 203 */ 204 long getMixRate() const 205 { 206 checkClassBinding!(typeof(this))(); 207 return ptrcall!(long)(_classBinding.getMixRate, _godot_object); 208 } 209 /** 210 211 */ 212 void setStereo(in bool stereo) 213 { 214 checkClassBinding!(typeof(this))(); 215 ptrcall!(void)(_classBinding.setStereo, _godot_object, stereo); 216 } 217 /** 218 219 */ 220 bool isStereo() const 221 { 222 checkClassBinding!(typeof(this))(); 223 return ptrcall!(bool)(_classBinding.isStereo, _godot_object); 224 } 225 /** 226 227 */ 228 void saveToWav(StringArg0)(in StringArg0 path) 229 { 230 checkClassBinding!(typeof(this))(); 231 ptrcall!(void)(_classBinding.saveToWav, _godot_object, path); 232 } 233 /** 234 Contains the audio data in bytes. 235 */ 236 @property PoolByteArray data() 237 { 238 return getData(); 239 } 240 /// ditto 241 @property void data(PoolByteArray v) 242 { 243 setData(v); 244 } 245 /** 246 Audio format. See FORMAT_* constants for values. 247 */ 248 @property AudioStreamSample.Format format() 249 { 250 return getFormat(); 251 } 252 /// ditto 253 @property void format(long v) 254 { 255 setFormat(v); 256 } 257 /** 258 Loop mode. See LOOP_* constants for values. 259 */ 260 @property AudioStreamSample.LoopMode loopMode() 261 { 262 return getLoopMode(); 263 } 264 /// ditto 265 @property void loopMode(long v) 266 { 267 setLoopMode(v); 268 } 269 /** 270 Loop start in bytes. 271 */ 272 @property long loopBegin() 273 { 274 return getLoopBegin(); 275 } 276 /// ditto 277 @property void loopBegin(long v) 278 { 279 setLoopBegin(v); 280 } 281 /** 282 Loop end in bytes. 283 */ 284 @property long loopEnd() 285 { 286 return getLoopEnd(); 287 } 288 /// ditto 289 @property void loopEnd(long v) 290 { 291 setLoopEnd(v); 292 } 293 /** 294 The sample rate for mixing this audio. 295 */ 296 @property long mixRate() 297 { 298 return getMixRate(); 299 } 300 /// ditto 301 @property void mixRate(long v) 302 { 303 setMixRate(v); 304 } 305 /** 306 If `true`, audio is stereo. Default value: `false`. 307 */ 308 @property bool stereo() 309 { 310 return isStereo(); 311 } 312 /// ditto 313 @property void stereo(bool v) 314 { 315 setStereo(v); 316 } 317 }