From f5ee23cea3c125055b34fb746a1a8dc486ff6016 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sat, 28 Dec 2024 10:59:25 +0100 Subject: [PATCH] - [NEW] JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop = 0); --- jail_audio.cpp | 13 +++++++++++++ jail_audio.h | 1 + 2 files changed, 14 insertions(+) diff --git a/jail_audio.cpp b/jail_audio.cpp index be7031b..1a0e0d2 100644 --- a/jail_audio.cpp +++ b/jail_audio.cpp @@ -316,6 +316,19 @@ int JA_PlaySound(JA_Sound_t *sound, const int loop) return channel; } +int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop) +{ + if (!JA_soundEnabled) return -1; + + if (channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return -1; + + channels[channel].sound = sound; + channels[channel].times = loop; + channels[channel].pos = 0; + channels[channel].state = JA_CHANNEL_PLAYING; + return channel; +} + void JA_DeleteSound(JA_Sound_t *sound) { for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { diff --git a/jail_audio.h b/jail_audio.h index d4d8772..67138c7 100644 --- a/jail_audio.h +++ b/jail_audio.h @@ -28,6 +28,7 @@ JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length); JA_Sound_t *JA_LoadSound(Uint8* buffer, Uint32 length); JA_Sound_t *JA_LoadSound(const char* filename); int JA_PlaySound(JA_Sound_t *sound, const int loop = 0); +int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop = 0); void JA_PauseChannel(const int channel); void JA_ResumeChannel(const int channel); void JA_StopChannel(const int channel);