mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
Merge pull request #2345 from TimeyDingo/CallieTesting
unclamped gain #2336
This commit is contained in:
@@ -176,6 +176,9 @@ float Source::getMinVolume() const
|
||||
|
||||
void Source::setMaxVolume(float volume)
|
||||
{
|
||||
#ifndef AL_SOFT_gain_clamp_ex
|
||||
volume = std::min(volume, 1.0f);
|
||||
#endif
|
||||
this->maxVolume = volume;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ int w_Source_setVolumeLimits(lua_State *L)
|
||||
Source *t = luax_checksource(L, 1);
|
||||
float vmin = (float)luaL_checknumber(L, 2);
|
||||
float vmax = (float)luaL_checknumber(L, 3);
|
||||
if (vmin < .0f || vmin > 1.f || vmax < .0f || vmax > 1.f)
|
||||
if (vmin < .0f || vmin > 1.f || vmax < .0f)
|
||||
return luaL_error(L, "Invalid volume limits: [%f:%f]. Must be in [0:1]", vmin, vmax);
|
||||
t->setMinVolume(vmin);
|
||||
t->setMaxVolume(vmax);
|
||||
|
||||
@@ -87,10 +87,10 @@ love.test.audio.Source = function(test)
|
||||
test:assertFalse(stereo:isPlaying(), 'check stopped playing')
|
||||
|
||||
-- check volume limits
|
||||
stereo:setVolumeLimits(0.1, 0.5)
|
||||
stereo:setVolumeLimits(0.1, 5.5)
|
||||
local min, max = stereo:getVolumeLimits()
|
||||
test:assertRange(min, 0.1, 0.2, 'check min limit')
|
||||
test:assertRange(max, 0.5, 0.6, 'check max limit')
|
||||
test:assertRange(max, 5.5, 5.6, 'check max limit')
|
||||
|
||||
-- check setting volume
|
||||
stereo:setVolume(1)
|
||||
|
||||
Reference in New Issue
Block a user