summaryrefslogtreecommitdiffhomepage
path: root/src/audio.h
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2016-11-18 13:39:57 +0100
committerraysan5 <[email protected]>2016-11-18 13:39:57 +0100
commitf7b706263a820034a93ab88e7582b7001819d8d0 (patch)
treedec39c4e98c119b151be962ba3706042b285c39a /src/audio.h
parentc7f0350182b6c0b46daaaff232789acc4c7ab4f1 (diff)
downloadraylib-f7b706263a820034a93ab88e7582b7001819d8d0.tar.gz
raylib-f7b706263a820034a93ab88e7582b7001819d8d0.zip
Some code tweaks
Correcting details that pop-up when testing the different platforms
Diffstat (limited to 'src/audio.h')
-rw-r--r--src/audio.h39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/audio.h b/src/audio.h
index 5de8f613..2b3c5933 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -62,12 +62,6 @@
#endif
#endif
-// Sound source type
-typedef struct Sound {
- unsigned int source; // Sound audio source id
- unsigned int buffer; // Sound audio buffer id
-} Sound;
-
// Wave type, defines audio wave data
typedef struct Wave {
unsigned int sampleCount; // Number of samples
@@ -77,9 +71,16 @@ typedef struct Wave {
void *data; // Buffer data pointer
} Wave;
+// Sound source type
+typedef struct Sound {
+ unsigned int source; // OpenAL audio source id
+ unsigned int buffer; // OpenAL audio buffer id
+ int format; // OpenAL audio format specifier
+} Sound;
+
// Music type (file streaming from memory)
// NOTE: Anything longer than ~10 seconds should be streamed
-typedef struct Music *Music;
+typedef struct MusicData *Music;
// Audio stream type
// NOTE: Useful to create custom audio streams not bound to a specific file
@@ -106,13 +107,16 @@ extern "C" { // Prevents name mangling of functions
// Module Functions Declaration
//----------------------------------------------------------------------------------
void InitAudioDevice(void); // Initialize audio device and context
-void CloseAudioDevice(void); // Close the audio device and context (and music stream)
+void CloseAudioDevice(void); // Close the audio device and context
bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
-Sound LoadSound(char *fileName); // Load sound to memory
+Wave LoadWave(const char *fileName); // Load wave data from file into RAM
+Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from float array data (32bit)
+Sound LoadSound(const 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 UpdateSound(Sound sound, void *data, int numSamples); // 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
@@ -121,12 +125,15 @@ void StopSound(Sound sound); // Stop playing
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)
-
-Music LoadMusicStream(char *fileName); // Load music stream from file
+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 (open stream)
+void PlayMusicStream(Music music); // Start music playing
void UpdateMusicStream(Music music); // Updates buffers for music streaming
-void StopMusicStream(Music music); // Stop music playing (close stream)
+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
@@ -135,9 +142,9 @@ void SetMusicPitch(Music music, float pitch); // Set pitch for
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
-AudioStream InitAudioStream(unsigned int sampleRate,
- unsigned int sampleSize,
- unsigned int channels); // Init audio stream (to stream audio pcm data)
+AudioStream InitAudioStream(unsigned int sampleRate,
+ unsigned int sampleSize,
+ unsigned int channels); // Init audio stream (to stream raw audio pcm data)
void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // 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