1. rude
  2. love

Commits

Alex Szpakowski  committed bb0bddc

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

  • Participants
  • Parent commits a6a17f8
  • Branches default

Comments (0)

Files changed (7)

File src/modules/audio/Source.h

View file
 	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);

File src/modules/audio/null/Source.cpp

View file
 	return this->maxDistance;
 }
 
+int Source::getChannels() const
+{
+	return 2;
+}
+
 } // null
 } // audio
 } // love

File src/modules/audio/null/Source.h

View file
 	virtual float getRolloffFactor() const;
 	virtual void setMaxDistance(float distance);
 	virtual float getMaxDistance() const;
+	virtual int getChannels() const;
 
 private:
 

File src/modules/audio/openal/Source.cpp

View file
 	, cone()
 	, offsetSamples(0)
 	, offsetSeconds(0)
+	, channels(soundData->getChannels())
 	, decoder(0)
 	, toLoop(0)
 {
 	, cone()
 	, offsetSamples(0)
 	, offsetSeconds(0)
+	, channels(decoder->getChannels())
 	, decoder(decoder)
 	, toLoop(0)
 {
 	return this->maxDistance;
 }
 
+int Source::getChannels() const
+{
+	return channels;
+}
+
 } // openal
 } // audio
 } // love

File src/modules/audio/openal/Source.h

View file
 	virtual float getRolloffFactor() const;
 	virtual void setMaxDistance(float distance);
 	virtual float getMaxDistance() const;
+	virtual int getChannels() const;
 
 	void playAtomic();
 	void stopAtomic();
 	float offsetSamples;
 	float offsetSeconds;
 
+	int channels;
+
 	love::sound::Decoder *decoder;
 
 	unsigned int toLoop;

File src/modules/audio/wrap_Source.cpp

View file
 	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);
 	{ "setRolloff", w_Source_setRolloff},
 	{ "getRolloff", w_Source_getRolloff},
 
+	{ "getChannels", w_Source_getChannels },
 	{ "getType", w_Source_getType },
 
 	{ 0, 0 }

File src/modules/audio/wrap_Source.h

View file
 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);