diff options
| author | Ray <[email protected]> | 2021-08-16 11:06:31 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-08-16 11:06:31 +0200 |
| commit | 1b4c58b66f670b521d2f707b3fa1be860738b33a (patch) | |
| tree | 60f2773b66e8a90e11361a219dce7d0599dfd8b4 /src/raudio.h | |
| parent | e203fb58c6025e28acec1f7340e185c00a1d3e2a (diff) | |
| download | raylib-1b4c58b66f670b521d2f707b3fa1be860738b33a.tar.gz raylib-1b4c58b66f670b521d2f707b3fa1be860738b33a.zip | |
WARNING: BREAKING: Use `frameCount` on audio
This is a big change for optimization and a more professional understanding of audio. Instead of dealing with samples, now we deal with frames, like miniaudio does, so, avoiding continuous conversions from samples to frames.
Diffstat (limited to 'src/raudio.h')
| -rw-r--r-- | src/raudio.h | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/src/raudio.h b/src/raudio.h index e8a1ebaf..cddb3568 100644 --- a/src/raudio.h +++ b/src/raudio.h @@ -78,49 +78,42 @@ #endif #endif -// Wave type, defines audio wave data +// Wave, audio wave data typedef struct Wave { - unsigned int sampleCount; // Total number of samples - unsigned int sampleRate; // Frequency (samples per second) - unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) - unsigned int channels; // Number of channels (1-mono, 2-stereo) - void *data; // Buffer data pointer + unsigned int frameCount; // Total number of frames (considering channels) + unsigned int sampleRate; // Frequency (samples per second) + unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) + void *data; // Buffer data pointer } Wave; typedef struct rAudioBuffer rAudioBuffer; -// Audio stream type -// NOTE: Useful to create custom audio streams not bound to a specific file +// AudioStream, custom audio stream typedef struct AudioStream { - unsigned int sampleRate; // Frequency (samples per second) - unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) - unsigned int channels; // Number of channels (1-mono, 2-stereo) + rAudioBuffer *buffer; // Pointer to internal data used by the audio system - rAudioBuffer *buffer; // Pointer to internal data used by the audio system + unsigned int sampleRate; // Frequency (samples per second) + unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) } AudioStream; -// Sound source type +// Sound typedef struct Sound { - unsigned int sampleCount; // Total number of samples - AudioStream stream; // Audio stream + AudioStream stream; // Audio stream + unsigned int frameCount; // Total number of frames (considering channels) } Sound; -// Music stream type (audio file streaming from memory) -// NOTE: Anything longer than ~10 seconds should be streamed +// Music, audio stream, anything longer than ~10 seconds should be streamed typedef struct Music { - int ctxType; // Type of music context (audio filetype) - void *ctxData; // Audio context data, depends on type + AudioStream stream; // Audio stream + unsigned int frameCount; // Total number of frames (considering channels) + bool looping; // Music looping enable - bool looping; // Music looping enable - unsigned int sampleCount; // Total number of samples - - AudioStream stream; // Audio stream + int ctxType; // Type of music context (audio filetype) + void *ctxData; // Audio context data, depends on type } Music; -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -130,6 +123,10 @@ extern "C" { // Prevents name mangling of functions // Module Functions Declaration //---------------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { // Prevents name mangling of functions +#endif + // Audio device management functions void InitAudioDevice(void); // Initialize audio device and context void CloseAudioDevice(void); // Close the audio device and context |
