Added audio function: SetMasterVolume()
This commit is contained in:
parent
734776b923
commit
ac6b4d3830
33
src/audio.c
33
src/audio.c
@ -177,9 +177,11 @@ void InitAudioDevice(void)
|
||||
TraceLog(INFO, "Audio device and context initialized successfully: %s", alcGetString(device, ALC_DEVICE_SPECIFIER));
|
||||
|
||||
// Listener definition (just for 2D)
|
||||
alListener3f(AL_POSITION, 0, 0, 0);
|
||||
alListener3f(AL_VELOCITY, 0, 0, 0);
|
||||
alListener3f(AL_ORIENTATION, 0, 0, -1);
|
||||
alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alListener3f(AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alListener3f(AL_ORIENTATION, 0.0f, 0.0f, -1.0f);
|
||||
|
||||
alListenerf(AL_GAIN, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -216,6 +218,15 @@ bool IsAudioDeviceReady(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Set master volume (listener)
|
||||
void SetMasterVolume(float volume)
|
||||
{
|
||||
if (volume < 0.0f) volume = 0.0f;
|
||||
else if (volume > 1.0f) volume = 1.0f;
|
||||
|
||||
alListenerf(AL_GAIN, volume);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Sounds loading and playing (.WAV)
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -313,10 +324,10 @@ Sound LoadSoundFromWave(Wave wave)
|
||||
ALuint source;
|
||||
alGenSources(1, &source); // Generate pointer to audio source
|
||||
|
||||
alSourcef(source, AL_PITCH, 1);
|
||||
alSourcef(source, AL_GAIN, 1);
|
||||
alSource3f(source, AL_POSITION, 0, 0, 0);
|
||||
alSource3f(source, AL_VELOCITY, 0, 0, 0);
|
||||
alSourcef(source, AL_PITCH, 1.0f);
|
||||
alSourcef(source, AL_GAIN, 1.0f);
|
||||
alSource3f(source, AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSourcei(source, AL_LOOPING, AL_FALSE);
|
||||
|
||||
// Convert loaded data to OpenAL buffer
|
||||
@ -899,10 +910,10 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||
|
||||
// Create an audio source
|
||||
alGenSources(1, &stream.source);
|
||||
alSourcef(stream.source, AL_PITCH, 1);
|
||||
alSourcef(stream.source, AL_GAIN, 1);
|
||||
alSource3f(stream.source, AL_POSITION, 0, 0, 0);
|
||||
alSource3f(stream.source, AL_VELOCITY, 0, 0, 0);
|
||||
alSourcef(stream.source, AL_PITCH, 1.0f);
|
||||
alSourcef(stream.source, AL_GAIN, 1.0f);
|
||||
alSource3f(stream.source, AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(stream.source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Create Buffers (double buffering)
|
||||
alGenBuffers(MAX_STREAM_BUFFERS, stream.buffers);
|
||||
|
@ -947,6 +947,7 @@ RLAPI void ToggleVrMode(void); // Enable/Disable VR experienc
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
|
Loading…
Reference in New Issue
Block a user