-
Notifications
You must be signed in to change notification settings - Fork 49
/
Audio.lua
738 lines (737 loc) · 27.6 KB
/
Audio.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
local path = (...):match('(.-)[^%./]+$')
return {
name = 'audio',
description = 'Provides an interface to create noise with the user\'s speakers.',
types = {
require(path .. 'types.RecordingDevice'),
require(path .. 'types.Source'),
},
functions = {
{
name = 'getActiveEffects',
description = 'Gets a list of the names of the currently enabled effects.',
variants = {
},
},
{
name = 'getActiveSourceCount',
description = 'Gets the current number of simultaneously playing sources.',
variants = {
{
returns = {
{
type = 'number',
name = 'count',
description = 'The current number of simultaneously playing sources.',
},
},
},
},
},
{
name = 'getDistanceModel',
description = 'Returns the distance attenuation model.',
variants = {
{
returns = {
{
type = 'DistanceModel',
name = 'model',
description = 'The current distance model. The default is \'inverseclamped\'.',
},
},
},
},
},
{
name = 'getDopplerScale',
description = 'Gets the current global scale factor for velocity-based doppler effects.',
variants = {
{
returns = {
{
type = 'number',
name = 'scale',
description = 'The current doppler scale factor.',
},
},
},
},
},
{
name = 'getEffect',
description = 'Gets the settings associated with an effect.',
variants = {
{
arguments = {
{
type = 'string',
name = 'name',
description = 'The name of the effect.',
},
},
returns = {
{
type = 'table',
name = 'settings',
description = 'The settings associated with the effect.',
},
},
},
},
},
{
name = 'getMaxSceneEffects',
description = 'Gets the maximum number of active effects supported by the system.',
variants = {
{
returns = {
{
type = 'number',
name = 'maximum',
description = 'The maximum number of active effects.',
},
},
},
},
},
{
name = 'getMaxSourceEffects',
description = 'Gets the maximum number of active Effects in a single Source object, that the system can support.',
variants = {
{
description = 'This function return 0 for system that doesn\'t support audio effects.',
returns = {
{
type = 'number',
name = 'maximum',
description = 'The maximum number of active Effects per Source.',
},
},
},
},
},
{
name = 'getOrientation',
description = 'Returns the orientation of the listener.',
variants = {
{
returns = {
{
type = 'number',
name = 'fx, fy, fz',
description = 'Forward vector of the listener orientation.',
},
{
type = 'number',
name = 'ux, uy, uz',
description = 'Up vector of the listener orientation.',
},
},
},
},
},
{
name = 'getPosition',
description = 'Returns the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources.',
variants = {
{
returns = {
{
type = 'number',
name = 'x',
description = 'The X position of the listener.',
},
{
type = 'number',
name = 'y',
description = 'The Y position of the listener.',
},
{
type = 'number',
name = 'z',
description = 'The Z position of the listener.',
},
},
},
},
},
{
name = 'getRecordingDevices',
description = 'Gets a list of RecordingDevices on the system.\n\nThe first device in the list is the user\'s default recording device. The list may be empty if there are no microphones connected to the system.\n\nAudio recording is currently not supported on iOS and Android.',
variants = {
{
returns = {
{
type = 'table',
name = 'devices',
description = 'The list of connected recording devices.',
},
},
},
},
},
{
name = 'getSourceCount',
description = 'Gets the current number of simultaneously playing sources.',
variants = {
{
returns = {
{
type = 'number',
name = 'numSources',
description = 'The current number of simultaneously playing sources.',
},
},
},
},
},
{
name = 'getVelocity',
description = 'Returns the velocity of the listener.',
variants = {
{
returns = {
{
type = 'number',
name = 'x',
description = 'The X velocity of the listener.',
},
{
type = 'number',
name = 'y',
description = 'The Y velocity of the listener.',
},
{
type = 'number',
name = 'z',
description = 'The Z velocity of the listener.',
},
},
},
},
},
{
name = 'getVolume',
description = 'Returns the master volume.',
variants = {
{
returns = {
{
type = 'number',
name = 'volume',
description = 'The current master volume',
},
},
},
},
},
{
name = 'isEffectsSupported',
description = 'Gets whether audio effects are supported in the system.',
variants = {
{
description = 'Older Linux distributions that ship with older OpenAL library may not support audio effects. Furthermore, iOS doesn\'t\n\nsupport audio effects at all.',
returns = {
{
type = 'boolean',
name = 'supported',
description = 'True if effects are supported, false otherwise.',
},
},
},
},
},
{
name = 'newQueueableSource',
description = 'Creates a new Source usable for real-time generated sound playback with Source:queue.',
variants = {
{
description = 'The sample rate, bit depth, and channel count of any SoundData used with Source:queue must match the parameters given to this constructor.',
arguments = {
{
type = 'number',
name = 'samplerate',
description = 'Number of samples per second when playing.',
},
{
type = 'number',
name = 'bitdepth',
description = 'Bits per sample (8 or 16).',
},
{
type = 'number',
name = 'channels',
description = '1 for mono or 2 for stereo.',
},
{
type = 'number',
name = 'buffercount',
description = 'The number of buffers that can be queued up at any given time with Source:queue. Cannot be greater than 64. A sensible default (~8) is chosen if no value is specified.',
default = '0',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'The new Source usable with Source:queue.',
},
},
},
},
},
{
name = 'newSource',
description = 'Creates a new Source from a filepath, File, Decoder or SoundData.\n\nSources created from SoundData are always static.',
variants = {
{
arguments = {
{
type = 'string',
name = 'filename',
description = 'The filepath to the audio file.',
},
{
type = 'SourceType',
name = 'type',
description = 'Streaming or static source.',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'A new Source that can play the specified audio.',
},
},
},
{
arguments = {
{
type = 'File',
name = 'file',
description = 'A File pointing to an audio file.',
},
{
type = 'SourceType',
name = 'type',
description = 'Streaming or static source.',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'A new Source that can play the specified audio.',
},
},
},
{
arguments = {
{
type = 'Decoder',
name = 'decoder',
description = 'The Decoder to create a Source from.',
},
{
type = 'SourceType',
name = 'type',
description = 'Streaming or static source.',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'A new Source that can play the specified audio.',
},
},
},
{
arguments = {
{
type = 'FileData',
name = 'data',
description = 'The FileData to create a Source from.',
},
{
type = 'SourceType',
name = 'type',
description = 'Streaming or static source.',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'A new Source that can play the specified audio.',
},
},
},
{
arguments = {
{
type = 'SoundData',
name = 'data',
description = 'The SoundData to create a Source from.',
},
},
returns = {
{
type = 'Source',
name = 'source',
description = 'A new Source that can play the specified audio. The SourceType of the returned audio is \'static\'.',
},
},
},
},
},
{
name = 'pause',
description = 'Pauses specific or all currently played Sources.',
variants = {
{
description = 'Pauses all currently active Sources and returns them.',
returns = {
{
type = 'table',
name = 'Sources',
description = 'A table containing a list of Sources that were paused by this call.',
},
},
},
{
description = 'Pauses the given Sources.',
arguments = {
{
type = 'Source',
name = 'source',
description = 'The first Source to pause.',
},
{
type = 'Source',
name = '...',
description = 'Additional Sources to pause.',
},
},
},
{
description = 'Pauses the given Sources.',
arguments = {
{
type = 'table',
name = 'sources',
description = 'A table containing a list of Sources to pause.',
},
},
},
},
},
{
name = 'play',
description = 'Plays the specified Source.',
variants = {
{
arguments = {
{
type = 'Source',
name = 'source',
description = 'The Source to play.',
},
},
},
{
description = 'Starts playing multiple Sources simultaneously.',
arguments = {
{
type = 'table',
name = 'sources',
description = 'Table containing a list of Sources to play.',
},
},
},
{
description = 'Starts playing multiple Sources simultaneously.',
arguments = {
{
type = 'Source',
name = 'source1',
description = 'The first Source to play.',
},
{
type = 'Source',
name = 'source2',
description = 'The second Source to play.',
},
{
type = 'Source',
name = '...',
description = 'Additional Sources to play.',
},
},
},
},
},
{
name = 'setDistanceModel',
description = 'Sets the distance attenuation model.',
variants = {
{
arguments = {
{
type = 'DistanceModel',
name = 'model',
description = 'The new distance model.',
},
},
},
},
},
{
name = 'setDopplerScale',
description = 'Sets a global scale factor for velocity-based doppler effects. The default scale value is 1.',
variants = {
{
arguments = {
{
type = 'number',
name = 'scale',
description = 'The new doppler scale factor. The scale must be greater than 0.',
},
},
},
},
},
{
name = 'setEffect',
description = 'Defines an effect that can be applied to a Source.\n\nNot all system supports audio effects. Use love.audio.isEffectsSupported to check.',
variants = {
{
arguments = {
{
type = 'string',
name = 'name',
description = 'The name of the effect.',
},
{
type = 'table',
name = 'settings',
description = 'The settings to use for this effect, with the following fields:',
table = {
{
type = 'EffectType',
name = 'type',
description = 'The type of effect to use.',
},
{
type = 'number',
name = 'volume',
description = 'The volume of the effect.',
},
{
type = 'number',
name = '...',
description = 'Effect-specific settings. See EffectType for available effects and their corresponding settings.',
},
},
},
},
returns = {
{
type = 'boolean',
name = 'success',
description = 'Whether the effect was successfully created.',
},
},
},
{
arguments = {
{
type = 'string',
name = 'name',
description = 'The name of the effect.',
},
{
type = 'boolean',
name = 'enabled',
description = 'If false and the given effect name was previously set, disables the effect.',
default = 'true',
},
},
returns = {
{
type = 'boolean',
name = 'success',
description = 'Whether the effect was successfully disabled.',
},
},
},
},
},
{
name = 'setMixWithSystem',
description = 'Sets whether the system should mix the audio with the system\'s audio.',
variants = {
{
arguments = {
{
type = 'boolean',
name = 'mix',
description = 'True to enable mixing, false to disable it.',
},
},
returns = {
{
type = 'boolean',
name = 'success',
description = 'True if the change succeeded, false otherwise.',
},
},
},
},
},
{
name = 'setOrientation',
description = 'Sets the orientation of the listener.',
variants = {
{
arguments = {
{
type = 'number',
name = 'fx, fy, fz',
description = 'Forward vector of the listener orientation.',
},
{
type = 'number',
name = 'ux, uy, uz',
description = 'Up vector of the listener orientation.',
},
},
},
},
},
{
name = 'setPosition',
description = 'Sets the position of the listener, which determines how sounds play.',
variants = {
{
arguments = {
{
type = 'number',
name = 'x',
description = 'The x position of the listener.',
},
{
type = 'number',
name = 'y',
description = 'The y position of the listener.',
},
{
type = 'number',
name = 'z',
description = 'The z position of the listener.',
},
},
},
},
},
{
name = 'setVelocity',
description = 'Sets the velocity of the listener.',
variants = {
{
arguments = {
{
type = 'number',
name = 'x',
description = 'The X velocity of the listener.',
},
{
type = 'number',
name = 'y',
description = 'The Y velocity of the listener.',
},
{
type = 'number',
name = 'z',
description = 'The Z velocity of the listener.',
},
},
},
},
},
{
name = 'setVolume',
description = 'Sets the master volume.',
variants = {
{
arguments = {
{
type = 'number',
name = 'volume',
description = '1.0 is max and 0.0 is off.',
},
},
},
},
},
{
name = 'stop',
description = 'Stops currently played sources.',
variants = {
{
description = 'This function will stop all currently active sources.',
},
{
description = 'This function will only stop the specified source.',
arguments = {
{
type = 'Source',
name = 'source',
description = 'The source on which to stop the playback.',
},
},
},
{
description = 'Simultaneously stops all given Sources.',
arguments = {
{
type = 'Source',
name = 'source1',
description = 'The first Source to stop.',
},
{
type = 'Source',
name = 'source2',
description = 'The second Source to stop.',
},
{
type = 'Source',
name = '...',
description = 'Additional Sources to stop.',
},
},
},
{
description = 'Simultaneously stops all given Sources.',
arguments = {
{
type = 'table',
name = 'sources',
description = 'A table containing a list of Sources to stop.',
},
},
},
},
},
},
enums = {
require(path .. 'enums.DistanceModel'),
require(path .. 'enums.EffectType'),
require(path .. 'enums.EffectWaveform'),
require(path .. 'enums.FilterType'),
require(path .. 'enums.SourceType'),
require(path .. 'enums.TimeUnit'),
},
}