Lua: fix wrong frequency calculation in sound.get()

This commit is contained in:
gocha 2013-04-12 12:52:01 +00:00
parent a666ca9b4b
commit 43c849cc68
1 changed files with 3 additions and 3 deletions

View File

@ -4239,7 +4239,7 @@ static int sound_get(lua_State *L)
else
lua_pushnumber(L, nesVolumes[0]);
lua_setfield(L, -2, "volume");
freq = (39375000.0/352.0) / curfreq[0];
freq = (39375000.0/352.0) / (curfreq[0] + 1);
lua_pushnumber(L, freq);
lua_setfield(L, -2, "frequency");
lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
@ -4260,7 +4260,7 @@ static int sound_get(lua_State *L)
else
lua_pushnumber(L, nesVolumes[1]);
lua_setfield(L, -2, "volume");
freq = (39375000.0/352.0) / curfreq[1];
freq = (39375000.0/352.0) / (curfreq[1] + 1);
lua_pushnumber(L, freq);
lua_setfield(L, -2, "frequency");
lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);
@ -4280,7 +4280,7 @@ static int sound_get(lua_State *L)
lua_pushnumber(L, 1.0);
lua_setfield(L, -2, "volume");
freqReg = PSG[0xa] | ((PSG[0xb] & 7) << 8);
freq = (39375000.0/704.0) / freqReg;
freq = (39375000.0/704.0) / (freqReg + 1);
lua_pushnumber(L, freq);
lua_setfield(L, -2, "frequency");
lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69);