2015-07-29 22:41:19 +03:00
|
|
|
/**********************************************************************************************
|
|
|
|
*
|
|
|
|
* raylib.audio
|
|
|
|
*
|
2016-07-15 19:16:34 +03:00
|
|
|
* Basic functions to manage Audio:
|
|
|
|
* Manage audio device (init/close)
|
|
|
|
* Load and Unload audio files
|
|
|
|
* Play/Stop/Pause/Resume loaded audio
|
|
|
|
* Manage mixing channels
|
|
|
|
* Manage raw audio context
|
2015-07-29 22:41:19 +03:00
|
|
|
*
|
|
|
|
* Uses external lib:
|
|
|
|
* OpenAL Soft - Audio device management lib (http://kcat.strangesoft.net/openal.html)
|
|
|
|
* stb_vorbis - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
2016-07-15 19:16:34 +03:00
|
|
|
* jar_xm - XM module file loading
|
|
|
|
* jar_mod - MOD audio file loading
|
2015-07-29 22:41:19 +03:00
|
|
|
*
|
2016-07-15 19:16:34 +03:00
|
|
|
* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions:
|
|
|
|
* XM audio module support (jar_xm)
|
|
|
|
* MOD audio module support (jar_mod)
|
|
|
|
* Mixing channels support
|
|
|
|
* Raw audio context support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
2015-07-29 22:41:19 +03:00
|
|
|
*
|
|
|
|
* 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
|
2016-06-02 06:09:00 +03:00
|
|
|
#if !defined(_STDBOOL_H)
|
2016-04-30 09:00:12 +03:00
|
|
|
typedef enum { false, true } bool;
|
2016-06-02 06:09:00 +03:00
|
|
|
#define _STDBOOL_H
|
2016-04-30 09:00:12 +03:00
|
|
|
#endif
|
2015-07-29 22:41:19 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Sound source type
|
|
|
|
typedef struct Sound {
|
|
|
|
unsigned int source;
|
|
|
|
unsigned int buffer;
|
2016-06-02 12:02:23 +03:00
|
|
|
AudioError error; // if there was any error during the creation or use of this Sound
|
2015-07-29 22:41:19 +03:00
|
|
|
} Sound;
|
|
|
|
|
|
|
|
// Wave type, defines audio wave data
|
|
|
|
typedef struct Wave {
|
|
|
|
void *data; // Buffer data pointer
|
|
|
|
unsigned int dataSize; // Data size in bytes
|
|
|
|
unsigned int sampleRate;
|
|
|
|
short bitsPerSample;
|
|
|
|
short channels;
|
|
|
|
} Wave;
|
|
|
|
|
|
|
|
#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 (and music stream)
|
2016-07-15 19:16:34 +03:00
|
|
|
bool IsAudioDeviceReady(void); // Check if device has been initialized successfully
|
2016-04-30 09:00:12 +03:00
|
|
|
|
2015-07-29 22:41:19 +03:00
|
|
|
Sound LoadSound(char *fileName); // Load sound to memory
|
|
|
|
Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
|
|
|
|
Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
|
|
|
|
void UnloadSound(Sound sound); // Unload sound
|
|
|
|
void PlaySound(Sound sound); // Play a sound
|
|
|
|
void PauseSound(Sound sound); // Pause a sound
|
|
|
|
void StopSound(Sound sound); // Stop playing a sound
|
2016-05-03 19:04:21 +03:00
|
|
|
bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
|
2015-07-29 22:41:19 +03:00
|
|
|
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)
|
|
|
|
|
2016-06-02 20:09:56 +03:00
|
|
|
int PlayMusicStream(int index, char *fileName); // Start music playing (open stream)
|
2016-05-12 08:37:53 +03:00
|
|
|
void UpdateMusicStream(int index); // Updates buffers for music streaming
|
2016-05-11 10:37:10 +03:00
|
|
|
void StopMusicStream(int index); // Stop music playing (close stream)
|
|
|
|
void PauseMusicStream(int index); // Pause music playing
|
|
|
|
void ResumeMusicStream(int index); // Resume playing paused music
|
2016-05-12 04:14:59 +03:00
|
|
|
bool IsMusicPlaying(int index); // Check if music is playing
|
2016-05-11 10:37:10 +03:00
|
|
|
void SetMusicVolume(int index, float volume); // Set volume for music (1.0 is max level)
|
2016-07-09 00:17:18 +03:00
|
|
|
void SetMusicPitch(int index, float pitch); // Set pitch for a music (1.0 is base level)
|
2016-05-12 08:37:53 +03:00
|
|
|
float GetMusicTimeLength(int index); // Get music time length (in seconds)
|
|
|
|
float GetMusicTimePlayed(int index); // Get current music time played (in seconds)
|
2016-07-09 00:17:18 +03:00
|
|
|
int GetMusicStreamCount(void); // Get number of streams loaded
|
2015-07-29 22:41:19 +03:00
|
|
|
|
2016-07-15 19:16:34 +03:00
|
|
|
int InitRawMixChannel(int sampleRate, int channels, bool floatingPoint); // Initialize raw audio mix channel for audio buffering
|
|
|
|
int BufferRawMixChannel(int mixc, void *data, unsigned short numberElements); // Buffers data directly to raw mix channel
|
|
|
|
void CloseRawMixChannel(int mixc); // Closes and frees raw mix channel
|
2016-05-16 05:37:15 +03:00
|
|
|
|
2015-07-29 22:41:19 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // AUDIO_H
|