summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorchriscamacho <[email protected]>2019-06-29 09:49:42 +0100
committerRay <[email protected]>2019-06-29 10:49:42 +0200
commit83a4eb08525c25026dbf16211ef083a46745867f (patch)
treef681f33b075035a6540f391adcbc36b880b620bb /examples
parenta4e307ed965d2bb64f915c604e8a9ea2c003cf48 (diff)
downloadraylib-83a4eb08525c25026dbf16211ef083a46745867f.tar.gz
raylib-83a4eb08525c25026dbf16211ef083a46745867f.zip
add multi channel audio to raudio (#895)
* added multi channel sound replay to raudio added -fPIC to Makefile for Linux added simple lighting and audio multi channel to examples Makefile * not properly reporting audio buffer pool size...
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile8
-rw-r--r--examples/audio/audio_multichannel_sound.c116
2 files changed, 121 insertions, 3 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 218ed721..2731ee50 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -165,7 +165,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# HTML5 emscripten compiler
- # WARNING: To compile to HTML5, code must be redesigned
+ # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop()
CC = emcc
endif
@@ -303,12 +303,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
-
+
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
-
+
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
@@ -435,10 +435,12 @@ EXAMPLES = \
shaders/shaders_texture_waves \
shaders/shaders_julia_set \
shaders/shaders_eratosthenes \
+ shaders/shaders_basic_lighting \
audio/audio_module_playing \
audio/audio_music_stream \
audio/audio_raw_stream \
audio/audio_sound_loading \
+ audio/audio_multichannel_sound \
physac/physics_demo \
physac/physics_friction \
physac/physics_movement \
diff --git a/examples/audio/audio_multichannel_sound.c b/examples/audio/audio_multichannel_sound.c
new file mode 100644
index 00000000..42c71704
--- /dev/null
+++ b/examples/audio/audio_multichannel_sound.c
@@ -0,0 +1,116 @@
+
+/*
+* This example was coded to demonstrate multi channel audio changes added to raylib
+*
+* This example has been created using raylib (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* This example Copyright (c) 2018 Chris Camacho (codifies) http://bedroomcoders.co.uk/captcha/
+*
+* THIS EXAMPLE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* This example may be freely redistributed.
+*/
+
+#include "raylib.h"
+#include <stdio.h> // sprintf
+
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [audio] abuse!");
+
+ InitAudioDevice(); // Initialize audio device
+
+ Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
+ Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
+
+
+ //InitPlayBufferPool();
+
+
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+ int frame = 0;
+ // Main game loop
+
+ // old system still works alongside
+ SetSoundVolume(fxWav, 0.2); // effects all mutltiplay replay (really annoying sound!!!)
+ PlaySound(fxOgg);
+
+ bool inhibitWav = false;
+ bool inhibitOgg = false;
+ int maxFrame = 60;
+ int numberPlaying = 0;
+
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ frame++;
+
+ if (IsKeyDown(KEY_ENTER)) { inhibitWav=true; } else { inhibitWav=false; }
+ if (IsKeyDown(KEY_SPACE)) { inhibitOgg=true; } else { inhibitOgg=false; }
+
+ // deliberatly hammer the play pool to see what dropping old
+ // pool entries sounds like....
+ if (frame % 5==0) {
+ if (!inhibitWav) PlaySoundEx(fxWav);
+ }
+ if (frame==maxFrame) {
+ if (!inhibitOgg) PlaySoundEx(fxOgg);
+ frame=0;
+ maxFrame = GetRandomValue(6,12);
+ }
+
+ numberPlaying = ConcurrentPlayChannels();
+
+ //----------------------------------------------------------------------------------
+
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+ char msg[1024];
+ DrawText("multichannel sound abuse!", 200, 180, 20, LIGHTGRAY);
+ DrawText("Space to inhibit new ogg triggering", 200, 200, 20, LIGHTGRAY);
+ DrawText("Enter to inhibit new wav triggering", 200, 220, 20, LIGHTGRAY);
+
+ sprintf(msg,"concurrently playing %i", numberPlaying);
+ DrawText(msg, 200, 280, 20, LIGHTGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+
+
+ // you MUST stop the buffer pool before unloading
+ // any Sounds it might have used...
+ StopPlayBufferPool();
+
+ UnloadSound(fxWav); // Unload sound data
+ UnloadSound(fxOgg); // Unload sound data
+
+ CloseAudioDevice(); // Close audio device
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}