1 // Audio device management functions
2 //
3 module bindbc.raylib.bind.audio;
4 import bindbc.raylib.types;
5 
6 version (BindRaylib_Static) {
7    extern (C) @nogc nothrow {
8    }
9 } else {
10    extern (C) @nogc nothrow {
11       /**
12        * nitialize audio device and context
13        */
14       alias pInitAudioDevice = void function();
15       /**
16        * Close the audio device and context (and music stream)
17        */
18       alias pCloseAudioDevice = void function();
19       /**
20        * Check if audio device is ready
21        */
22       alias pIsAudioDeviceReady = bool function();
23       /**
24        * Set master volume (listener)
25        */
26       alias pSetMasterVolume = void function(float volume);
27 
28       // Wave Sound loading/unloading functions
29       /**
30        * Load wave data from file
31        */
32       alias pLoadWave = Wave function(const(char)* fileName);
33       /**
34        * Load sound from file
35        */
36       alias pLoadSound = Sound function(const(char)* fileName);
37       /**
38        * Load sound from wave data
39        */
40       alias pLoadSoundFromWave = Sound function(Wave wave);
41       /**
42        * Update sound buffer with new data
43        */
44       alias pUpdateSound = void function(Sound sound, const(void)* data, int samplesCount);
45       /**
46        * Unload wave data
47        */
48       alias pUnloadWave = void function(Wave wave);
49       /**
50        * Unload sound
51        */
52       alias pUnloadSound = void function(Sound sound);
53       /**
54        * Export wave data to file
55        */
56       alias pExportWave = void function(Wave wave, const(char)* fileName);
57       /**
58        * Export wave sample data to code (.h)
59        */
60       alias pExportWaveAsCode = void function(Wave wave, const(char)* fileName);
61 
62        // Wave Sound management functions
63       /**
64        * Play a sound
65        */
66       alias pPlaySound = void function(Sound sound);
67       /**
68        * Stop playing a sound
69        */
70       alias pStopSound = void function(Sound sound);
71       /**
72        * Pause a sound
73        */
74       alias pPauseSound = void function(Sound sound);
75       /**
76        * Resume a paused sound
77        */
78       alias pResumeSound = void function(Sound sound);
79       /**
80        * Play a sound (using multichannel buffer pool)
81        */
82       alias pPlaySoundMulti = void function(Sound sound);
83       /**
84        * Stop any sound playing (using multichannel buffer pool)
85        */
86       alias pStopSoundMulti = void function();
87       /**
88        * Get number of sounds playing in the multichannel
89        */
90       alias pGetSoundsPlaying = int function();
91       /**
92        * Check if a sound is currently playing
93        */
94       alias pIsSoundPlaying = bool function(Sound sound);
95       /**
96        * Set volume for a sound (1.0 is max level)
97        */
98       alias pSetSoundVolume = void function(Sound sound, float volume);
99       /**
100        * Set pitch for a sound (1.0 is base level)
101        */
102       alias pSetSoundPitch = void function(Sound sound, float pitch);
103 
104       /**
105       * Default size for new audio streams
106       */
107       alias pSetAudioStreamBufferSizeDefault = void function(int size);
108       /**
109        * Convert wave data to desired format
110        */
111       alias pWaveFormat = void function(Wave* wave, int sampleRate, int sampleSize, int channels);
112       /**
113        * Copy a wave to a new wave
114        */
115       alias pWaveCopy = Wave function(Wave wave);
116       /**
117        * Crop a wave to defined samples range
118        */
119       alias pWaveCrop = void function(Wave* wave, int initSample, int finalSample);
120       /**
121        * Get samples data from wave as a floats array
122        */
123       alias pGetWaveData = float* function(Wave wave);
124 
125       // Music management functions
126       /**
127        * Load music stream from file
128        */
129       alias pLoadMusicStream = Music function(const(char)* fileName);
130       /**
131        * Unload music stream
132        */
133       alias pUnloadMusicStream = void function(Music music);
134       /**
135        * Start music playing
136        */
137       alias pPlayMusicStream = void function(Music music);
138       /**
139        * Updates buffers for music streaming
140        */
141       alias pUpdateMusicStream = void function(Music music);
142       /**
143        * Stop music playing
144        */
145       alias pStopMusicStream = void function(Music music);
146       /**
147        * Pause music playing
148        */
149       alias pPauseMusicStream = void function(Music music);
150       /**
151        * Resume playing paused music
152        */
153       alias pResumeMusicStream = void function(Music music);
154       /**
155        * Check if music is playing
156        */
157       alias pIsMusicPlaying = bool function(Music music);
158       /**
159        * Set volume for music (1.0 is max level)
160        */
161       alias pSetMusicVolume = void function(Music music, float volume);
162       /**
163        * Set pitch for a music (1.0 is base level)
164        */
165       alias pSetMusicPitch = void function(Music music, float pitch);
166       /**
167        * Set music loop count (loop repeats)
168        */
169       alias pSetMusicLoopCount = void function(Music music, int count);
170       /**
171        * Get music time length (in seconds)
172        */
173       alias pGetMusicTimeLength = float function(Music music);
174       /**
175        * Get current music time played (in seconds)
176        */
177       alias pGetMusicTimePlayed = float function(Music music);
178 
179       // AudioStream management functions
180       /**
181        * Init audio stream (to stream raw audio pcm data)
182        */
183       alias pInitAudioStream = AudioStream function(uint sampleRate, uint sampleSize, uint channels);
184       /**
185        * Update audio stream buffers with data
186        */
187       alias pUpdateAudioStream = void function(AudioStream stream, const(void)* data, int samplesCount);
188       /**
189        * Close audio stream and free memory
190        */
191       alias pCloseAudioStream = void function(AudioStream stream);
192       /**
193        * Check if any audio stream buffers requires refill
194        */
195       alias pIsAudioStreamProcessed = bool function(AudioStream stream);
196       /**
197        * Play audio stream
198        */
199       alias pPlayAudioStream = void function(AudioStream stream);
200       /**
201        * Pause audio stream
202        */
203       alias pPauseAudioStream = void function(AudioStream stream);
204       /**
205        * Resume audio stream
206        */
207       alias pResumeAudioStream = void function(AudioStream stream);
208       /**
209        * Check if audio stream is playing
210        */
211       alias pIsAudioStreamPlaying = bool function(AudioStream stream);
212       /**
213        * Stop audio stream
214        */
215       alias pStopAudioStream = void function(AudioStream stream);
216       /**
217        * Set volume for audio stream (1.0 is max level)
218        */
219       alias pSetAudioStreamVolume = void function(AudioStream stream, float volume);
220       /**
221        * Set pitch for audio stream (1.0 is base level)
222        */
223       alias pSetAudioStreamPitch = void function(AudioStream stream, float pitch);
224    }
225    __gshared {
226       pInitAudioDevice InitAudioDevice;
227       pCloseAudioDevice CloseAudioDevice;
228       pIsAudioDeviceReady IsAudioDeviceReady;
229       pSetMasterVolume SetMasterVolume;
230       pLoadWave LoadWave;
231       pLoadSound LoadSound;
232       pLoadSoundFromWave LoadSoundFromWave;
233       pUpdateSound UpdateSound;
234       pUnloadWave UnloadWave;
235       pUnloadSound UnloadSound;
236       pExportWave ExportWave;
237       pExportWaveAsCode ExportWaveAsCode;
238       pPlaySound PlaySound;
239       pStopSound StopSound;
240       pPauseSound PauseSound;
241       pResumeSound ResumeSound;
242       pPlaySoundMulti PlaySoundMulti;
243       pStopSoundMulti StopSoundMulti;
244       pGetSoundsPlaying GetSoundsPlaying;
245       pIsSoundPlaying IsSoundPlaying;
246       pSetSoundVolume SetSoundVolume;
247       pSetSoundPitch SetSoundPitch;
248       pSetAudioStreamBufferSizeDefault SetAudioStreamBufferSizeDefault;
249       pWaveFormat WaveFormat;
250       pWaveCopy WaveCopy;
251       pWaveCrop WaveCrop;
252       pGetWaveData GetWaveData;
253       pLoadMusicStream LoadMusicStream;
254       pUnloadMusicStream UnloadMusicStream;
255       pPlayMusicStream PlayMusicStream;
256       pUpdateMusicStream UpdateMusicStream;
257       pStopMusicStream StopMusicStream;
258       pPauseMusicStream PauseMusicStream;
259       pResumeMusicStream ResumeMusicStream;
260       pIsMusicPlaying IsMusicPlaying;
261       pSetMusicVolume SetMusicVolume;
262       pSetMusicPitch SetMusicPitch;
263       pSetMusicLoopCount SetMusicLoopCount;
264       pGetMusicTimeLength GetMusicTimeLength;
265       pGetMusicTimePlayed GetMusicTimePlayed;
266       pInitAudioStream InitAudioStream;
267       pUpdateAudioStream UpdateAudioStream;
268       pCloseAudioStream CloseAudioStream;
269       pIsAudioStreamProcessed IsAudioStreamProcessed;
270       pPlayAudioStream PlayAudioStream;
271       pPauseAudioStream PauseAudioStream;
272       pResumeAudioStream ResumeAudioStream;
273       pIsAudioStreamPlaying IsAudioStreamPlaying;
274       pStopAudioStream StopAudioStream;
275       pSetAudioStreamVolume SetAudioStreamVolume;
276       pSetAudioStreamPitch SetAudioStreamPitch;
277    }
278 }