diff --git a/examples/Makefile b/examples/Makefile index 0b524015f..6b0b4a848 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -531,7 +531,6 @@ AUDIO = \ audio/audio_music_stream \ audio/audio_raw_stream \ audio/audio_sound_loading \ - audio/audio_multichannel_sound \ audio/audio_stream_effects CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) diff --git a/examples/Makefile.Web b/examples/Makefile.Web index a55a76b8c..063530fb3 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -503,7 +503,6 @@ AUDIO = \ audio/audio_music_stream \ audio/audio_raw_stream \ audio/audio_sound_loading \ - audio/audio_multichannel_sound \ audio/audio_stream_effects CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) @@ -1006,11 +1005,6 @@ audio/audio_sound_loading: audio/audio_sound_loading.c --preload-file audio/resources/sound.wav@resources/sound.wav \ --preload-file audio/resources/target.ogg@resources/target.ogg -audio/audio_multichannel_sound: audio/audio_multichannel_sound.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ - --preload-file audio/resources/sound.wav@resources/sound.wav \ - --preload-file audio/resources/target.ogg@resources/target.ogg - audio/audio_stream_effects: audio/audio_stream_effects.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \ --preload-file audio/resources/country.mp3@resources/country.mp3 diff --git a/examples/README.md b/examples/README.md index 7a3e72f87..8399d677d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -186,7 +186,6 @@ Examples using raylib audio functionality, including sound/music loading and pla | 118 | [audio_music_stream](audio/audio_music_stream.c) | audio_music_stream | ⭐️☆☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) | | 119 | [audio_raw_stream](audio/audio_raw_stream.c) | audio_raw_stream | ⭐️⭐️⭐️☆ | 1.6 | **4.2** | [Ray](https://github.com/raysan5) | | 120 | [audio_sound_loading](audio/audio_sound_loading.c) | audio_sound_loading | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) | -| 121 | [audio_multichannel_sound](audio/audio_multichannel_sound.c) | audio_multichannel_sound | ⭐️☆☆☆ | 3.0 | 3.5 | [Chris Camacho](https://github.com/codifies) | ### category: others diff --git a/examples/audio/audio_multichannel_sound.c b/examples/audio/audio_multichannel_sound.c deleted file mode 100644 index 1d549a055..000000000 --- a/examples/audio/audio_multichannel_sound.c +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************************* -* -* raylib [audio] example - Multichannel sound playing -* -* Example originally created with raylib 3.0, last time updated with raylib 3.5 -* -* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5) -* -* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software -* -* Copyright (c) 2019-2023 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing"); - - InitAudioDevice(); // Initialize audio device - - Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file - Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file - - SetSoundVolume(fxWav, 0.2f); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_ENTER)) PlaySoundMulti(fxWav); // Play a new wav sound instance - if (IsKeyPressed(KEY_SPACE)) PlaySoundMulti(fxOgg); // Play a new ogg sound instance - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("MULTICHANNEL SOUND PLAYING", 20, 20, 20, GRAY); - DrawText("Press SPACE to play new ogg instance!", 200, 120, 20, LIGHTGRAY); - DrawText("Press ENTER to play new wav instance!", 200, 180, 20, LIGHTGRAY); - - DrawText(TextFormat("CONCURRENT SOUNDS PLAYING: %02i", GetSoundsPlaying()), 220, 280, 20, RED); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - StopSoundMulti(); // We must stop the buffer pool before unloading - - UnloadSound(fxWav); // Unload sound data - UnloadSound(fxOgg); // Unload sound data - - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/audio/audio_multichannel_sound.png b/examples/audio/audio_multichannel_sound.png deleted file mode 100644 index 4b98b26e0..000000000 Binary files a/examples/audio/audio_multichannel_sound.png and /dev/null differ diff --git a/projects/VS2022/examples/audio_multichannel_sound.vcxproj b/projects/VS2022/examples/audio_multichannel_sound.vcxproj deleted file mode 100644 index 91ab9095d..000000000 --- a/projects/VS2022/examples/audio_multichannel_sound.vcxproj +++ /dev/null @@ -1,390 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F} - Win32Proj - audio_multichannel_sound - 10.0 - audio_multichannel_sound - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\audio - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 06166cdd0..673ccb4b3 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_image_drawing", "e EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_module_playing", "examples\audio_module_playing.vcxproj", "{E6784F91-4E4E-4956-A079-73FAB1AC7BE6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_multichannel_sound", "examples\audio_multichannel_sound.vcxproj", "{9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_music_stream", "examples\audio_music_stream.vcxproj", "{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_raw_stream", "examples\audio_raw_stream.vcxproj", "{93A1F656-0D29-4C5E-B140-11F23FF5D6AB}" diff --git a/src/raudio.c b/src/raudio.c index 8bd9052c2..c86ea0bb4 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 6bc81fe75..9fcece6f0 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)