mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-05 17:36:26 +00:00
WARNING: REMOVED: Multichannel audio support API
It was quite restrictive and hacky implementation, just load multiple types same sound to play multiple instances.
This commit is contained in:
87
src/raudio.c
87
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)
|
||||
{
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user