diff options
| author | Ray <[email protected]> | 2023-03-07 19:48:47 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-03-07 19:48:47 +0100 |
| commit | 1b873b028f18486d31bb5c75f6b04a4de4c8d9fa (patch) | |
| tree | 16c38ad8ccce7f663925b2de141f0c94719a87ab /src | |
| parent | 3a332d241c1c675c8b581fe3a29e328983642fe4 (diff) | |
| download | raylib-1b873b028f18486d31bb5c75f6b04a4de4c8d9fa.tar.gz raylib-1b873b028f18486d31bb5c75f6b04a4de4c8d9fa.zip | |
WARNING: REMOVED: Multichannel audio support API
It was quite restrictive and hacky implementation, just load multiple types same sound to play multiple instances.
Diffstat (limited to 'src')
| -rw-r--r-- | src/raudio.c | 87 | ||||
| -rw-r--r-- | src/raylib.h | 3 |
2 files changed, 0 insertions, 90 deletions
diff --git a/src/raudio.c b/src/raudio.c index 8bd9052c..c86ea0bb 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -377,11 +377,6 @@ typedef struct AudioData { int defaultSize; // Default audio buffer size for audio streams } Buffer; rAudioProcessor *mixedProcessor; - struct { - unsigned int poolCounter; // AudioBuffer pointers pool counter - AudioBuffer *pool[MAX_AUDIO_BUFFER_POOL_CHANNELS]; // Multichannel AudioBuffer pointers pool - unsigned int channels[MAX_AUDIO_BUFFER_POOL_CHANNELS]; // AudioBuffer pool channels - } MultiChannel; } AudioData; //---------------------------------------------------------------------------------- @@ -1100,88 +1095,6 @@ void PlaySound(Sound sound) PlayAudioBuffer(sound.stream.buffer); } -// Play a sound in the multichannel buffer pool -void PlaySoundMulti(Sound sound) -{ - int index = -1; - unsigned int oldAge = 0; - int oldIndex = -1; - - // find the first non-playing pool entry - for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++) - { - if (AUDIO.MultiChannel.channels[i] > oldAge) - { - oldAge = AUDIO.MultiChannel.channels[i]; - oldIndex = i; - } - - if (!IsAudioBufferPlaying(AUDIO.MultiChannel.pool[i])) - { - index = i; - break; - } - } - - // If no none playing pool members can be indexed choose the oldest - if (index == -1) - { - TRACELOG(LOG_WARNING, "SOUND: Buffer pool is already full, count: %i", AUDIO.MultiChannel.poolCounter); - - if (oldIndex == -1) - { - // Shouldn't be able to get here... but just in case something odd happens! - TRACELOG(LOG_WARNING, "SOUND: Buffer pool could not determine the oldest buffer not playing sound"); - return; - } - - index = oldIndex; - - // Just in case... - StopAudioBuffer(AUDIO.MultiChannel.pool[index]); - } - - // Experimentally mutex lock doesn't seem to be needed this makes sense - // as pool[index] isn't playing and the only stuff we're copying - // shouldn't be changing... - - AUDIO.MultiChannel.channels[index] = AUDIO.MultiChannel.poolCounter; - AUDIO.MultiChannel.poolCounter++; - - SetAudioBufferVolume(AUDIO.MultiChannel.pool[index], sound.stream.buffer->volume); - SetAudioBufferPitch(AUDIO.MultiChannel.pool[index], sound.stream.buffer->pitch); - SetAudioBufferPan(AUDIO.MultiChannel.pool[index], sound.stream.buffer->pan); - - AUDIO.MultiChannel.pool[index]->looping = sound.stream.buffer->looping; - AUDIO.MultiChannel.pool[index]->usage = sound.stream.buffer->usage; - AUDIO.MultiChannel.pool[index]->isSubBufferProcessed[0] = false; - AUDIO.MultiChannel.pool[index]->isSubBufferProcessed[1] = false; - AUDIO.MultiChannel.pool[index]->sizeInFrames = sound.stream.buffer->sizeInFrames; - - AUDIO.MultiChannel.pool[index]->data = sound.stream.buffer->data; // Fill dummy track with data for playing - - PlayAudioBuffer(AUDIO.MultiChannel.pool[index]); -} - -// Stop any sound played with PlaySoundMulti() -void StopSoundMulti(void) -{ - for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++) StopAudioBuffer(AUDIO.MultiChannel.pool[i]); -} - -// Get number of sounds playing in the multichannel buffer pool -int GetSoundsPlaying(void) -{ - int counter = 0; - - for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++) - { - if (IsAudioBufferPlaying(AUDIO.MultiChannel.pool[i])) counter++; - } - - return counter; -} - // Pause a sound void PauseSound(Sound sound) { diff --git a/src/raylib.h b/src/raylib.h index 6bc81fe7..9fcece6f 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1530,9 +1530,6 @@ RLAPI void PlaySound(Sound sound); // Play a RLAPI void StopSound(Sound sound); // Stop playing a sound RLAPI void PauseSound(Sound sound); // Pause a sound RLAPI void ResumeSound(Sound sound); // Resume a paused sound -RLAPI void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool) -RLAPI void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool) -RLAPI int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) |
