mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 06:13:10 +00:00
WARNING: BREAKING: Redesigned SetSoundPan() and SetMusicPan() #5350
Now it goes from -1.0 (full left) to 1.0 (full right) being 0.0 center
This commit is contained in:
parent
67f24b3b41
commit
ba65bd7f99
12
src/raudio.c
12
src/raudio.c
@ -593,7 +593,7 @@ AudioBuffer *LoadAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam
|
|||||||
// Init audio buffer values
|
// Init audio buffer values
|
||||||
audioBuffer->volume = 1.0f;
|
audioBuffer->volume = 1.0f;
|
||||||
audioBuffer->pitch = 1.0f;
|
audioBuffer->pitch = 1.0f;
|
||||||
audioBuffer->pan = 0.5f;
|
audioBuffer->pan = 0.0f; // Center
|
||||||
|
|
||||||
audioBuffer->callback = NULL;
|
audioBuffer->callback = NULL;
|
||||||
audioBuffer->processor = NULL;
|
audioBuffer->processor = NULL;
|
||||||
@ -720,7 +720,7 @@ void SetAudioBufferPitch(AudioBuffer *buffer, float pitch)
|
|||||||
// Set pan for an audio buffer
|
// Set pan for an audio buffer
|
||||||
void SetAudioBufferPan(AudioBuffer *buffer, float pan)
|
void SetAudioBufferPan(AudioBuffer *buffer, float pan)
|
||||||
{
|
{
|
||||||
if (pan < 0.0f) pan = 0.0f;
|
if (pan < -1.0f) pan = -1.0f;
|
||||||
else if (pan > 1.0f) pan = 1.0f;
|
else if (pan > 1.0f) pan = 1.0f;
|
||||||
|
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
@ -985,10 +985,10 @@ Sound LoadSoundAlias(Sound source)
|
|||||||
audioBuffer->sizeInFrames = source.stream.buffer->sizeInFrames;
|
audioBuffer->sizeInFrames = source.stream.buffer->sizeInFrames;
|
||||||
audioBuffer->data = source.stream.buffer->data;
|
audioBuffer->data = source.stream.buffer->data;
|
||||||
|
|
||||||
// initalize the buffer as if it was new
|
// Initalize the buffer as if it was new
|
||||||
audioBuffer->volume = 1.0f;
|
audioBuffer->volume = 1.0f;
|
||||||
audioBuffer->pitch = 1.0f;
|
audioBuffer->pitch = 1.0f;
|
||||||
audioBuffer->pan = 0.5f;
|
audioBuffer->pan = 0.0f; // Center
|
||||||
|
|
||||||
sound.frameCount = source.frameCount;
|
sound.frameCount = source.frameCount;
|
||||||
sound.stream.sampleRate = AUDIO.System.device.sampleRate;
|
sound.stream.sampleRate = AUDIO.System.device.sampleRate;
|
||||||
@ -2605,8 +2605,8 @@ static void MixAudioFrames(float *framesOut, const float *framesIn, ma_uint32 fr
|
|||||||
|
|
||||||
if (channels == 2) // We consider panning
|
if (channels == 2) // We consider panning
|
||||||
{
|
{
|
||||||
const float left = buffer->pan;
|
const float right = (buffer->pan + 1.0f)/2.0f; // Normalize: [-1..1] -> [0..1]
|
||||||
const float right = 1.0f - left;
|
const float left = 1.0f - right;
|
||||||
|
|
||||||
// Fast sine approximation in [0..1] for pan law: y = 0.5f*x*(3 - x*x);
|
// Fast sine approximation in [0..1] for pan law: y = 0.5f*x*(3 - x*x);
|
||||||
const float levels[2] = { localVolume*0.5f*left*(3.0f - left*left), localVolume*0.5f*right*(3.0f - right*right) };
|
const float levels[2] = { localVolume*0.5f*left*(3.0f - left*left), localVolume*0.5f*right*(3.0f - right*right) };
|
||||||
|
|||||||
@ -1672,7 +1672,7 @@ RLAPI void ResumeSound(Sound sound); // Resume
|
|||||||
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
|
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
|
||||||
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
|
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
|
||||||
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
|
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
|
||||||
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center)
|
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
|
||||||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||||
RLAPI void WaveCrop(Wave *wave, int initFrame, int finalFrame); // Crop a wave to defined frames range
|
RLAPI void WaveCrop(Wave *wave, int initFrame, int finalFrame); // Crop a wave to defined frames range
|
||||||
RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
|
RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
|
||||||
@ -1693,7 +1693,7 @@ RLAPI void ResumeMusicStream(Music music); // Resume
|
|||||||
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
|
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
|
||||||
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
||||||
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||||
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center)
|
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
|
||||||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user