summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2021-05-07 15:38:13 +0200
committerRay <[email protected]>2021-05-07 15:38:13 +0200
commitb62c86572e58c95e23c19d03e9b0bdacfa214f80 (patch)
treedbffb580833b21fb37326c9e59a8fe104475eaf9 /src
parentc82d9cb89a4aec4485441887f8b74fff06494be5 (diff)
downloadraylib-b62c86572e58c95e23c19d03e9b0bdacfa214f80.tar.gz
raylib-b62c86572e58c95e23c19d03e9b0bdacfa214f80.zip
REVIEWED: raudio_standalone #1752
Diffstat (limited to 'src')
-rw-r--r--src/raudio.c54
-rw-r--r--src/raudio.h12
2 files changed, 57 insertions, 9 deletions
diff --git a/src/raudio.c b/src/raudio.c
index 2b6b0a19..5db2407a 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -385,6 +385,10 @@ static Wave LoadMP3(const unsigned char *fileData, unsigned int fileSize); //
#if defined(RAUDIO_STANDALONE)
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 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
@@ -1587,11 +1591,11 @@ void StopMusicStream(Music music)
// Update (re-fill) music buffers if data already processed
void UpdateMusicStream(Music music)
{
- if (music.stream.buffer == NULL)
- return;
+ if (music.stream.buffer == NULL) return;
- if (music.ctxType == MUSIC_MODULE_XM)
- jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1);
+#if defined(SUPPORT_FILEFORMAT_XM)
+ if (music.ctxType == MUSIC_MODULE_XM) jar_xm_set_max_loop_count(music.ctxData, music.looping ? 0 : 1);
+#endif
bool streamEnding = false;
@@ -2327,6 +2331,48 @@ static bool IsFileExtension(const char *fileName, const char *ext)
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
static unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
{
diff --git a/src/raudio.h b/src/raudio.h
index cf8b767a..e37f4b27 100644
--- a/src/raudio.h
+++ b/src/raudio.h
@@ -138,13 +138,14 @@ void SetMasterVolume(float volume); // Set master vo
// Wave/Sound loading/unloading functions
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 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 ExportWave(Wave wave, const char *fileName); // Export wave data to file
-void ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h)
+bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success
+bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success
// Wave/Sound management functions
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
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
+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 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 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 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)
float GetMusicTimeLength(Music music); // Get music time length (in seconds)