-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathaudio_gen.nim
1399 lines (1247 loc) · 48.4 KB
/
audio_gen.nim
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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#--- SFML/Audio ---#
#--- SFML/Audio/Listener ---#
proc listener_setGlobalVolume*(volume: cfloat) {.
cdecl, importc: "sfListener_setGlobalVolume".}
## Change the global volume of all the sounds and musics
##
## The volume is a number between 0 and 100; it is combined with
## the individual volume of each sound / music.
## The default value for the volume is 100 (maximum).
##
## *Arguments*:
## - ``volume``: New global volume, in the range [0, 100]
proc listener_getGlobalVolume*(): cfloat {.
cdecl, importc: "sfListener_getGlobalVolume".}
## Get the current value of the global volume
##
## *Returns:* Current global volume, in the range [0, 100]
proc listener_setPosition*(position: Vector3f) {.
cdecl, importc: "sfListener_setPosition".}
## Set the position of the listener in the scene
##
## The default listener's position is (0, 0, 0).
##
## *Arguments*:
## - ``position``: New position of the listener
proc listener_getPosition*(): Vector3f {.
cdecl, importc: "sfListener_getPosition".}
## Get the current position of the listener in the scene
##
## *Returns:* The listener's position
proc listener_setDirection*(direction: Vector3f) {.
cdecl, importc: "sfListener_setDirection".}
## Set the orientation of the forward vector in the scene
##
## The direction (also called "at vector") is the vector
## pointing forward from the listener's perspective. Together
## with the up vector, it defines the 3D orientation of the
## listener in the scene. The direction vector doesn't
## have to be normalized.
## The default listener's direction is (0, 0, -1).
##
## *Arguments*:
## - ``direction``: New listener's direction
proc listener_getDirection*(): Vector3f {.
cdecl, importc: "sfListener_getDirection".}
## Get the current forward vector of the listener in the scene
##
## *Returns:* Listener's forward vector (not normalized)
proc listener_setUpVector*(upVector: Vector3f) {.
cdecl, importc: "sfListener_setUpVector".}
## Set the upward vector of the listener in the scene
##
## The up vector is the vector that points upward from the
## listener's perspective. Together with the direction, it
## defines the 3D orientation of the listener in the scene.
## The up vector doesn't have to be normalized.
## The default listener's up vector is (0, 1, 0). It is usually
## not necessary to change it, especially in 2D scenarios.
##
## *Arguments*:
## - ``upVector``: New listener's up vector
proc listener_getUpVector*(): Vector3f {.
cdecl, importc: "sfListener_getUpVector".}
## Get the current upward vector of the listener in the scene
##
## *Returns:* Listener's upward vector (not normalized)
#--- SFML/Audio/Music ---#
#--- SFML/Audio/SoundStatus ---#
type SoundStatus* {.pure, size: sizeof(cint).} = enum ## Enumeration of statuses for sounds and musics
Stopped, Paused, Playing
#--- SFML/Audio/Types ---#
type Music* = ptr object
type Sound* = ptr object
type SoundBuffer* = ptr object
type SoundBufferRecorder* = ptr object
type SoundRecorder* = ptr object
type SoundStream* = ptr object
type TimeSpan* {.bycopy.} = object
## Structure defining a time range
offset*: Time
length*: Time
proc newMusic*(filename: cstring): Music {.
cdecl, importc: "sfMusic_createFromFile".}
## Create a new music and load it from a file
##
## This function doesn't start playing the music (call
## Music_play to do so).
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``filename``: Path of the music file to open
##
## *Returns:* A new Music object (NULL if failed)
proc newMusic*(data: pointer, sizeInBytes: int): Music {.
cdecl, importc: "sfMusic_createFromMemory".}
## Create a new music and load it from a file in memory
##
## This function doesn't start playing the music (call
## Music_play to do so).
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``data``: Pointer to the file data in memory
## - ``sizeInBytes``: Size of the data to load, in bytes
##
## *Returns:* A new Music object (NULL if failed)
proc newMusic*(stream: var InputStream): Music {.
cdecl, importc: "sfMusic_createFromStream".}
## Create a new music and load it from a custom stream
##
## This function doesn't start playing the music (call
## Music_play to do so).
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``stream``: Source stream to read from
##
## *Returns:* A new Music object (NULL if failed)
proc destroy*(music: Music) {.
cdecl, importc: "sfMusic_destroy".}
## Destroy a music
##
## *Arguments*:
## - ``music``: Music to destroy
proc `loop=`*(music: Music, loop: BoolInt) {.
cdecl, importc: "sfMusic_setLoop".}
## Set whether or not a music should loop after reaching the end
##
## If set, the music will restart from beginning after
## reaching the end and so on, until it is stopped or
## Music_setLoop(music, False) is called.
## The default looping state for musics is false.
##
## *Arguments*:
## - ``music``: Music object
## - ``loop``: True to play in loop, False to play once
proc loop*(music: Music): BoolInt {.
cdecl, importc: "sfMusic_getLoop".}
## Tell whether or not a music is in loop mode
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* True if the music is looping, False otherwise
proc duration*(music: Music): Time {.
cdecl, importc: "sfMusic_getDuration".}
## Get the total duration of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Music duration
proc loopPoints*(music: Music): TimeSpan {.
cdecl, importc: "sfMusic_getLoopPoints".}
## Get the positions of the of the sound's looping sequence
##
## *Returns:* Loop Time position class.
##
## \warning Since Music_setLoopPoints() performs some adjustments on the
## provided values and rounds them to internal samples, a call to
## Music_getLoopPoints() is not guaranteed to return the same times passed
## into a previous call to Music_setLoopPoints(). However, it is guaranteed
## to return times that will map to the valid internal samples of
## this Music if they are later passed to Music_setLoopPoints().
##
## \see setLoopPoints
proc `loopPoints=`*(music: Music, timePoints: TimeSpan) {.
cdecl, importc: "sfMusic_setLoopPoints".}
## Sets the beginning and end of the sound's looping sequence using sf::Time
##
## Loop points allow one to specify a pair of positions such that, when the music
## is enabled for looping, it will seamlessly seek to the beginning whenever it
## encounters the end. Valid ranges for timePoints.offset and timePoints.length are
## [0, Dur) and (0, Dur-offset] respectively, where Dur is the value returned by Music_getDuration().
## Note that the EOF "loop point" from the end to the beginning of the stream is still honored,
## in case the caller seeks to a point after the end of the loop range. This function can be
## safely called at any point after a stream is opened, and will be applied to a playing sound
## without affecting the current playing offset.
##
## \warning Setting the loop points while the stream's status is Paused
## will set its status to Stopped. The playing offset will be unaffected.
##
## *Arguments*:
## - ``timePoints``: The definition of the loop. Can be any time points within the sound's length
##
## \see getLoopPoints
proc play*(music: Music) {.
cdecl, importc: "sfMusic_play".}
## Start or resume playing a music
##
## This function starts the music if it was stopped, resumes
## it if it was paused, and restarts it from beginning if it
## was it already playing.
## This function uses its own thread so that it doesn't block
## the rest of the program while the music is played.
##
## *Arguments*:
## - ``music``: Music object
proc pause*(music: Music) {.
cdecl, importc: "sfMusic_pause".}
## Pause a music
##
## This function pauses the music if it was playing,
## otherwise (music already paused or stopped) it has no effect.
##
## *Arguments*:
## - ``music``: Music object
proc stop*(music: Music) {.
cdecl, importc: "sfMusic_stop".}
## Stop playing a music
##
## This function stops the music if it was playing or paused,
## and does nothing if it was already stopped.
## It also resets the playing position (unlike Music_pause).
##
## *Arguments*:
## - ``music``: Music object
proc channelCount*(music: Music): cint {.
cdecl, importc: "sfMusic_getChannelCount".}
## Return the number of channels of a music
##
## 1 channel means a mono sound, 2 means stereo, etc.
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Number of channels
proc sampleRate*(music: Music): cint {.
cdecl, importc: "sfMusic_getSampleRate".}
## Get the sample rate of a music
##
## The sample rate is the number of audio samples played per
## second. The higher, the better the quality.
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Sample rate, in number of samples per second
proc status*(music: Music): SoundStatus {.
cdecl, importc: "sfMusic_getStatus".}
## Get the current status of a music (stopped, paused, playing)
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Current status
proc playingOffset*(music: Music): Time {.
cdecl, importc: "sfMusic_getPlayingOffset".}
## Get the current playing position of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Current playing position
proc `pitch=`*(music: Music, pitch: cfloat) {.
cdecl, importc: "sfMusic_setPitch".}
## Set the pitch of a music
##
## The pitch represents the perceived fundamental frequency
## of a sound; thus you can make a music more acute or grave
## by changing its pitch. A side effect of changing the pitch
## is to modify the playing speed of the music as well.
## The default value for the pitch is 1.
##
## *Arguments*:
## - ``music``: Music object
## - ``pitch``: New pitch to apply to the music
proc `volume=`*(music: Music, volume: cfloat) {.
cdecl, importc: "sfMusic_setVolume".}
## Set the volume of a music
##
## The volume is a value between 0 (mute) and 100 (full volume).
## The default value for the volume is 100.
##
## *Arguments*:
## - ``music``: Music object
## - ``volume``: Volume of the music
proc `position=`*(music: Music, position: Vector3f) {.
cdecl, importc: "sfMusic_setPosition".}
## Set the 3D position of a music in the audio scene
##
## Only musics with one channel (mono musics) can be
## spatialized.
## The default position of a music is (0, 0, 0).
##
## *Arguments*:
## - ``music``: Music object
## - ``position``: Position of the music in the scene
proc `relativeToListener=`*(music: Music, relative: BoolInt) {.
cdecl, importc: "sfMusic_setRelativeToListener".}
## Make a musics's position relative to the listener or absolute
##
## Making a music relative to the listener will ensure that it will always
## be played the same way regardless the position of the listener.
## This can be useful for non-spatialized musics, musics that are
## produced by the listener, or musics attached to it.
## The default value is false (position is absolute).
##
## *Arguments*:
## - ``music``: Music object
## - ``relative``: True to set the position relative, False to set it absolute
proc `minDistance=`*(music: Music, distance: cfloat) {.
cdecl, importc: "sfMusic_setMinDistance".}
## Set the minimum distance of a music
##
## The "minimum distance" of a music is the maximum
## distance at which it is heard at its maximum volume. Further
## than the minimum distance, it will start to fade out according
## to its attenuation factor. A value of 0 ("inside the head
## of the listener") is an invalid value and is forbidden.
## The default value of the minimum distance is 1.
##
## *Arguments*:
## - ``music``: Music object
## - ``distance``: New minimum distance of the music
proc `attenuation=`*(music: Music, attenuation: cfloat) {.
cdecl, importc: "sfMusic_setAttenuation".}
## Set the attenuation factor of a music
##
## The attenuation is a multiplicative factor which makes
## the music more or less loud according to its distance
## from the listener. An attenuation of 0 will produce a
## non-attenuated music, i.e. its volume will always be the same
## whether it is heard from near or from far. On the other hand,
## an attenuation value such as 100 will make the music fade out
## very quickly as it gets further from the listener.
## The default value of the attenuation is 1.
##
## *Arguments*:
## - ``music``: Music object
## - ``attenuation``: New attenuation factor of the music
proc `playingOffset=`*(music: Music, timeOffset: Time) {.
cdecl, importc: "sfMusic_setPlayingOffset".}
## Change the current playing position of a music
##
## The playing position can be changed when the music is
## either paused or playing.
##
## *Arguments*:
## - ``music``: Music object
## - ``timeOffset``: New playing position
proc pitch*(music: Music): cfloat {.
cdecl, importc: "sfMusic_getPitch".}
## Get the pitch of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Pitch of the music
proc volume*(music: Music): cfloat {.
cdecl, importc: "sfMusic_getVolume".}
## Get the volume of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Volume of the music, in the range [0, 100]
proc position*(music: Music): Vector3f {.
cdecl, importc: "sfMusic_getPosition".}
## Get the 3D position of a music in the audio scene
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Position of the music in the world
proc relativeToListener*(music: Music): BoolInt {.
cdecl, importc: "sfMusic_isRelativeToListener".}
## Tell whether a music's position is relative to the
## listener or is absolute
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* True if the position is relative, False if it's absolute
proc minDistance*(music: Music): cfloat {.
cdecl, importc: "sfMusic_getMinDistance".}
## Get the minimum distance of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Minimum distance of the music
proc attenuation*(music: Music): cfloat {.
cdecl, importc: "sfMusic_getAttenuation".}
## Get the attenuation factor of a music
##
## *Arguments*:
## - ``music``: Music object
##
## *Returns:* Attenuation factor of the music
#--- SFML/Audio/Sound ---#
proc newSound*(): Sound {.
cdecl, importc: "sfSound_create".}
## Create a new sound
##
## *Returns:* A new Sound object
proc copy*(sound: Sound): Sound {.
cdecl, importc: "sfSound_copy".}
## Create a new sound by copying an existing one
##
## *Arguments*:
## - ``sound``: Sound to copy
##
## *Returns:* A new Sound object which is a copy of ``sound``
proc destroy*(sound: Sound) {.
cdecl, importc: "sfSound_destroy".}
## Destroy a sound
##
## *Arguments*:
## - ``sound``: Sound to destroy
proc play*(sound: Sound) {.
cdecl, importc: "sfSound_play".}
## Start or resume playing a sound
##
## This function starts the sound if it was stopped, resumes
## it if it was paused, and restarts it from beginning if it
## was it already playing.
## This function uses its own thread so that it doesn't block
## the rest of the program while the sound is played.
##
## *Arguments*:
## - ``sound``: Sound object
proc pause*(sound: Sound) {.
cdecl, importc: "sfSound_pause".}
## Pause a sound
##
## This function pauses the sound if it was playing,
## otherwise (sound already paused or stopped) it has no effect.
##
## *Arguments*:
## - ``sound``: Sound object
proc stop*(sound: Sound) {.
cdecl, importc: "sfSound_stop".}
## Stop playing a sound
##
## This function stops the sound if it was playing or paused,
## and does nothing if it was already stopped.
## It also resets the playing position (unlike Sound_pause).
##
## *Arguments*:
## - ``sound``: Sound object
proc `buffer=`*(sound: Sound, buffer: SoundBuffer) {.
cdecl, importc: "sfSound_setBuffer".}
## Set the source buffer containing the audio data to play
##
## It is important to note that the sound buffer is not copied,
## thus the SoundBuffer object must remain alive as long
## as it is attached to the sound.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``buffer``: Sound buffer to attach to the sound
proc buffer*(sound: Sound): SoundBuffer {.
cdecl, importc: "sfSound_getBuffer".}
## Get the audio buffer attached to a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Sound buffer attached to the sound (can be NULL)
proc `loop=`*(sound: Sound, loop: BoolInt) {.
cdecl, importc: "sfSound_setLoop".}
## Set whether or not a sound should loop after reaching the end
##
## If set, the sound will restart from beginning after
## reaching the end and so on, until it is stopped or
## Sound_setLoop(sound, False) is called.
## The default looping state for sounds is false.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``loop``: True to play in loop, False to play once
proc loop*(sound: Sound): BoolInt {.
cdecl, importc: "sfSound_getLoop".}
## Tell whether or not a sound is in loop mode
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* True if the sound is looping, False otherwise
proc status*(sound: Sound): SoundStatus {.
cdecl, importc: "sfSound_getStatus".}
## Get the current status of a sound (stopped, paused, playing)
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Current status
proc `pitch=`*(sound: Sound, pitch: cfloat) {.
cdecl, importc: "sfSound_setPitch".}
## Set the pitch of a sound
##
## The pitch represents the perceived fundamental frequency
## of a sound; thus you can make a sound more acute or grave
## by changing its pitch. A side effect of changing the pitch
## is to modify the playing speed of the sound as well.
## The default value for the pitch is 1.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``pitch``: New pitch to apply to the sound
proc `volume=`*(sound: Sound, volume: cfloat) {.
cdecl, importc: "sfSound_setVolume".}
## Set the volume of a sound
##
## The volume is a value between 0 (mute) and 100 (full volume).
## The default value for the volume is 100.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``volume``: Volume of the sound
proc `position=`*(sound: Sound, position: Vector3f) {.
cdecl, importc: "sfSound_setPosition".}
## Set the 3D position of a sound in the audio scene
##
## Only sounds with one channel (mono sounds) can be
## spatialized.
## The default position of a sound is (0, 0, 0).
##
## *Arguments*:
## - ``sound``: Sound object
## - ``position``: Position of the sound in the scene
proc `relativeToListener=`*(sound: Sound, relative: BoolInt) {.
cdecl, importc: "sfSound_setRelativeToListener".}
## Make the sound's position relative to the listener or absolute
##
## Making a sound relative to the listener will ensure that it will always
## be played the same way regardless the position of the listener.
## This can be useful for non-spatialized sounds, sounds that are
## produced by the listener, or sounds attached to it.
## The default value is false (position is absolute).
##
## *Arguments*:
## - ``sound``: Sound object
## - ``relative``: True to set the position relative, False to set it absolute
proc `minDistance=`*(sound: Sound, distance: cfloat) {.
cdecl, importc: "sfSound_setMinDistance".}
## Set the minimum distance of a sound
##
## The "minimum distance" of a sound is the maximum
## distance at which it is heard at its maximum volume. Further
## than the minimum distance, it will start to fade out according
## to its attenuation factor. A value of 0 ("inside the head
## of the listener") is an invalid value and is forbidden.
## The default value of the minimum distance is 1.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``distance``: New minimum distance of the sound
proc `attenuation=`*(sound: Sound, attenuation: cfloat) {.
cdecl, importc: "sfSound_setAttenuation".}
## Set the attenuation factor of a sound
##
## The attenuation is a multiplicative factor which makes
## the sound more or less loud according to its distance
## from the listener. An attenuation of 0 will produce a
## non-attenuated sound, i.e. its volume will always be the same
## whether it is heard from near or from far. On the other hand,
## an attenuation value such as 100 will make the sound fade out
## very quickly as it gets further from the listener.
## The default value of the attenuation is 1.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``attenuation``: New attenuation factor of the sound
proc `playingOffset=`*(sound: Sound, timeOffset: Time) {.
cdecl, importc: "sfSound_setPlayingOffset".}
## Change the current playing position of a sound
##
## The playing position can be changed when the sound is
## either paused or playing.
##
## *Arguments*:
## - ``sound``: Sound object
## - ``timeOffset``: New playing position
proc pitch*(sound: Sound): cfloat {.
cdecl, importc: "sfSound_getPitch".}
## Get the pitch of a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Pitch of the sound
proc volume*(sound: Sound): cfloat {.
cdecl, importc: "sfSound_getVolume".}
## Get the volume of a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Volume of the sound, in the range [0, 100]
proc position*(sound: Sound): Vector3f {.
cdecl, importc: "sfSound_getPosition".}
## Get the 3D position of a sound in the audio scene
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Position of the sound in the world
proc relativeToListener*(sound: Sound): BoolInt {.
cdecl, importc: "sfSound_isRelativeToListener".}
## Tell whether a sound's position is relative to the
## listener or is absolute
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* True if the position is relative, False if it's absolute
proc minDistance*(sound: Sound): cfloat {.
cdecl, importc: "sfSound_getMinDistance".}
## Get the minimum distance of a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Minimum distance of the sound
proc attenuation*(sound: Sound): cfloat {.
cdecl, importc: "sfSound_getAttenuation".}
## Get the attenuation factor of a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Attenuation factor of the sound
proc playingOffset*(sound: Sound): Time {.
cdecl, importc: "sfSound_getPlayingOffset".}
## Get the current playing position of a sound
##
## *Arguments*:
## - ``sound``: Sound object
##
## *Returns:* Current playing position
#--- SFML/Audio/SoundBuffer ---#
proc newSoundBuffer*(filename: cstring): SoundBuffer {.
cdecl, importc: "sfSoundBuffer_createFromFile".}
## Create a new sound buffer and load it from a file
##
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``filename``: Path of the sound file to load
##
## *Returns:* A new SoundBuffer object (NULL if failed)
proc newSoundBuffer*(data: pointer, sizeInBytes: int): SoundBuffer {.
cdecl, importc: "sfSoundBuffer_createFromMemory".}
## Create a new sound buffer and load it from a file in memory
##
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``data``: Pointer to the file data in memory
## - ``sizeInBytes``: Size of the data to load, in bytes
##
## *Returns:* A new SoundBuffer object (NULL if failed)
proc newSoundBuffer*(stream: var InputStream): SoundBuffer {.
cdecl, importc: "sfSoundBuffer_createFromStream".}
## Create a new sound buffer and load it from a custom stream
##
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``stream``: Source stream to read from
##
## *Returns:* A new SoundBuffer object (NULL if failed)
proc newSoundBuffer*(samples: ptr int16, sampleCount: uint64, channelCount: cint, sampleRate: cint): SoundBuffer {.
cdecl, importc: "sfSoundBuffer_createFromSamples".}
## Create a new sound buffer and load it from an array of samples in memory
##
## The assumed format of the audio samples is 16 bits signed integer
## (Int16).
##
## *Arguments*:
## - ``samples``: Pointer to the array of samples in memory
## - ``sampleCount``: Number of samples in the array
## - ``channelCount``: Number of channels (1 = mono, 2 = stereo, ...)
## - ``sampleRate``: Sample rate (number of samples to play per second)
##
## *Returns:* A new SoundBuffer object (NULL if failed)
proc copy*(soundBuffer: SoundBuffer): SoundBuffer {.
cdecl, importc: "sfSoundBuffer_copy".}
## Create a new sound buffer by copying an existing one
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer to copy
##
## *Returns:* A new SoundBuffer object which is a copy of ``soundBuffer``
proc destroy*(soundBuffer: SoundBuffer) {.
cdecl, importc: "sfSoundBuffer_destroy".}
## Destroy a sound buffer
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer to destroy
proc saveToFile*(soundBuffer: SoundBuffer, filename: cstring): BoolInt {.
cdecl, importc: "sfSoundBuffer_saveToFile".}
## Save a sound buffer to an audio file
##
## Here is a complete list of all the supported audio formats:
## ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
## w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
## - ``filename``: Path of the sound file to write
##
## *Returns:* True if saving succeeded, False if it failed
proc samples*(soundBuffer: SoundBuffer): ptr int16 {.
cdecl, importc: "sfSoundBuffer_getSamples".}
## Get the array of audio samples stored in a sound buffer
##
## The format of the returned samples is 16 bits signed integer
## (Int16). The total number of samples in this array
## is given by the SoundBuffer_getSampleCount function.
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
##
## *Returns:* Read-only pointer to the array of sound samples
proc sampleCount*(soundBuffer: SoundBuffer): uint64 {.
cdecl, importc: "sfSoundBuffer_getSampleCount".}
## Get the number of samples stored in a sound buffer
##
## The array of samples can be accessed with the
## SoundBuffer_getSamples function.
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
##
## *Returns:* Number of samples
proc sampleRate*(soundBuffer: SoundBuffer): cint {.
cdecl, importc: "sfSoundBuffer_getSampleRate".}
## Get the sample rate of a sound buffer
##
## The sample rate is the number of samples played per second.
## The higher, the better the quality (for example, 44100
## samples/s is CD quality).
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
##
## *Returns:* Sample rate (number of samples per second)
proc channelCount*(soundBuffer: SoundBuffer): cint {.
cdecl, importc: "sfSoundBuffer_getChannelCount".}
## Get the number of channels used by a sound buffer
##
## If the sound is mono then the number of channels will
## be 1, 2 for stereo, etc.
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
##
## *Returns:* Number of channels
proc duration*(soundBuffer: SoundBuffer): Time {.
cdecl, importc: "sfSoundBuffer_getDuration".}
## Get the total duration of a sound buffer
##
## *Arguments*:
## - ``soundBuffer``: Sound buffer object
##
## *Returns:* Sound duration
#--- SFML/Audio/SoundBufferRecorder ---#
proc newSoundBufferRecorder*(): SoundBufferRecorder {.
cdecl, importc: "sfSoundBufferRecorder_create".}
## Create a new sound buffer recorder
##
## *Returns:* A new SoundBufferRecorder object (NULL if failed)
proc destroy*(soundBufferRecorder: SoundBufferRecorder) {.
cdecl, importc: "sfSoundBufferRecorder_destroy".}
## Destroy a sound buffer recorder
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder to destroy
proc start*(soundBufferRecorder: SoundBufferRecorder, sampleRate: cint): BoolInt {.
cdecl, importc: "sfSoundBufferRecorder_start".}
## Start the capture of a sound recorder recorder
##
## The ``sampleRate`` parameter defines the number of audio samples
## captured per second. The higher, the better the quality
## (for example, 44100 samples/sec is CD quality).
## This function uses its own thread so that it doesn't block
## the rest of the program while the capture runs.
## Please note that only one capture can happen at the same time.
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
## - ``sampleRate``: Desired capture rate, in number of samples per second
##
## *Returns:* True, if it was able to start recording
proc stop*(soundBufferRecorder: SoundBufferRecorder) {.
cdecl, importc: "sfSoundBufferRecorder_stop".}
## Stop the capture of a sound recorder
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
proc sampleRate*(soundBufferRecorder: SoundBufferRecorder): cint {.
cdecl, importc: "sfSoundBufferRecorder_getSampleRate".}
## Get the sample rate of a sound buffer recorder
##
## The sample rate defines the number of audio samples
## captured per second. The higher, the better the quality
## (for example, 44100 samples/sec is CD quality).
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
##
## *Returns:* Sample rate, in samples per second
proc buffer*(soundBufferRecorder: SoundBufferRecorder): SoundBuffer {.
cdecl, importc: "sfSoundBufferRecorder_getBuffer".}
## Get the sound buffer containing the captured audio data
##
## The sound buffer is valid only after the capture has ended.
## This function provides a read-only access to the internal
## sound buffer, but it can be copied if you need to
## make any modification to it.
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
##
## *Returns:* Read-only access to the sound buffer
proc `device=`*(soundBufferRecorder: SoundBufferRecorder, name: cstring): BoolInt {.
cdecl, importc: "sfSoundBufferRecorder_setDevice".}
## Set the audio capture device
##
## This function sets the audio capture device to the device
## with the given name. It can be called on the fly (i.e:
## while recording). If you do so while recording and
## opening the device fails, it stops the recording.
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
## - ``name``: The name of the audio capture device
##
## *Returns:* True, if it was able to set the requested device
proc device*(soundBufferRecorder: SoundBufferRecorder): cstring {.
cdecl, importc: "sfSoundBufferRecorder_getDevice".}
## Get the name of the current audio capture device
##
## *Arguments*:
## - ``soundBufferRecorder``: Sound buffer recorder object
##
## *Returns:* The name of the current audio capture device
#--- SFML/Audio/SoundRecorder ---#
type SoundRecorderStartCallback* = proc(p1: pointer): BoolInt {.cdecl.}
type SoundRecorderProcessCallback* = proc(p1: ptr int16; p2: int; p3: pointer): BoolInt {.cdecl.}
type SoundRecorderStopCallback* = proc(p1: pointer): void {.cdecl.}
proc newSoundRecorder*(onStart: SoundRecorderStartCallback, onProcess: SoundRecorderProcessCallback, onStop: SoundRecorderStopCallback, userData: pointer): SoundRecorder {.
cdecl, importc: "sfSoundRecorder_create".}
## Construct a new sound recorder from callback functions
##
## *Arguments*:
## - ``onStart``: Callback function which will be called when a new capture starts (can be NULL)
## - ``onProcess``: Callback function which will be called each time there's audio data to process
## - ``onStop``: Callback function which will be called when the current capture stops (can be NULL)
## - ``userData``: Data to pass to the callback function (can be NULL)
##
## *Returns:* A new SoundRecorder object (NULL if failed)
proc destroy*(soundRecorder: SoundRecorder) {.
cdecl, importc: "sfSoundRecorder_destroy".}
## Destroy a sound recorder
##
## *Arguments*:
## - ``soundRecorder``: Sound recorder to destroy
proc start*(soundRecorder: SoundRecorder, sampleRate: cint): BoolInt {.
cdecl, importc: "sfSoundRecorder_start".}
## Start the capture of a sound recorder
##
## The ``sampleRate`` parameter defines the number of audio samples
## captured per second. The higher, the better the quality
## (for example, 44100 samples/sec is CD quality).
## This function uses its own thread so that it doesn't block
## the rest of the program while the capture runs.
## Please note that only one capture can happen at the same time.
##
## *Arguments*:
## - ``soundRecorder``: Sound recorder object
## - ``sampleRate``: Desired capture rate, in number of samples per second