-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDAUDIO.h
More file actions
101 lines (83 loc) · 3.76 KB
/
DAUDIO.h
File metadata and controls
101 lines (83 loc) · 3.76 KB
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
/* Dust Ultimate Game Library (DUGL)
Copyright (C) 2025 Fakhri Feki
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
contact: libdugl(at)hotmail.com */
#ifndef DAUDIO_H_INCLUDED
#define DAUDIO_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*daudioEventCallBack)(unsigned int);
typedef struct DSound {
unsigned char *data;
unsigned int length;
} DSound;
// DSound
typedef struct DSoundState {
DSound *sound;
unsigned int volume;
unsigned int position;
daudioEventCallBack OnFinish;
daudioEventCallBack OnLoop;
daudioEventCallBack OnQueue;
bool paused;
bool loop;
bool queueInheritEvents;
bool stopEvents;
} DSoundState;
#define NO_SOUND_ID 0xffffffff
// initialize Audio output with frequency [11025, 48000Hz], stereo or not
bool InstallDAudio(int frequency, bool stereo);
// Unininstall audio and free allocated ressources
void UninstallDAudio();
// Start outputting audio / InstallDAudio start at paused state
void PlayDAudio();
// stop outputting audio
void PauseDAudio();
// Lock audio (Mutex) for Critical data
void LockDAudio();
// Unlock audio (Mutex) for Critical data
void UnlockDAudio();
// Load DSound WAV and convert it to the current audio output format/frequency
DSound *DgLoadWAV(char *filename);
// Destroy loaded DSound
void DestroyDSound(DSound *sound);
// Allocate a new channel or (soundID) and start playing it if paused is false, return the new channel or NO_SOUND_ID if failed
unsigned int PlayDSound(DSound *sound, unsigned char volume, bool loop, bool paused);
// free the soundID and stop playing it
void StopDSound(unsigned int soundID);
// update volume of SoundID
void SetVolumeDSound(unsigned int soundID, unsigned char volume);
// Change paused state of SoundID
void SetPausedDSound(unsigned int soundID, bool paused);
// Change looping state of SoundID
void SetLoopingDSound(unsigned int soundID, bool loop);
// Change StopEvents state of SoundID, if false will stop calling channel events callback
void SetStopEventsDSound(unsigned int soundID, bool stopEvents);
// Get soundID state
DSoundState* GetPlayingStateDSound(unsigned int soundID);
// set events callback for soundID
void SetEventsDSound(unsigned int soundID, daudioEventCallBack OnFinish, daudioEventCallBack OnLoop, daudioEventCallBack OnQueue);
// Queue a sound for soundID, will only play if the current sound finish
bool QueueDSound(unsigned int soundID, DSound *sound, unsigned char volume, bool loop, bool paused, bool inheritEvents);
// Replace current soundID with new sound as soon as possible, if the soundID already finished return false and the new channel in SoundID
bool ReplaceDSound(unsigned int *soundID, DSound *sound, unsigned char volume, bool loop, bool paused, bool inheritEvents);
// return true if the soundID has a queue sound waiting
bool IsQueuedDSound(unsigned int soundID);
// return true if the soundID is playing even if paused
bool IsPlayingDSound(unsigned int soundID);
// get current count of channels used
unsigned int GetPlayingDSoundCount();
#ifdef __cplusplus
} // extern "C" {
#endif
#endif // DAUDIO_H_INCLUDED