mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Added Source:getChannels. Positional/directional audio only works with 1-channel (mono) sources.
This commit is contained in:
@@ -102,6 +102,7 @@ public:
|
||||
virtual void setMaxDistance(float distance) = 0;
|
||||
virtual float getMaxDistance() const = 0;
|
||||
|
||||
virtual int getChannels() const = 0;
|
||||
virtual Type getType() const;
|
||||
|
||||
static bool getConstant(const char *in, Type &out);
|
||||
|
||||
@@ -224,6 +224,11 @@ float Source::getMaxDistance() const
|
||||
return this->maxDistance;
|
||||
}
|
||||
|
||||
int Source::getChannels() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
} // null
|
||||
} // audio
|
||||
} // love
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
virtual float getRolloffFactor() const;
|
||||
virtual void setMaxDistance(float distance);
|
||||
virtual float getMaxDistance() const;
|
||||
virtual int getChannels() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
||||
, cone()
|
||||
, offsetSamples(0)
|
||||
, offsetSeconds(0)
|
||||
, channels(soundData->getChannels())
|
||||
, decoder(0)
|
||||
, toLoop(0)
|
||||
{
|
||||
@@ -81,6 +82,7 @@ Source::Source(Pool *pool, love::sound::Decoder *decoder)
|
||||
, cone()
|
||||
, offsetSamples(0)
|
||||
, offsetSeconds(0)
|
||||
, channels(decoder->getChannels())
|
||||
, decoder(decoder)
|
||||
, toLoop(0)
|
||||
{
|
||||
@@ -754,6 +756,11 @@ float Source::getMaxDistance() const
|
||||
return this->maxDistance;
|
||||
}
|
||||
|
||||
int Source::getChannels() const
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
|
||||
} // openal
|
||||
} // audio
|
||||
} // love
|
||||
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
virtual float getRolloffFactor() const;
|
||||
virtual void setMaxDistance(float distance);
|
||||
virtual float getMaxDistance() const;
|
||||
virtual int getChannels() const;
|
||||
|
||||
void playAtomic();
|
||||
void stopAtomic();
|
||||
@@ -155,6 +156,8 @@ private:
|
||||
float offsetSamples;
|
||||
float offsetSeconds;
|
||||
|
||||
int channels;
|
||||
|
||||
love::sound::Decoder *decoder;
|
||||
|
||||
unsigned int toLoop;
|
||||
|
||||
@@ -324,6 +324,13 @@ int w_Source_getRolloff(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_getChannels(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_getType(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
@@ -377,6 +384,7 @@ static const luaL_Reg functions[] =
|
||||
{ "setRolloff", w_Source_setRolloff},
|
||||
{ "getRolloff", w_Source_getRolloff},
|
||||
|
||||
{ "getChannels", w_Source_getChannels },
|
||||
{ "getType", w_Source_getType },
|
||||
|
||||
{ 0, 0 }
|
||||
|
||||
@@ -63,6 +63,7 @@ int w_Source_setAttenuationDistances(lua_State *L);
|
||||
int w_Source_getAttenuationDistances(lua_State *L);
|
||||
int w_Source_setRolloff(lua_State *L);
|
||||
int w_Source_getRolloff(lua_State *L);
|
||||
int w_Source_getChannels(lua_State *L);
|
||||
int w_Source_getType(lua_State *L);
|
||||
extern "C" int luaopen_source(lua_State *L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user