WARNING: Renamed module: audio -> raudio
Planning to promote raudio module as a simple and easy-to-use front-end for the amazing mini_al library, so the name change. Name comes from raylib-audio but in spanish it also remembers to word "raudo", meaning "very fast", an analogy that fits perfectly to the usefulness and performance of the library! Consequently, raylib version has been bumped to 2.4-dev.
This commit is contained in:
parent
64fd131ed5
commit
93471b0a7c
17 changed files with 24 additions and 24 deletions
|
|
@ -149,7 +149,7 @@ On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new v
|
||||||
|
|
||||||
Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
||||||
|
|
||||||
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/master/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/raudio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/master/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
||||||
|
|
||||||
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ features
|
||||||
|
|
||||||
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
|
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
|
||||||
|
|
||||||
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, the amazing [mini_al](https://github.com/dr-soft/mini_al) audio library, single-file header-only and supporting multiple platforms and multiple audio backends.
|
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/raudio.c) module, the amazing [mini_al](https://github.com/dr-soft/mini_al) audio library, single-file header-only and supporting multiple platforms and multiple audio backends.
|
||||||
|
|
||||||
raylib uses internally multiple single-file header-only libraries to support multiple fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory.
|
raylib uses internally multiple single-file header-only libraries to support multiple fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory.
|
||||||
|
|
||||||
|
|
|
||||||
141
examples/others/raudio_standalone.c
Normal file
141
examples/others/raudio_standalone.c
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [audio] example - Using raudio module as standalone module
|
||||||
|
*
|
||||||
|
* NOTE: This example does not require any graphic device, it can run directly on console.
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* mini_al.h - Audio device management lib (http://kcat.strangesoft.net/openal.html)
|
||||||
|
* stb_vorbis.h - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||||
|
* jar_xm.h - XM module file loading
|
||||||
|
* jar_mod.h - MOD audio file loading
|
||||||
|
* dr_flac.h - FLAC audio file loading
|
||||||
|
*
|
||||||
|
* COMPILATION:
|
||||||
|
* gcc -c ..\..\src\external\mini_al.c -Wall -I.
|
||||||
|
* gcc -o audio_standalone.exe audio_standalone.c ..\..\src\raudio.c mini_al.o /
|
||||||
|
* -I..\..\src -I..\..\src\external -L. -Wall -std=c99 /
|
||||||
|
* -DAUDIO_STANDALONE -DSUPPORT_FILEFORMAT_WAV -DSUPPORT_FILEFORMAT_OGG
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* This example is 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) 2014-2019 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
|
* will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||||
|
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||||
|
* in the product documentation would be appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||||
|
* as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raudio.h" // raylib audio library
|
||||||
|
|
||||||
|
#include <stdio.h> // Required for: printf()
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <conio.h> // Windows only, no stardard library
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Provide kbhit() function in non-Windows platforms
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
// Check if a key has been pressed
|
||||||
|
static int kbhit(void)
|
||||||
|
{
|
||||||
|
struct termios oldt, newt;
|
||||||
|
int ch;
|
||||||
|
int oldf;
|
||||||
|
|
||||||
|
tcgetattr(STDIN_FILENO, &oldt);
|
||||||
|
newt = oldt;
|
||||||
|
newt.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||||
|
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||||
|
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
||||||
|
|
||||||
|
ch = getchar();
|
||||||
|
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||||
|
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
||||||
|
|
||||||
|
if (ch != EOF)
|
||||||
|
{
|
||||||
|
ungetc(ch, stdin);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get pressed character
|
||||||
|
static char getch() { return getchar(); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define KEY_ESCAPE 27
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
static unsigned char key;
|
||||||
|
|
||||||
|
InitAudioDevice();
|
||||||
|
|
||||||
|
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
|
||||||
|
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
|
||||||
|
|
||||||
|
Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
|
||||||
|
PlayMusicStream(music);
|
||||||
|
|
||||||
|
printf("\nPress s or d to play sounds...\n");
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
while (key != KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
if (kbhit()) key = getch();
|
||||||
|
|
||||||
|
if (key == 's')
|
||||||
|
{
|
||||||
|
PlaySound(fxWav);
|
||||||
|
key = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'd')
|
||||||
|
{
|
||||||
|
PlaySound(fxOgg);
|
||||||
|
key = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateMusicStream(music);
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadSound(fxWav); // Unload sound data
|
||||||
|
UnloadSound(fxOgg); // Unload sound data
|
||||||
|
|
||||||
|
UnloadMusicStream(music); // Unload music stream data
|
||||||
|
|
||||||
|
CloseAudioDevice();
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -23,14 +23,14 @@ gcc -O2 -c shapes.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
gcc -O2 -c textures.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
gcc -O2 -c textures.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
gcc -O2 -c text.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
gcc -O2 -c text.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
gcc -O2 -c models.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
gcc -O2 -c models.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
gcc -O2 -c audio.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
gcc -O2 -c raudio.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
gcc -O2 -c external/mini_al.c -Wall -I.
|
gcc -O2 -c external/mini_al.c -Wall -I.
|
||||||
gcc -O2 -c utils.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
gcc -O2 -c utils.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||||
|
|
||||||
:: .
|
:: .
|
||||||
:: . > Generate raylib library
|
:: . > Generate raylib library
|
||||||
:: ------------------------------
|
:: ------------------------------
|
||||||
ar rcs libraylib.a core.o rglfw.o shapes.o textures.o text.o models.o audio.o mini_al.o utils.o
|
ar rcs libraylib.a core.o rglfw.o shapes.o textures.o text.o models.o raudio.o mini_al.o utils.o
|
||||||
:: .
|
:: .
|
||||||
:: > Installing raylib library
|
:: > Installing raylib library
|
||||||
:: -----------------------------
|
:: -----------------------------
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -114,7 +114,7 @@ if [ ! -d "$TEMP_DIR" ]; then
|
||||||
mkdir -p $TEMP_DIR
|
mkdir -p $TEMP_DIR
|
||||||
cd $TEMP_DIR
|
cd $TEMP_DIR
|
||||||
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
||||||
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/audio.c $RAYLIB_SRC/rglfw.c $RAYLIB_SRC/external/mini_al.c"
|
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c $RAYLIB_SRC/rglfw.c $RAYLIB_SRC/external/mini_al.c"
|
||||||
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
||||||
|
|
||||||
if [ -n "$REALLY_QUIET" ]; then
|
if [ -n "$REALLY_QUIET" ]; then
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ if [ ! -d "$TEMP_DIR" ]; then
|
||||||
mkdir -p $TEMP_DIR
|
mkdir -p $TEMP_DIR
|
||||||
cd $TEMP_DIR
|
cd $TEMP_DIR
|
||||||
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
||||||
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/audio.c $RAYLIB_SRC/external/mini_al.c"
|
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c $RAYLIB_SRC/external/mini_al.c"
|
||||||
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
||||||
|
|
||||||
if [ -n "$REALLY_QUIET" ]; then
|
if [ -n "$REALLY_QUIET" ]; then
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ IF NOT EXIST !TEMP_DIR!\ (
|
||||||
cd !TEMP_DIR!
|
cd !TEMP_DIR!
|
||||||
REM Raylib's src folder
|
REM Raylib's src folder
|
||||||
set "RAYLIB_DEFINES=/D_DEFAULT_SOURCE /DPLATFORM_DESKTOP /DGRAPHICS_API_OPENGL_33"
|
set "RAYLIB_DEFINES=/D_DEFAULT_SOURCE /DPLATFORM_DESKTOP /DGRAPHICS_API_OPENGL_33"
|
||||||
set RAYLIB_C_FILES="!RAYLIB_SRC!\core.c" "!RAYLIB_SRC!\shapes.c" "!RAYLIB_SRC!\textures.c" "!RAYLIB_SRC!\text.c" "!RAYLIB_SRC!\models.c" "!RAYLIB_SRC!\utils.c" "!RAYLIB_SRC!\audio.c" "!RAYLIB_SRC!\rglfw.c" "!RAYLIB_SRC!\external\mini_al.c"
|
set RAYLIB_C_FILES="!RAYLIB_SRC!\core.c" "!RAYLIB_SRC!\shapes.c" "!RAYLIB_SRC!\textures.c" "!RAYLIB_SRC!\text.c" "!RAYLIB_SRC!\models.c" "!RAYLIB_SRC!\utils.c" "!RAYLIB_SRC!\raudio.c" "!RAYLIB_SRC!\rglfw.c" "!RAYLIB_SRC!\external\mini_al.c"
|
||||||
set RAYLIB_INCLUDE_FLAGS=/I"!RAYLIB_SRC!" /I"!RAYLIB_SRC!\external\glfw\include"
|
set RAYLIB_INCLUDE_FLAGS=/I"!RAYLIB_SRC!" /I"!RAYLIB_SRC!\external\glfw\include"
|
||||||
|
|
||||||
IF DEFINED REALLY_QUIET (
|
IF DEFINED REALLY_QUIET (
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ if(USE_AUDIO)
|
||||||
else()
|
else()
|
||||||
MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
|
MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
|
||||||
set(INCLUDE_AUDIO_MODULE 0)
|
set(INCLUDE_AUDIO_MODULE 0)
|
||||||
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio.c)
|
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/raudio.c)
|
||||||
set(sources ${raylib_sources})
|
set(sources ${raylib_sources})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -250,7 +250,7 @@ file(COPY "raylib.h" DESTINATION ".")
|
||||||
file(COPY "rlgl.h" DESTINATION ".")
|
file(COPY "rlgl.h" DESTINATION ".")
|
||||||
file(COPY "physac.h" DESTINATION ".")
|
file(COPY "physac.h" DESTINATION ".")
|
||||||
file(COPY "raymath.h" DESTINATION ".")
|
file(COPY "raymath.h" DESTINATION ".")
|
||||||
file(COPY "audio.h" DESTINATION ".")
|
file(COPY "raudio.h" DESTINATION ".")
|
||||||
|
|
||||||
# Print the flags for the user
|
# Print the flags for the user
|
||||||
message(STATUS "Compiling with the flags:")
|
message(STATUS "Compiling with the flags:")
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON)
|
||||||
option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON)
|
option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON)
|
||||||
option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON)
|
option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON)
|
||||||
|
|
||||||
# audio.c
|
# raudio.c
|
||||||
option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON)
|
option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON)
|
||||||
option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON)
|
option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON)
|
||||||
option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON)
|
option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON)
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(INCLUDE_AUDIO_MODULE),TRUE)
|
ifeq ($(INCLUDE_AUDIO_MODULE),TRUE)
|
||||||
OBJS += audio.o
|
OBJS += raudio.o
|
||||||
OBJS += mini_al.o
|
OBJS += mini_al.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -529,7 +529,7 @@ models.o : models.c raylib.h rlgl.h raymath.h
|
||||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||||
|
|
||||||
# Compile audio module
|
# Compile audio module
|
||||||
audio.o : audio.c raylib.h
|
raudio.o : raudio.c raylib.h
|
||||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
|
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
|
||||||
|
|
||||||
# Compile mini_al audio library
|
# Compile mini_al audio library
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#define RAYLIB_VERSION "2.3-dev"
|
#define RAYLIB_VERSION "2.4-dev"
|
||||||
|
|
||||||
// Edit to control what features Makefile'd raylib is compiled with
|
// Edit to control what features Makefile'd raylib is compiled with
|
||||||
#if defined(RAYLIB_CMAKE)
|
#if defined(RAYLIB_CMAKE)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
* NOTE: Some generated meshes DO NOT include generated texture coordinates */
|
* NOTE: Some generated meshes DO NOT include generated texture coordinates */
|
||||||
#cmakedefine SUPPORT_MESH_GENERATION 1
|
#cmakedefine SUPPORT_MESH_GENERATION 1
|
||||||
|
|
||||||
// audio.c
|
// raudio.c
|
||||||
/* Desired fileformats to be supported for loading. */
|
/* Desired fileformats to be supported for loading. */
|
||||||
#cmakedefine SUPPORT_FILEFORMAT_WAV 1
|
#cmakedefine SUPPORT_FILEFORMAT_WAV 1
|
||||||
#cmakedefine SUPPORT_FILEFORMAT_OGG 1
|
#cmakedefine SUPPORT_FILEFORMAT_OGG 1
|
||||||
|
|
|
||||||
BIN
src/libraylib.a
Normal file
BIN
src/libraylib.a
Normal file
Binary file not shown.
1958
src/raudio.c
Normal file
1958
src/raudio.c
Normal file
File diff suppressed because it is too large
Load diff
182
src/raudio.h
Normal file
182
src/raudio.h
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
/**********************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib.audio - Basic funtionality to work with audio
|
||||||
|
*
|
||||||
|
* FEATURES:
|
||||||
|
* - Manage audio device (init/close)
|
||||||
|
* - Load and unload audio files
|
||||||
|
* - Format wave data (sample rate, size, channels)
|
||||||
|
* - Play/Stop/Pause/Resume loaded audio
|
||||||
|
* - Manage mixing channels
|
||||||
|
* - Manage raw audio context
|
||||||
|
*
|
||||||
|
* LIMITATIONS (only OpenAL Soft):
|
||||||
|
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
|
||||||
|
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* mini_al - Audio device/context management (https://github.com/dr-soft/mini_al)
|
||||||
|
* stb_vorbis - OGG audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||||
|
* jar_xm - XM module file loading
|
||||||
|
* jar_mod - MOD audio file loading
|
||||||
|
* dr_flac - FLAC audio file loading
|
||||||
|
*
|
||||||
|
* *OpenAL Soft - Audio device management, still used on HTML5 and OSX platforms
|
||||||
|
*
|
||||||
|
* CONTRIBUTORS:
|
||||||
|
* David Reid (github: @mackron) (Nov. 2017):
|
||||||
|
* - Complete port to mini_al library
|
||||||
|
*
|
||||||
|
* Joshua Reisenauer (github: @kd7tck) (2015)
|
||||||
|
* - XM audio module support (jar_xm)
|
||||||
|
* - MOD audio module support (jar_mod)
|
||||||
|
* - Mixing channels support
|
||||||
|
* - Raw audio context support
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
|
* will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||||
|
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||||
|
* in the product documentation would be appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||||
|
* as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AUDIO_H
|
||||||
|
#define AUDIO_H
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Defines and Macros
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
//...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
// NOTE: Below types are required for CAMERA_STANDALONE usage
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
#ifndef __cplusplus
|
||||||
|
// Boolean type
|
||||||
|
#if !defined(_STDBOOL_H)
|
||||||
|
typedef enum { false, true } bool;
|
||||||
|
#define _STDBOOL_H
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Wave type, defines audio wave data
|
||||||
|
typedef struct Wave {
|
||||||
|
unsigned int sampleCount; // Number of samples
|
||||||
|
unsigned int sampleRate; // Frequency (samples per second)
|
||||||
|
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||||
|
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||||
|
void *data; // Buffer data pointer
|
||||||
|
} Wave;
|
||||||
|
|
||||||
|
// Sound source type
|
||||||
|
typedef struct Sound {
|
||||||
|
void *audioBuffer; // Pointer to internal data used by the audio system
|
||||||
|
|
||||||
|
unsigned int source; // Audio source id
|
||||||
|
unsigned int buffer; // Audio buffer id
|
||||||
|
int format; // Audio format specifier
|
||||||
|
} Sound;
|
||||||
|
|
||||||
|
// Music type (file streaming from memory)
|
||||||
|
// NOTE: Anything longer than ~10 seconds should be streamed
|
||||||
|
typedef struct MusicData *Music;
|
||||||
|
|
||||||
|
// Audio stream type
|
||||||
|
// NOTE: Useful to create custom audio streams not bound to a specific file
|
||||||
|
typedef struct AudioStream {
|
||||||
|
unsigned int sampleRate; // Frequency (samples per second)
|
||||||
|
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||||
|
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||||
|
|
||||||
|
void *audioBuffer; // Pointer to internal data used by the audio system.
|
||||||
|
|
||||||
|
int format; // Audio format specifier
|
||||||
|
unsigned int source; // Audio source id
|
||||||
|
unsigned int buffers[2]; // Audio buffers (double buffering)
|
||||||
|
} AudioStream;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" { // Prevents name mangling of functions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
//...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
void InitAudioDevice(void); // Initialize audio device and context
|
||||||
|
void CloseAudioDevice(void); // Close the audio device and context
|
||||||
|
bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||||
|
void SetMasterVolume(float volume); // Set master volume (listener)
|
||||||
|
|
||||||
|
Wave LoadWave(const char *fileName); // Load wave data from file
|
||||||
|
Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||||
|
Sound LoadSound(const char *fileName); // Load sound from file
|
||||||
|
Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
||||||
|
void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||||
|
void UnloadWave(Wave wave); // Unload wave data
|
||||||
|
void UnloadSound(Sound sound); // Unload sound
|
||||||
|
void PlaySound(Sound sound); // Play a sound
|
||||||
|
void PauseSound(Sound sound); // Pause a sound
|
||||||
|
void ResumeSound(Sound sound); // Resume a paused sound
|
||||||
|
void StopSound(Sound sound); // Stop playing a sound
|
||||||
|
bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
|
||||||
|
void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
|
||||||
|
void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
|
||||||
|
void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
|
||||||
|
Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||||
|
void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||||
|
float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||||
|
Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||||
|
void UnloadMusicStream(Music music); // Unload music stream
|
||||||
|
void PlayMusicStream(Music music); // Start music playing
|
||||||
|
void UpdateMusicStream(Music music); // Updates buffers for music streaming
|
||||||
|
void StopMusicStream(Music music); // Stop music playing
|
||||||
|
void PauseMusicStream(Music music); // Pause music playing
|
||||||
|
void ResumeMusicStream(Music music); // Resume playing paused music
|
||||||
|
bool IsMusicPlaying(Music music); // Check if music is playing
|
||||||
|
void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
||||||
|
void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||||
|
void SetMusicLoopCount(Music music, int count); // Set music loop count (loop repeats)
|
||||||
|
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||||
|
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||||
|
|
||||||
|
// AudioStream management functions
|
||||||
|
AudioStream InitAudioStream(unsigned int sampleRate,
|
||||||
|
unsigned int sampleSize,
|
||||||
|
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||||
|
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||||
|
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||||
|
bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
||||||
|
void PlayAudioStream(AudioStream stream); // Play audio stream
|
||||||
|
void PauseAudioStream(AudioStream stream); // Pause audio stream
|
||||||
|
void ResumeAudioStream(AudioStream stream); // Resume audio stream
|
||||||
|
bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing
|
||||||
|
void StopAudioStream(AudioStream stream); // Stop audio stream
|
||||||
|
void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)
|
||||||
|
void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // AUDIO_H
|
||||||
Loading…
Reference in a new issue