aboutsummaryrefslogtreecommitdiff
path: root/raylib/src/raudio.c
diff options
context:
space:
mode:
Diffstat (limited to 'raylib/src/raudio.c')
-rw-r--r--raylib/src/raudio.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/raylib/src/raudio.c b/raylib/src/raudio.c
index 8216897..19794f7 100644
--- a/raylib/src/raudio.c
+++ b/raylib/src/raudio.c
@@ -536,6 +536,14 @@ void SetMasterVolume(float volume)
ma_device_set_master_volume(&AUDIO.System.device, volume);
}
+// Get master volume (listener)
+float GetMasterVolume(void)
+{
+ float volume = 0.0f;
+ ma_device_get_master_volume(&AUDIO.System.device, &volume);
+ return volume;
+}
+
//----------------------------------------------------------------------------------
// Module Functions Definition - Audio Buffer management
//----------------------------------------------------------------------------------
@@ -920,7 +928,6 @@ Sound LoadSoundFromWave(Wave wave)
}
// Clone sound from existing sound data, clone does not own wave data
-// Wave data must
// NOTE: Wave data must be unallocated manually and will be shared across all clones
Sound LoadSoundAlias(Sound source)
{
@@ -928,13 +935,16 @@ Sound LoadSoundAlias(Sound source)
if (source.stream.buffer->data != NULL)
{
- AudioBuffer* audioBuffer = LoadAudioBuffer(AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, source.frameCount, AUDIO_BUFFER_USAGE_STATIC);
+ AudioBuffer* audioBuffer = LoadAudioBuffer(AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, 0, AUDIO_BUFFER_USAGE_STATIC);
if (audioBuffer == NULL)
{
TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer");
return sound; // early return to avoid dereferencing the audioBuffer null pointer
}
+ audioBuffer->sizeInFrames = source.stream.buffer->sizeInFrames;
+ audioBuffer->volume = source.stream.buffer->volume;
audioBuffer->data = source.stream.buffer->data;
+
sound.frameCount = source.frameCount;
sound.stream.sampleRate = AUDIO.System.device.sampleRate;
sound.stream.sampleSize = 32;
@@ -945,6 +955,7 @@ Sound LoadSoundAlias(Sound source)
return sound;
}
+
// Checks if a sound is ready
bool IsSoundReady(Sound sound)
{
@@ -1786,7 +1797,14 @@ void SeekMusicStream(Music music, float position)
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
#endif
#if defined(SUPPORT_FILEFORMAT_QOA)
- case MUSIC_AUDIO_QOA: qoaplay_seek_frame((qoaplay_desc *)music.ctxData, positionInFrames); break;
+ case MUSIC_AUDIO_QOA:
+ {
+ int qoaFrame = positionInFrames/QOA_FRAME_LEN;
+ qoaplay_seek_frame((qoaplay_desc *)music.ctxData, qoaFrame); // Seeks to QOA frame, not PCM frame
+
+ // We need to compute QOA frame number and update positionInFrames
+ positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position;
+ } break;
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
@@ -1867,7 +1885,7 @@ void UpdateMusicStream(Music music)
frameCountReadTotal += frameCountRead;
frameCountStillNeeded -= frameCountRead;
if (frameCountStillNeeded == 0) break;
- else stb_vorbis_seek_start((stb_vorbis *)music.ctxData);
+ else SeekMusicStream(music, music.loopPoint);
}
} break;
#endif
@@ -1887,18 +1905,10 @@ void UpdateMusicStream(Music music)
#if defined(SUPPORT_FILEFORMAT_QOA)
case MUSIC_AUDIO_QOA:
{
- unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream);
- frameCountReadTotal += frameCountRead;
- /*
- while (true)
- {
- int frameCountRead = (int)qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize), frameCountStillNeeded);
- frameCountReadTotal += frameCountRead;
- frameCountStillNeeded -= frameCountRead;
- if (frameCountStillNeeded == 0) break;
- else qoaplay_rewind((qoaplay_desc *)music.ctxData);
- }
- */
+ int qoaFrame = (int)(music.loopPoint * music.stream.sampleRate)/QOA_FRAME_LEN;
+ unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream, qoaFrame);
+ frameCountReadTotal += frameCountRead;
+
} break;
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
@@ -1949,8 +1959,6 @@ void UpdateMusicStream(Music music)
StopMusicStream(music);
return;
}
-
- SeekMusicStream(music, music.loopPoint);
}
}