Debian Codegraph @

tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim

raw
1 import
2 sfml
3 const
4 Lib = "libcsfml-audio.so.2.0"
5 type
6 PMusic* = ptr TMusic
7 TMusic* {.pure, final.} = object
8 PSound* = ptr TSound
9 TSound* {.pure, final.} = object
10 PSoundBuffer* = ptr TSoundBuffer
11 TSoundBuffer* {.pure, final.} = object
12 PSoundBufferRecorder* = ptr TSoundBufferRecorder
13 TSoundBufferRecorder* {.pure, final.} = object
14 PSoundRecorder* = ptr TSoundRecorder
15 TSoundRecorder* {.pure, final.} = object
16 PSoundStream* = ptr TSoundStream
17 TSoundStream* {.pure, final.} = object
18 TSoundStatus* {.size: sizeof(cint).} = enum
19 Stopped, Paused, Playing
20
21 proc newMusic*(filename: cstring): PMusic {.
22 cdecl, importc: "sfMusic_createFromFile", dynlib: Lib.}
23 proc newMusic*(data: pointer, size: cint): PMusic {.
24 cdecl, importc: "sfMusic_createFromMemory", dynlib: Lib.}
25 proc newMusic*(stream: PInputStream): PMusic {.
26 cdecl, importc: "sfMusic_createFromStream", dynlib: Lib.}
27 proc destroy*(music: PMusic) {.
28 cdecl, importc: "sfMusic_destroy", dynlib: Lib.}
29 proc setLoop*(music: PMusic, loop: bool) {.
30 cdecl, importc: "sfMusic_setLoop", dynlib: Lib.}
31 proc getLoop*(music: PMusic): bool {.
32 cdecl, importc: "sfMusic_getLoop", dynlib: Lib.}
33 proc getDuration*(music: PMusic): TTime {.
34 cdecl, importc: "sfMusic_getDuration", dynlib: Lib.}
35 proc play*(music: PMusic) {.
36 cdecl, importc: "sfMusic_play", dynlib: Lib.}
37 proc pause*(music: PMusic) {.
38 cdecl, importc: "sfMusic_pause", dynlib: Lib.}
39 proc stop*(music: PMusic) {.
40 cdecl, importc: "sfMusic_stop", dynlib: Lib.}
41 proc getChannelCount*(music: PMusic): cint {.
42 cdecl, importc: "sfMusic_getChannelCount", dynlib: Lib.}
43 proc getSampleRate*(music: PMusic): cint {.
44 cdecl, importc: "sfMusic_getSampleRate", dynlib: Lib.}
45 proc getStatus*(music: PMusic): TSoundStatus {.
46 cdecl, importc: "sfMusic_getStatus", dynlib: Lib.}
47 proc getPlayingOffset*(music: PMusic): TTime {.
48 cdecl, importc: "sfMusic_getPlayingOffset", dynlib: Lib.}
49 proc setPitch*(music: PMusic, pitch: cfloat) {.
50 cdecl, importc: "sfMusic_setPitch", dynlib: Lib.}
51 proc setVolume*(music: PMusic, volume: float) {.
52 cdecl, importc: "sfMusic_setVolume", dynlib: Lib.}
53 proc setPosition*(music: PMusic, position: TVector3f) {.
54 cdecl, importc: "sfMusic_setPosition", dynlib: Lib.}
55 proc setRelativeToListener*(music: PMusic, relative: bool) {.
56 cdecl, importc: "sfMusic_setRelativeToListener", dynlib: Lib.}
57 proc setMinDistance*(music: PMusic, distance: cfloat) {.
58 cdecl, importc: "sfMusic_setMinDistance", dynlib: Lib.}
59 proc setAttenuation*(music: PMusic, attenuation: cfloat) {.
60 cdecl, importc: "sfMusic_setAttenuation", dynlib: Lib.}
61 proc setPlayingOffset*(music: PMusic, time: TTime) {.
62 cdecl, importc: "sfMusic_setPlayingOffset", dynlib: Lib.}
63 proc getPitch*(music: PMusic): cfloat {.
64 cdecl, importc: "sfMusic_getPitch", dynlib: Lib.}
65 proc getVolume*(music: PMusic): cfloat {.
66 cdecl, importc: "sfMusic_getVolume", dynlib: Lib.}
67 proc getPosition*(music: PMusic): TVector3f {.
68 cdecl, importc: "sfMusic_getPosition", dynlib: Lib.}
69 proc isRelativeToListener*(music: PMusic): bool {.
70 cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.}
71 proc getMinDistance*(music: PMusic): cfloat {.
72 cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.}
73 proc getAttenuation*(music: PMusic): cfloat {.
74 cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.}
75
76 #/ \brief Create a new sound
77 proc newSound*(): PSound{.
78 cdecl, importc: "sfSound_create", dynlib: Lib.}
79 #//////////////////////////////////////////////////////////
80 #/ \brief Create a new sound by copying an existing one
81 #/
82 #/ \param sound Sound to copy
83 #/
84 #/ \return A new sfSound object which is a copy of \a sound
85 #/
86 #//////////////////////////////////////////////////////////
87 proc copy*(sound: PSound): PSound{.
88 cdecl, importc: "sfSound_copy", dynlib: Lib.}
89 #//////////////////////////////////////////////////////////
90 #/ \brief Destroy a sound
91 proc destroy*(sound: PSound){.
92 cdecl, importc: "sfSound_destroy", dynlib: Lib.}
93 #//////////////////////////////////////////////////////////
94 #/ \brief Start or resume playing a sound
95 #/
96 #/ This function starts the sound if it was stopped, resumes
97 #/ it if it was paused, and restarts it from beginning if it
98 #/ was it already playing.
99 #/ This function uses its own thread so that it doesn't block
100 #/ the rest of the program while the sound is played.
101 proc play*(sound: PSound){.
102 cdecl, importc: "sfSound_play", dynlib: Lib.}
103 #//////////////////////////////////////////////////////////
104 #/ This function pauses the sound if it was playing,
105 #/ otherwise (sound already paused or stopped) it has no effect.
106 proc pause*(sound: PSound){.
107 cdecl, importc: "sfSound_pause", dynlib: Lib.}
108 #//////////////////////////////////////////////////////////
109 #/ This function stops the sound if it was playing or paused,
110 #/ and does nothing if it was already stopped.
111 #/ It also resets the playing position (unlike sfSound_pause).
112 proc stop*(sound: PSound){.
113 cdecl, importc: "sfSound_stop", dynlib: Lib.}
114 #//////////////////////////////////////////////////////////
115 #/ It is important to note that the sound buffer is not copied,
116 #/ thus the sfSoundBuffer object must remain alive as long
117 #/ as it is attached to the sound.
118 proc setBuffer*(sound: PSound; buffer: PSoundBuffer){.
119 cdecl, importc: "sfSound_setBuffer", dynlib: Lib.}
120 #//////////////////////////////////////////////////////////
121 #/ \brief Get the audio buffer attached to a sound
122 proc getBuffer*(sound: PSound): PSoundBuffer{.
123 cdecl, importc: "sfSound_getBuffer", dynlib: Lib.}
124 #//////////////////////////////////////////////////////////
125 #/ \brief Set whether or not a sound should loop after reaching the end
126 #/
127 #/ If set, the sound will restart from beginning after
128 #/ reaching the end and so on, until it is stopped or
129 #/ sfSound_setLoop(sound, sfFalse) is called.
130 #/ The default looping state for sounds is false.
131 proc setLoop*(sound: PSound; loop: bool){.
132 cdecl, importc: "sfSound_setLoop", dynlib: Lib.}
133 #//////////////////////////////////////////////////////////
134 #/ \brief Tell whether or not a soud is in loop mode
135 proc getLoop*(sound: PSound): bool {.
136 cdecl, importc: "sfSound_getLoop", dynlib: Lib.}
137 #//////////////////////////////////////////////////////////
138 #/ \brief Get the current status of a sound (stopped, paused, playing)
139 proc getStatus*(sound: PSound): TSoundStatus{.
140 cdecl, importc: "sfSound_getStatus", dynlib: Lib.}
141 #//////////////////////////////////////////////////////////
142 #/ \brief Set the pitch of a sound
143 #/
144 #/ The pitch represents the perceived fundamental frequency
145 #/ of a sound; thus you can make a sound more acute or grave
146 #/ by changing its pitch. A side effect of changing the pitch
147 #/ is to modify the playing speed of the sound as well.
148 #/ The default value for the pitch is 1.
149 proc setPitch*(sound: PSound; pitch: cfloat){.
150 cdecl, importc: "sfSound_setPitch", dynlib: Lib.}
151 #//////////////////////////////////////////////////////////
152 #/ \brief Set the volume of a sound
153 #/
154 #/ The volume is a value between 0 (mute) and 100 (full volume).
155 #/ The default value for the volume is 100.
156 proc setVolume*(sound: PSound; volume: cfloat){.
157 cdecl, importc: "sfSound_setVolume", dynlib: Lib.}
158 #//////////////////////////////////////////////////////////
159 #/ \brief Set the 3D position of a sound in the audio scene
160 #/
161 #/ Only sounds with one channel (mono sounds) can be
162 #/ spatialized.
163 #/ The default position of a sound is (0, 0, 0).
164 proc setPosition*(sound: PSound; position: TVector3f){.
165 cdecl, importc: "sfSound_setPosition", dynlib: Lib.}
166 #//////////////////////////////////////////////////////////
167 #/ \brief Make the sound's position relative to the listener or absolute
168 #/
169 #/ Making a sound relative to the listener will ensure that it will always
170 #/ be played the same way regardless the position of the listener.
171 #/ This can be useful for non-spatialized sounds, sounds that are
172 #/ produced by the listener, or sounds attached to it.
173 #/ The default value is false (position is absolute).
174 proc setRelativeToListener*(sound: PSound; relative: bool){.
175 cdecl, importc: "sfSound_setRelativeToListener", dynlib: Lib.}
176 #//////////////////////////////////////////////////////////
177 #/ \brief Set the minimum distance of a sound
178 #/
179 #/ The "minimum distance" of a sound is the maximum
180 #/ distance at which it is heard at its maximum volume. Further
181 #/ than the minimum distance, it will start to fade out according
182 #/ to its attenuation factor. A value of 0 ("inside the head
183 #/ of the listener") is an invalid value and is forbidden.
184 #/ The default value of the minimum distance is 1.
185 proc setMinDistance*(sound: PSound; distance: cfloat){.
186 cdecl, importc: "sfSound_setMinDistance", dynlib: Lib.}
187 #//////////////////////////////////////////////////////////
188 #/ \brief Set the attenuation factor of a sound
189 #/
190 #/ The attenuation is a multiplicative factor which makes
191 #/ the sound more or less loud according to its distance
192 #/ from the listener. An attenuation of 0 will produce a
193 #/ non-attenuated sound, i.e. its volume will always be the same
194 #/ whether it is heard from near or from far. On the other hand,
195 #/ an attenuation value such as 100 will make the sound fade out
196 #/ very quickly as it gets further from the listener.
197 #/ The default value of the attenuation is 1.
198 proc setAttenuation*(sound: PSound; attenuation: cfloat){.
199 cdecl, importc: "sfSound_setAttenuation", dynlib: Lib.}
200 #//////////////////////////////////////////////////////////
201 #/ \brief Change the current playing position of a sound
202 #/
203 #/ The playing position can be changed when the sound is
204 #/ either paused or playing.
205 proc setPlayingOffset*(sound: PSound; timeOffset: sfml.TTime){.
206 cdecl, importc: "sfSound_setPlayingOffset", dynlib: Lib.}
207 #//////////////////////////////////////////////////////////
208 #/ \brief Get the pitch of a sound
209 proc getPitch*(sound: PSound): cfloat{.
210 cdecl, importc: "sfSound_getPitch", dynlib: Lib.}
211 #//////////////////////////////////////////////////////////
212 #/ \brief Get the volume of a sound
213 proc getVolume*(sound: PSound): cfloat{.
214 cdecl, importc: "sfSound_getVolume", dynlib: Lib.}
215 #//////////////////////////////////////////////////////////
216 #/ \brief Get the 3D position of a sound in the audio scene
217 proc getPosition*(sound: PSound): TVector3f{.
218 cdecl, importc: "sfSound_getPosition", dynlib: Lib.}
219 #//////////////////////////////////////////////////////////
220 #/ \brief Tell whether a sound's position is relative to the
221 #/ listener or is absolute
222 proc isRelativeToListener*(sound: PSound): bool{.
223 cdecl, importc: "sfSound_isRelativeToListener", dynlib: Lib.}
224 #//////////////////////////////////////////////////////////
225 #/ \brief Get the minimum distance of a sound
226 proc getMinDistance*(sound: PSound): cfloat{.
227 cdecl, importc: "sfSound_getMinDistance", dynlib: Lib.}
228 #//////////////////////////////////////////////////////////
229 #/ \brief Get the attenuation factor of a sound
230 proc getAttenuation*(sound: PSound): cfloat{.
231 cdecl, importc: "sfSound_getAttenuation", dynlib: Lib.}
232 #//////////////////////////////////////////////////////////
233 #/ \brief Get the current playing position of a sound
234 proc getPlayingOffset*(sound: PSound): TTime{.
235 cdecl, importc: "sfSound_getPlayingOffset", dynlib: Lib.}
236
237 #//////////////////////////////////////////////////////////
238 # Headers
239 #//////////////////////////////////////////////////////////
240 #//////////////////////////////////////////////////////////
241 #/ \brief Create a new sound buffer and load it from a file
242 #/
243 #/ Here is a complete list of all the supported audio formats:
244 #/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
245 #/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
246 #/
247 #/ \param filename Path of the sound file to load
248 #/
249 #/ \return A new sfSoundBuffer object (NULL if failed)
250 #/
251 #//////////////////////////////////////////////////////////
252 proc newSoundBuffer*(filename: cstring): PSoundBuffer{.
253 cdecl, importc: "sfSoundBuffer_createFromFile", dynlib: Lib.}
254 #//////////////////////////////////////////////////////////
255 #/ \brief Create a new sound buffer and load it from a file in memory
256 #/
257 #/ Here is a complete list of all the supported audio formats:
258 #/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
259 #/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
260 #/
261 #/ \param data Pointer to the file data in memory
262 #/ \param sizeInBytes Size of the data to load, in bytes
263 #/
264 #/ \return A new sfSoundBuffer object (NULL if failed)
265 #/
266 #//////////////////////////////////////////////////////////
267 proc newSoundBuffer*(data: pointer; sizeInBytes: cint): PSoundBuffer{.
268 cdecl, importc: "sfSoundBuffer_createFromMemory", dynlib: Lib.}
269 #//////////////////////////////////////////////////////////
270 #/ \brief Create a new sound buffer and load it from a custom stream
271 #/
272 #/ Here is a complete list of all the supported audio formats:
273 #/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
274 #/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
275 #/
276 #/ \param stream Source stream to read from
277 #/
278 #/ \return A new sfSoundBuffer object (NULL if failed)
279 #/
280 #//////////////////////////////////////////////////////////
281 proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{.
282 cdecl, importc: "sfSoundBuffer_createFromStream", dynlib: Lib.}
283 #//////////////////////////////////////////////////////////
284 #/ \brief Create a new sound buffer and load it from an array of samples in memory
285 #/
286 #/ The assumed format of the audio samples is 16 bits signed integer
287 #/ (sfint16).
288 #/
289 #/ \param samples Pointer to the array of samples in memory
290 #/ \param sampleCount Number of samples in the array
291 #/ \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
292 #/ \param sampleRate Sample rate (number of samples to play per second)
293 #/
294 #/ \return A new sfSoundBuffer object (NULL if failed)
295 #/
296 #//////////////////////////////////////////////////////////
297 proc createFromSamples*(samples: ptr int16; sampleCount: cuint;
298 channelCount: cuint; sampleRate: cuint): PSoundBuffer{.
299 cdecl, importc: "sfSoundBuffer_createFromSamples", dynlib: Lib.}
300 #//////////////////////////////////////////////////////////
301 #/ \brief Create a new sound buffer by copying an existing one
302 #/
303 #/ \param soundBuffer Sound buffer to copy
304 #/
305 #/ \return A new sfSoundBuffer object which is a copy of \a soundBuffer
306 #/
307 #//////////////////////////////////////////////////////////
308 proc copy*(soundBuffer: PSoundBuffer): PSoundBuffer{.
309 cdecl, importc: "sfSoundBuffer_copy", dynlib: Lib.}
310 #//////////////////////////////////////////////////////////
311 #/ \brief Destroy a sound buffer
312 #/
313 #/ \param soundBuffer Sound buffer to destroy
314 #/
315 #//////////////////////////////////////////////////////////
316 proc destroy*(soundBuffer: PSoundBuffer){.
317 cdecl, importc: "sfSoundBuffer_destroy", dynlib: Lib.}
318 #//////////////////////////////////////////////////////////
319 #/ \brief Save a sound buffer to an audio file
320 #/
321 #/ Here is a complete list of all the supported audio formats:
322 #/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
323 #/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
324 #/
325 #/ \param soundBuffer Sound buffer object
326 #/ \param filename Path of the sound file to write
327 #/
328 #/ \return sfTrue if saving succeeded, sfFalse if it failed
329 #/
330 #//////////////////////////////////////////////////////////
331 proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {.
332 cdecl, importc: "sfSoundBuffer_saveToFile", dynlib: Lib.}
333 #//////////////////////////////////////////////////////////
334 #/ \brief Get the array of audio samples stored in a sound buffer
335 #/
336 #/ The format of the returned samples is 16 bits signed integer
337 #/ (sfint16). The total number of samples in this array
338 #/ is given by the sfSoundBuffer_getSampleCount function.
339 #/
340 #/ \param soundBuffer Sound buffer object
341 #/
342 #/ \return Read-only pointer to the array of sound samples
343 #/
344 #//////////////////////////////////////////////////////////
345 proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr int16{.
346 cdecl, importc: "sfSoundBuffer_getSamples", dynlib: Lib.}
347 #//////////////////////////////////////////////////////////
348 #/ \brief Get the number of samples stored in a sound buffer
349 #/
350 #/ The array of samples can be accessed with the
351 #/ sfSoundBuffer_getSamples function.
352 proc getSampleCount*(soundBuffer: PSoundBuffer): cint{.
353 cdecl, importc: "sfSoundBuffer_getSampleCount", dynlib: Lib.}
354 #//////////////////////////////////////////////////////////
355 #/ \brief Get the sample rate of a sound buffer
356 #/
357 #/ The sample rate is the number of samples played per second.
358 #/ The higher, the better the quality (for example, 44100
359 #/ samples/s is CD quality).
360 proc getSampleRate*(soundBuffer: PSoundBuffer): cuint{.
361 cdecl, importc: "sfSoundBuffer_getSampleRate", dynlib: Lib.}
362 #//////////////////////////////////////////////////////////
363 #/ \brief Get the number of channels used by a sound buffer
364 #/
365 #/ If the sound is mono then the number of channels will
366 #/ be 1, 2 for stereo, etc.
367 proc getChannelCount*(soundBuffer: PSoundBuffer): cuint{.
368 cdecl, importc: "sfSoundBuffer_getChannelCount", dynlib: Lib.}
369 #//////////////////////////////////////////////////////////
370 #/ \brief Get the total duration of a sound buffer
371 #/
372 #/ \param soundBuffer Sound buffer object
373 #/
374 #/ \return Sound duration
375 #/
376 #//////////////////////////////////////////////////////////
377 proc getDuration*(soundBuffer: PSoundBuffer): TTime{.
378 cdecl, importc: "sfSoundBuffer_getDuration", dynlib: Lib.}
379
380 #//////////////////////////////////////////////////////////
381 #/ \brief Change the global volume of all the sounds and musics
382 #/
383 #/ The volume is a number between 0 and 100; it is combined with
384 #/ the individual volume of each sound / music.
385 #/ The default value for the volume is 100 (maximum).
386 #/
387 #/ \param volume New global volume, in the range [0, 100]
388 #/
389 #//////////////////////////////////////////////////////////
390 proc listenerSetGlobalVolume*(volume: cfloat){.
391 cdecl, importc: "sfListener_setGlobalVolume", dynlib: Lib.}
392 #//////////////////////////////////////////////////////////
393 #/ \brief Get the current value of the global volume
394 #/
395 #/ \return Current global volume, in the range [0, 100]
396 #/
397 #//////////////////////////////////////////////////////////
398 proc listenerGetGlobalVolume*(): cfloat{.
399 cdecl, importc: "sfListener_getGlobalVolume", dynlib: Lib.}
400 #//////////////////////////////////////////////////////////
401 #/ \brief Set the position of the listener in the scene
402 #/
403 #/ The default listener's position is (0, 0, 0).
404 #/
405 #/ \param position New position of the listener
406 #/
407 #//////////////////////////////////////////////////////////
408 proc listenerSetPosition*(position: TVector3f){.
409 cdecl, importc: "sfListener_setPosition", dynlib: Lib.}
410 #//////////////////////////////////////////////////////////
411 #/ \brief Get the current position of the listener in the scene
412 #/
413 #/ \return The listener's position
414 #/
415 #//////////////////////////////////////////////////////////
416 proc listenerGetPosition*(): TVector3f{.
417 cdecl, importc: "sfListener_getPosition", dynlib: Lib.}
418 #//////////////////////////////////////////////////////////
419 #/ \brief Set the orientation of the listener in the scene
420 #/
421 #/ The orientation defines the 3D axes of the listener
422 #/ (left, up, front) in the scene. The orientation vector
423 #/ doesn't have to be normalized.
424 #/ The default listener's orientation is (0, 0, -1).
425 #/
426 #/ \param position New direction of the listener
427 #/
428 #//////////////////////////////////////////////////////////
429 proc listenerSetDirection*(orientation: TVector3f){.
430 cdecl, importc: "sfListener_setDirection", dynlib: Lib.}
431 #//////////////////////////////////////////////////////////
432 #/ \brief Get the current orientation of the listener in the scene
433 #/
434 #/ \return The listener's direction
435 #/
436 #//////////////////////////////////////////////////////////
437 proc listenerGetDirection*(): TVector3f{.
438 cdecl, importc: "sfListener_getDirection", dynlib: Lib.}
439
440 type
441 TSoundRecorderStartCallback* = proc (a2: pointer): bool {.cdecl.}
442 #/< Type of the callback used when starting a capture
443 TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint;
444 a4: pointer): bool {.cdecl.}
445 #/< Type of the callback used to process audio data
446 TSoundRecorderStopCallback* = proc (a2: pointer){.cdecl.}
447 #/< Type of the callback used when stopping a capture
448 #//////////////////////////////////////////////////////////
449 #/ \brief Construct a new sound recorder from callback functions
450 #/
451 #/ \param onStart Callback function which will be called when a new capture starts (can be NULL)
452 #/ \param onProcess Callback function which will be called each time there's audio data to process
453 #/ \param onStop Callback function which will be called when the current capture stops (can be NULL)
454 #/ \param userData Data to pass to the callback function (can be NULL)
455 #/
456 #/ \return A new sfSoundRecorder object (NULL if failed)
457 #/
458 #//////////////////////////////////////////////////////////
459 proc newSoundRecorder*(onStart: TSoundRecorderStartCallback;
460 onProcess: TSoundRecorderProcessCallback;
461 onStop: TSoundRecorderStopCallback;
462 userData: pointer = nil): PSoundRecorder{.
463 cdecl, importc: "sfSoundRecorder_create", dynlib: Lib.}
464 #//////////////////////////////////////////////////////////
465 #/ \brief Destroy a sound recorder
466 #/
467 #/ \param soundRecorder Sound recorder to destroy
468 #/
469 #//////////////////////////////////////////////////////////
470 proc destroy*(soundRecorder: PSoundRecorder){.
471 cdecl, importc: "sfSoundRecorder_destroy", dynlib: Lib.}
472 #//////////////////////////////////////////////////////////
473 #/ \brief Start the capture of a sound recorder
474 #/
475 #/ The \a sampleRate parameter defines the number of audio samples
476 #/ captured per second. The higher, the better the quality
477 #/ (for example, 44100 samples/sec is CD quality).
478 #/ This function uses its own thread so that it doesn't block
479 #/ the rest of the program while the capture runs.
480 #/ Please note that only one capture can happen at the same time.
481 #/
482 #/ \param soundRecorder Sound recorder object
483 #/ \param sampleRate Desired capture rate, in number of samples per second
484 #/
485 #//////////////////////////////////////////////////////////
486 proc start*(soundRecorder: PSoundRecorder; sampleRate: cuint){.
487 cdecl, importc: "sfSoundRecorder_start", dynlib: Lib.}
488 #//////////////////////////////////////////////////////////
489 #/ \brief Stop the capture of a sound recorder
490 #/
491 #/ \param soundRecorder Sound recorder object
492 #/
493 #//////////////////////////////////////////////////////////
494 proc stop*(soundRecorder: PSoundRecorder){.
495 cdecl, importc: "sfSoundRecorder_stop", dynlib: Lib.}
496 #//////////////////////////////////////////////////////////
497 #/ \brief Get the sample rate of a sound recorder
498 #/
499 #/ The sample rate defines the number of audio samples
500 #/ captured per second. The higher, the better the quality
501 #/ (for example, 44100 samples/sec is CD quality).
502 #/
503 #/ \param soundRecorder Sound recorder object
504 #/
505 #/ \return Sample rate, in samples per second
506 #/
507 #//////////////////////////////////////////////////////////
508 proc getSampleRate*(soundRecorder: PSoundRecorder): cuint{.
509 cdecl, importc: "sfSoundRecorder_getSampleRate", dynlib: Lib.}
510 #//////////////////////////////////////////////////////////
511 #/ \brief Check if the system supports audio capture
512 #/
513 #/ This function should always be called before using
514 #/ the audio capture features. If it returns false, then
515 #/ any attempt to use sfSoundRecorder will fail.
516 #/
517 #/ \return sfTrue if audio capture is supported, sfFalse otherwise
518 #/
519 #//////////////////////////////////////////////////////////
520 proc soundRecorderIsAvailable*(): bool {.
521 cdecl, importc: "sfSoundRecorder_isAvailable", dynlib: Lib.}
522
523 #//////////////////////////////////////////////////////////
524 #/ \brief Create a new sound buffer recorder
525 #/
526 #/ \return A new sfSoundBufferRecorder object (NULL if failed)
527 #/
528 #//////////////////////////////////////////////////////////
529 proc newSoundBufferRecorder*(): PSoundBufferRecorder{.
530 cdecl, importc: "sfSoundBufferRecorder_create", dynlib: Lib.}
531 #//////////////////////////////////////////////////////////
532 #/ \brief Destroy a sound buffer recorder
533 #/
534 #/ \param soundBufferRecorder Sound buffer recorder to destroy
535 #/
536 #//////////////////////////////////////////////////////////
537 proc destroy*(soundBufferRecorder: PSoundBufferRecorder){.
538 cdecl, importc: "sfSoundBufferRecorder_destroy", dynlib: Lib.}
539 #//////////////////////////////////////////////////////////
540 #/ \brief Start the capture of a sound recorder recorder
541 #/
542 #/ The \a sampleRate parameter defines the number of audio samples
543 #/ captured per second. The higher, the better the quality
544 #/ (for example, 44100 samples/sec is CD quality).
545 #/ This function uses its own thread so that it doesn't block
546 #/ the rest of the program while the capture runs.
547 #/ Please note that only one capture can happen at the same time.
548 #/
549 #/ \param soundBufferRecorder Sound buffer recorder object
550 #/ \param sampleRate Desired capture rate, in number of samples per second
551 #/
552 #//////////////////////////////////////////////////////////
553 proc start*(soundBufferRecorder: PSoundBufferRecorder; sampleRate: cuint){.
554 cdecl, importc: "sfSoundBufferRecorder_start", dynlib: Lib.}
555 #//////////////////////////////////////////////////////////
556 #/ \brief Stop the capture of a sound recorder
557 #/
558 #/ \param soundBufferRecorder Sound buffer recorder object
559 #/
560 #//////////////////////////////////////////////////////////
561 proc stop*(soundBufferRecorder: PSoundBufferRecorder){.
562 cdecl, importc: "sfSoundBufferRecorder_stop", dynlib: Lib.}
563 #//////////////////////////////////////////////////////////
564 #/ \brief Get the sample rate of a sound buffer recorder
565 #/
566 #/ The sample rate defines the number of audio samples
567 #/ captured per second. The higher, the better the quality
568 #/ (for example, 44100 samples/sec is CD quality).
569 #/
570 #/ \param soundBufferRecorder Sound buffer recorder object
571 #/
572 #/ \return Sample rate, in samples per second
573 #/
574 #//////////////////////////////////////////////////////////
575 proc getSampleRate*(soundBufferRecorder: PSoundBufferRecorder): cuint{.
576 cdecl, importc: "sfSoundBufferRecorder_getSampleRate", dynlib: Lib.}
577 #//////////////////////////////////////////////////////////
578 #/ \brief Get the sound buffer containing the captured audio data
579 #/
580 #/ The sound buffer is valid only after the capture has ended.
581 #/ This function provides a read-only access to the internal
582 #/ sound buffer, but it can be copied if you need to
583 #/ make any modification to it.
584 #/
585 #/ \param soundBufferRecorder Sound buffer recorder object
586 #/
587 #/ \return Read-only access to the sound buffer
588 #/
589 #//////////////////////////////////////////////////////////
590 proc getBuffer*(soundBufferRecorder: PSoundBufferRecorder): PSoundBuffer{.
591 cdecl, importc: "sfSoundBufferRecorder_getBuffer", dynlib: Lib.}
592
593
594 #//////////////////////////////////////////////////////////
595 #/ \brief defines the data to fill by the OnGetData callback
596 #/
597 #//////////////////////////////////////////////////////////
598 type
599 PSoundStreamChunk* = ptr TSoundStreamChunk
600 TSoundStreamChunk*{.pure, final.} = object
601 samples*: ptr int16 #/< Pointer to the audio samples
602 sampleCount*: cuint #/< Number of samples pointed by Samples
603
604 TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk;
605 a3: pointer): bool{.cdecl.}
606 #/< Type of the callback used to get a sound stream data
607 TSoundStreamSeekCallback* = proc (a2: TTime; a3: pointer){.cdecl.}
608 #/< Type of the callback used to seek in a sound stream
609 #//////////////////////////////////////////////////////////
610 #/ \brief Create a new sound stream
611 #/
612 #/ \param onGetData Function called when the stream needs more data (can't be NULL)
613 #/ \param onSeek Function called when the stream seeks (can't be NULL)
614 #/ \param channelCount Number of channels to use (1 = mono, 2 = stereo)
615 #/ \param sampleRate Sample rate of the sound (44100 = CD quality)
616 #/ \param userData Data to pass to the callback functions
617 #/
618 #/ \return A new sfSoundStream object
619 #/
620 #//////////////////////////////////////////////////////////
621 proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback;
622 channelCount: cuint; sampleRate: cuint; userData: pointer): PSoundStream{.
623 cdecl, importc: "sfSoundStream_create", dynlib: Lib.}
624 #//////////////////////////////////////////////////////////
625 #/ \brief Destroy a sound stream
626 #/
627 #/ \param soundStream Sound stream to destroy
628 #/
629 #//////////////////////////////////////////////////////////
630 proc destroy*(soundStream: PSoundStream){.
631 cdecl, importc: "sfSoundStream_destroy", dynlib: Lib.}
632 #//////////////////////////////////////////////////////////
633 #/ \brief Start or resume playing a sound stream
634 #/
635 #/ This function starts the stream if it was stopped, resumes
636 #/ it if it was paused, and restarts it from beginning if it
637 #/ was it already playing.
638 #/ This function uses its own thread so that it doesn't block
639 #/ the rest of the program while the music is played.
640 #/
641 #/ \param soundStream Sound stream object
642 #/
643 #//////////////////////////////////////////////////////////
644 proc play*(soundStream: PSoundStream){.
645 cdecl, importc: "sfSoundStream_play", dynlib: Lib.}
646 #//////////////////////////////////////////////////////////
647 #/ \brief Pause a sound stream
648 #/
649 #/ This function pauses the stream if it was playing,
650 #/ otherwise (stream already paused or stopped) it has no effect.
651 #/
652 #/ \param soundStream Sound stream object
653 #/
654 #//////////////////////////////////////////////////////////
655 proc pause*(soundStream: PSoundStream){.
656 cdecl, importc: "sfSoundStream_pause", dynlib: Lib.}
657 #//////////////////////////////////////////////////////////
658 #/ \brief Stop playing a sound stream
659 #/
660 #/ This function stops the stream if it was playing or paused,
661 #/ and does nothing if it was already stopped.
662 #/ It also resets the playing position (unlike sfSoundStream_pause).
663 #/
664 #/ \param soundStream Sound stream object
665 #/
666 #//////////////////////////////////////////////////////////
667 proc stop*(soundStream: PSoundStream){.
668 cdecl, importc: "sfSoundStream_stop", dynlib: Lib.}
669 #//////////////////////////////////////////////////////////
670 #/ \brief Get the current status of a sound stream (stopped, paused, playing)
671 #/
672 #/ \param soundStream Sound stream object
673 #/
674 #/ \return Current status
675 #/
676 #//////////////////////////////////////////////////////////
677 proc getStatus*(soundStream: PSoundStream): TSoundStatus{.
678 cdecl, importc: "sfSoundStream_getStatus", dynlib: Lib.}
679 #//////////////////////////////////////////////////////////
680 #/ \brief Return the number of channels of a sound stream
681 #/
682 #/ 1 channel means a mono sound, 2 means stereo, etc.
683 #/
684 #/ \param soundStream Sound stream object
685 #/
686 #/ \return Number of channels
687 #/
688 #//////////////////////////////////////////////////////////
689 proc getChannelCount*(soundStream: PSoundStream): cuint{.
690 cdecl, importc: "sfSoundStream_getChannelCount", dynlib: Lib.}
691 #//////////////////////////////////////////////////////////
692 #/ \brief Get the sample rate of a sound stream
693 #/
694 #/ The sample rate is the number of audio samples played per
695 #/ second. The higher, the better the quality.
696 #/
697 #/ \param soundStream Sound stream object
698 #/
699 #/ \return Sample rate, in number of samples per second
700 #/
701 #//////////////////////////////////////////////////////////
702 proc getSampleRate*(soundStream: PSoundStream): cuint{.
703 cdecl, importc: "sfSoundStream_getSampleRate", dynlib: Lib.}
704 #//////////////////////////////////////////////////////////
705 #/ \brief Set the pitch of a sound stream
706 #/
707 #/ The pitch represents the perceived fundamental frequency
708 #/ of a sound; thus you can make a stream more acute or grave
709 #/ by changing its pitch. A side effect of changing the pitch
710 #/ is to modify the playing speed of the stream as well.
711 #/ The default value for the pitch is 1.
712 #/
713 #/ \param soundStream Sound stream object
714 #/ \param pitch New pitch to apply to the stream
715 #/
716 #//////////////////////////////////////////////////////////
717 proc setPitch*(soundStream: PSoundStream; pitch: cfloat){.
718 cdecl, importc: "sfSoundStream_setPitch", dynlib: Lib.}
719 #//////////////////////////////////////////////////////////
720 #/ \brief Set the volume of a sound stream
721 #/
722 #/ The volume is a value between 0 (mute) and 100 (full volume).
723 #/ The default value for the volume is 100.
724 #/
725 #/ \param soundStream Sound stream object
726 #/ \param volume Volume of the stream
727 #/
728 #//////////////////////////////////////////////////////////
729 proc setVolume*(soundStream: PSoundStream; volume: cfloat){.
730 cdecl, importc: "sfSoundStream_setVolume", dynlib: Lib.}
731 #//////////////////////////////////////////////////////////
732 #/ \brief Set the 3D position of a sound stream in the audio scene
733 #/
734 #/ Only streams with one channel (mono streams) can be
735 #/ spatialized.
736 #/ The default position of a stream is (0, 0, 0).
737 #/
738 #/ \param soundStream Sound stream object
739 #/ \param position Position of the stream in the scene
740 #/
741 #//////////////////////////////////////////////////////////
742 proc setPosition*(soundStream: PSoundStream; position: TVector3f){.
743 cdecl, importc: "sfSoundStream_setPosition", dynlib: Lib.}
744 #//////////////////////////////////////////////////////////
745 #/ \brief Make a sound stream's position relative to the listener or absolute
746 #/
747 #/ Making a stream relative to the listener will ensure that it will always
748 #/ be played the same way regardless the position of the listener.
749 #/ This can be useful for non-spatialized streams, streams that are
750 #/ produced by the listener, or streams attached to it.
751 #/ The default value is false (position is absolute).
752 #/
753 #/ \param soundStream Sound stream object
754 #/ \param relative sfTrue to set the position relative, sfFalse to set it absolute
755 #/
756 #//////////////////////////////////////////////////////////
757 proc setRelativeToListener*(soundStream: PSoundStream; relative: bool){.
758 cdecl, importc: "sfSoundStream_setRelativeToListener", dynlib: Lib.}
759 #//////////////////////////////////////////////////////////
760 #/ \brief Set the minimum distance of a sound stream
761 #/
762 #/ The "minimum distance" of a stream is the maximum
763 #/ distance at which it is heard at its maximum volume. Further
764 #/ than the minimum distance, it will start to fade out according
765 #/ to its attenuation factor. A value of 0 ("inside the head
766 #/ of the listener") is an invalid value and is forbidden.
767 #/ The default value of the minimum distance is 1.
768 #/
769 #/ \param soundStream Sound stream object
770 #/ \param distance New minimum distance of the stream
771 #/
772 #//////////////////////////////////////////////////////////
773 proc setMinDistance*(soundStream: PSoundStream; distance: cfloat){.
774 cdecl, importc: "sfSoundStream_setMinDistance", dynlib: Lib.}
775 #//////////////////////////////////////////////////////////
776 #/ \brief Set the attenuation factor of a sound stream
777 #/
778 #/ The attenuation is a multiplicative factor which makes
779 #/ the stream more or less loud according to its distance
780 #/ from the listener. An attenuation of 0 will produce a
781 #/ non-attenuated stream, i.e. its volume will always be the same
782 #/ whether it is heard from near or from far. On the other hand,
783 #/ an attenuation value such as 100 will make the stream fade out
784 #/ very quickly as it gets further from the listener.
785 #/ The default value of the attenuation is 1.
786 #/
787 #/ \param soundStream Sound stream object
788 #/ \param attenuation New attenuation factor of the stream
789 #/
790 #//////////////////////////////////////////////////////////
791 proc setAttenuation*(soundStream: PSoundStream; attenuation: cfloat){.
792 cdecl, importc: "sfSoundStream_setAttenuation", dynlib: Lib.}
793 #//////////////////////////////////////////////////////////
794 #/ \brief Change the current playing position of a sound stream
795 #/
796 #/ The playing position can be changed when the stream is
797 #/ either paused or playing.
798 #/
799 #/ \param soundStream Sound stream object
800 #/ \param timeOffset New playing position
801 #/
802 #//////////////////////////////////////////////////////////
803 proc setPlayingOffset*(soundStream: PSoundStream; timeOffset: TTime){.
804 cdecl, importc: "sfSoundStream_setPlayingOffset", dynlib: Lib.}
805 #//////////////////////////////////////////////////////////
806 #/ \brief Set whether or not a sound stream should loop after reaching the end
807 #/
808 #/ If set, the stream will restart from beginning after
809 #/ reaching the end and so on, until it is stopped or
810 #/ sfSoundStream_setLoop(stream, sfFalse) is called.
811 #/ The default looping state for sound streams is false.
812 #/
813 #/ \param soundStream Sound stream object
814 #/ \param loop sfTrue to play in loop, sfFalse to play once
815 #/
816 #//////////////////////////////////////////////////////////
817 proc setLoop*(soundStream: PSoundStream; loop: bool){.
818 cdecl, importc: "sfSoundStream_setLoop", dynlib: Lib.}
819 #//////////////////////////////////////////////////////////
820 #/ \brief Get the pitch of a sound stream
821 #/
822 #/ \param soundStream Sound stream object
823 #/
824 #/ \return Pitch of the stream
825 #/
826 #//////////////////////////////////////////////////////////
827 proc getPitch*(soundStream: PSoundStream): cfloat{.
828 cdecl, importc: "sfSoundStream_getPitch", dynlib: Lib.}
829 #//////////////////////////////////////////////////////////
830 #/ \brief Get the volume of a sound stream
831 #/
832 #/ \param soundStream Sound stream object
833 #/
834 #/ \return Volume of the stream, in the range [0, 100]
835 #/
836 #//////////////////////////////////////////////////////////
837 proc getVolume*(soundStream: PSoundStream): cfloat{.
838 cdecl, importc: "sfSoundStream_getVolume", dynlib: Lib.}
839 #//////////////////////////////////////////////////////////
840 #/ \brief Get the 3D position of a sound stream in the audio scene
841 #/
842 #/ \param soundStream Sound stream object
843 #/
844 #/ \return Position of the stream in the world
845 #/
846 #//////////////////////////////////////////////////////////
847 proc getPosition*(soundStream: PSoundStream): TVector3f{.
848 cdecl, importc: "sfSoundStream_getPosition", dynlib: Lib.}
849 #//////////////////////////////////////////////////////////
850 #/ \brief Tell whether a sound stream's position is relative to the
851 #/ listener or is absolute
852 #/
853 #/ \param soundStream Sound stream object
854 #/
855 #/ \return sfTrue if the position is relative, sfFalse if it's absolute
856 #/
857 #//////////////////////////////////////////////////////////
858 proc isRelativeToListener*(soundStream: PSoundStream): bool{.
859 cdecl, importc: "sfSoundStream_isRelativeToListener", dynlib: Lib.}
860 #//////////////////////////////////////////////////////////
861 #/ \brief Get the minimum distance of a sound stream
862 #/
863 #/ \param soundStream Sound stream object
864 #/
865 #/ \return Minimum distance of the stream
866 #/
867 #//////////////////////////////////////////////////////////
868 proc getMinDistance*(soundStream: PSoundStream): cfloat{.
869 cdecl, importc: "sfSoundStream_getMinDistance", dynlib: Lib.}
870 #//////////////////////////////////////////////////////////
871 #/ \brief Get the attenuation factor of a sound stream
872 #/
873 #/ \param soundStream Sound stream object
874 #/
875 #/ \return Attenuation factor of the stream
876 #/
877 #//////////////////////////////////////////////////////////
878 proc getAttenuation*(soundStream: PSoundStream): cfloat{.
879 cdecl, importc: "sfSoundStream_getAttenuation", dynlib: Lib.}
880 #//////////////////////////////////////////////////////////
881 #/ \brief Tell whether or not a sound stream is in loop mode
882 #/
883 #/ \param soundStream Sound stream object
884 #/
885 #/ \return sfTrue if the music is looping, sfFalse otherwise
886 #/
887 #//////////////////////////////////////////////////////////
888 proc getLoop*(soundStream: PSoundStream): bool{.
889 cdecl, importc: "sfSoundStream_getLoop", dynlib: Lib.}
890 #//////////////////////////////////////////////////////////
891 #/ \brief Get the current playing position of a sound stream
892 #/
893 #/ \param soundStream Sound stream object
894 #/
895 #/ \return Current playing position
896 #/
897 #//////////////////////////////////////////////////////////
898 proc getPlayingOffset*(soundStream: PSoundStream): TTime{.
899 cdecl, importc: "sfSoundStream_getPlayingOffset", dynlib: Lib.}