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:
parent
3a332d241c
commit
1b873b028f
9 changed files with 0 additions and 568 deletions
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue