Added Source:getChannels. Positional/directional audio only works with 1-channel (mono) sources.

This commit is contained in:
Alex Szpakowski
2013-10-15 23:09:35 -04:00
parent f846ed60b2
commit cf6acfa258
7 changed files with 26 additions and 0 deletions
+1
View File
@@ -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);
+5
View File
@@ -224,6 +224,11 @@ float Source::getMaxDistance() const
return this->maxDistance;
}
int Source::getChannels() const
{
return 2;
}
} // null
} // audio
} // love
+1
View File
@@ -77,6 +77,7 @@ public:
virtual float getRolloffFactor() const;
virtual void setMaxDistance(float distance);
virtual float getMaxDistance() const;
virtual int getChannels() const;
private:
+7
View File
@@ -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
+3
View File
@@ -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;
+8
View File
@@ -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 }
+1
View File
@@ -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);