Browse Source

Added love.audio.set/getDopplerScale.

Alex Szpakowski 10 years ago
parent
commit
695ab41915

+ 3 - 0
src/modules/audio/Audio.h

@@ -185,6 +185,9 @@ public:
 	 **/
 	virtual void setVelocity(float *v) = 0;
 
+	virtual void setDopplerScale(float scale) = 0;
+	virtual float getDopplerScale() const = 0;
+
 	/**
 	 * Begins recording audio input from the microphone.
 	 **/

+ 9 - 0
src/modules/audio/null/Audio.cpp

@@ -132,6 +132,15 @@ void Audio::setVelocity(float *)
 {
 }
 
+void Audio::setDopplerScale(float)
+{
+}
+
+float Audio::getDopplerScale() const
+{
+	return 1.0f;
+}
+
 void Audio::record()
 {
 }

+ 3 - 0
src/modules/audio/null/Audio.h

@@ -67,6 +67,9 @@ public:
 	void getVelocity(float *v) const;
 	void setVelocity(float *v);
 
+	void setDopplerScale(float scale);
+	float getDopplerScale() const;
+
 	void record();
 	love::sound::SoundData *getRecordedData();
 	love::sound::SoundData *stopRecording(bool returnData);

+ 11 - 0
src/modules/audio/openal/Audio.cpp

@@ -256,6 +256,17 @@ void Audio::setVelocity(float *v)
 	alListenerfv(AL_VELOCITY, v);
 }
 
+void Audio::setDopplerScale(float scale)
+{
+	if (scale >= 0.0f)
+		alDopplerFactor(scale);
+}
+
+float Audio::getDopplerScale() const
+{
+	return alGetFloat(AL_DOPPLER_FACTOR);
+}
+
 void Audio::record()
 {
 	if (!canRecord()) return;

+ 3 - 0
src/modules/audio/openal/Audio.h

@@ -85,6 +85,9 @@ public:
 	void getVelocity(float *v) const;
 	void setVelocity(float *v);
 
+	void setDopplerScale(float scale);
+	float getDopplerScale() const;
+
 	void record();
 	love::sound::SoundData *getRecordedData();
 	love::sound::SoundData *stopRecording(bool returnData);

+ 14 - 0
src/modules/audio/wrap_Audio.cpp

@@ -218,6 +218,18 @@ int w_getVelocity(lua_State *L)
 	return 3;
 }
 
+int w_setDopplerScale(lua_State *L)
+{
+	instance()->setDopplerScale(luax_checkfloat(L, 1));
+	return 0;
+}
+
+int w_getDopplerScale(lua_State *L)
+{
+	lua_pushnumber(L, instance()->getDopplerScale());
+	return 1;
+}
+
 int w_record(lua_State *)
 {
 	instance()->record();
@@ -299,6 +311,8 @@ static const luaL_Reg functions[] =
 	{ "getOrientation", w_getOrientation },
 	{ "setVelocity", w_setVelocity },
 	{ "getVelocity", w_getVelocity },
+	{ "setDopplerScale", w_setDopplerScale },
+	{ "getDopplerScale", w_getDopplerScale },
 	/*{ "record", w_record },
 	{ "getRecordedData", w_getRecordedData },
 	{ "stopRecording", w_stopRecording },*/

+ 2 - 0
src/modules/audio/wrap_Audio.h

@@ -47,6 +47,8 @@ int w_setOrientation(lua_State *L);
 int w_getOrientation(lua_State *L);
 int w_setVelocity(lua_State *L);
 int w_getVelocity(lua_State *L);
+int w_setDopplerScale(lua_State *L);
+int w_getDopplerScale(lua_State *L);
 int w_record(lua_State *L);
 int w_getRecordedData(lua_State *L);
 int w_stopRecording(lua_State *L);