REVIEWED: raudio_standalone #1752
This commit is contained in:
parent
c82d9cb89a
commit
b62c86572e
3 changed files with 58 additions and 10 deletions
|
@ -61,7 +61,7 @@
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if !defined(_MSC_VER)
|
#if !defined(_WIN32)
|
||||||
static int kbhit(void); // Check if a key has been pressed
|
static int kbhit(void); // Check if a key has been pressed
|
||||||
static char getch(); // Get pressed character
|
static char getch(); // Get pressed character
|
||||||
#else
|
#else
|
||||||
|
|
54
src/raudio.c
54
src/raudio.c
|
@ -385,6 +385,10 @@ static Wave LoadMP3(const unsigned char *fileData, unsigned int fileSize); //
|
||||||
|
|
||||||
#if defined(RAUDIO_STANDALONE)
|
#if defined(RAUDIO_STANDALONE)
|
||||||
static bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
|
static bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
|
||||||
|
static const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes the dot: .png)
|
||||||
|
static bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
|
||||||
|
static const char *TextToLower(const char *text); // Get lower case version of provided string
|
||||||
|
|
||||||
static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
|
static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
|
||||||
static bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write)
|
static bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write)
|
||||||
static bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated
|
static bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated
|
||||||
|
@ -1587,11 +1591,11 @@ void StopMusicStream(Music music)
|
||||||
// Update (re-fill) music buffers if data already processed
|
// Update (re-fill) music buffers if data already processed
|
||||||
void UpdateMusicStream(Music music)
|
void UpdateMusicStream(Music music)
|
||||||
{
|
{
|
||||||
if (music.stream.buffer == NULL)
|
if (music.stream.buffer == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (music.ctxType == MUSIC_MODULE_XM)
|
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||||
jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1);
|
if (music.ctxType == MUSIC_MODULE_XM) jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool streamEnding = false;
|
bool streamEnding = false;
|
||||||
|
|
||||||
|
@ -2327,6 +2331,48 @@ static bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get pointer to extension for a filename string (includes the dot: .png)
|
||||||
|
static const char *GetFileExtension(const char *fileName)
|
||||||
|
{
|
||||||
|
const char *dot = strrchr(fileName, '.');
|
||||||
|
|
||||||
|
if (!dot || dot == fileName) return NULL;
|
||||||
|
|
||||||
|
return dot;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if two text string are equal
|
||||||
|
// REQUIRES: strcmp()
|
||||||
|
static bool TextIsEqual(const char *text1, const char *text2)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
if (strcmp(text1, text2) == 0) result = true;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get lower case version of provided string
|
||||||
|
// REQUIRES: tolower()
|
||||||
|
static const char *TextToLower(const char *text)
|
||||||
|
{
|
||||||
|
#define MAX_TEXT_BUFFER_LENGTH 1024
|
||||||
|
|
||||||
|
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)
|
||||||
|
{
|
||||||
|
if (text[i] != '\0')
|
||||||
|
{
|
||||||
|
buffer[i] = (char)tolower(text[i]);
|
||||||
|
//if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32;
|
||||||
|
}
|
||||||
|
else { buffer[i] = '\0'; break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
// Load data from file into a buffer
|
// Load data from file into a buffer
|
||||||
static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
|
static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
|
||||||
{
|
{
|
||||||
|
|
12
src/raudio.h
12
src/raudio.h
|
@ -138,13 +138,14 @@ void SetMasterVolume(float volume); // Set master vo
|
||||||
|
|
||||||
// Wave/Sound loading/unloading functions
|
// Wave/Sound loading/unloading functions
|
||||||
Wave LoadWave(const char *fileName); // Load wave data from file
|
Wave LoadWave(const char *fileName); // Load wave data from file
|
||||||
|
Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. ".wav"
|
||||||
Sound LoadSound(const char *fileName); // Load sound from file
|
Sound LoadSound(const char *fileName); // Load sound from file
|
||||||
Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
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 UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||||
void UnloadWave(Wave wave); // Unload wave data
|
void UnloadWave(Wave wave); // Unload wave data
|
||||||
void UnloadSound(Sound sound); // Unload sound
|
void UnloadSound(Sound sound); // Unload sound
|
||||||
void ExportWave(Wave wave, const char *fileName); // Export wave data to file
|
bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success
|
||||||
void ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h)
|
bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success
|
||||||
|
|
||||||
// Wave/Sound management functions
|
// Wave/Sound management functions
|
||||||
void PlaySound(Sound sound); // Play a sound
|
void PlaySound(Sound sound); // Play a sound
|
||||||
|
@ -160,18 +161,19 @@ void SetSoundPitch(Sound sound, float pitch); // Set pitch for
|
||||||
void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
|
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
|
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
|
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
|
float *LoadWaveSamples(Wave wave); // Load samples data from wave as a floats array
|
||||||
|
void UnloadWaveSamples(float *samples); // Unload samples data loaded with LoadWaveSamples()
|
||||||
|
|
||||||
// Music management functions
|
// Music management functions
|
||||||
Music LoadMusicStream(const char *fileName); // Load music stream from file
|
Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||||
Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize); // Load module music from data
|
Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize); // Load music stream from data
|
||||||
void UnloadMusicStream(Music music); // Unload music stream
|
void UnloadMusicStream(Music music); // Unload music stream
|
||||||
void PlayMusicStream(Music music); // Start music playing
|
void PlayMusicStream(Music music); // Start music playing
|
||||||
|
bool IsMusicPlaying(Music music); // Check if music is playing
|
||||||
void UpdateMusicStream(Music music); // Updates buffers for music streaming
|
void UpdateMusicStream(Music music); // Updates buffers for music streaming
|
||||||
void StopMusicStream(Music music); // Stop music playing
|
void StopMusicStream(Music music); // Stop music playing
|
||||||
void PauseMusicStream(Music music); // Pause music playing
|
void PauseMusicStream(Music music); // Pause music playing
|
||||||
void ResumeMusicStream(Music music); // Resume playing paused music
|
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 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 SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||||
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue