volume and panning added
This commit is contained in:
parent
98849ee488
commit
80fa273aeb
|
@ -1248,6 +1248,23 @@ static int luaB_free_sounds(lua_State *L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int luaB_panning_sound(lua_State *L) {
|
||||||
|
int chan = luaL_optnumber(L, 1, -1);
|
||||||
|
int left = luaL_optnumber(L, 2, 255);
|
||||||
|
int right = luaL_optnumber(L, 3, 255);
|
||||||
|
snd_panning(chan, left, right);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int luaB_volume_sound(lua_State *L) {
|
||||||
|
int vol = luaL_optnumber(L, 1, -1);
|
||||||
|
if (vol != -1)
|
||||||
|
game_change_vol(0, vol);
|
||||||
|
vol = snd_volume_mus(-1);
|
||||||
|
lua_pushnumber(L, vol);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int luaB_channel_sound(lua_State *L) {
|
static int luaB_channel_sound(lua_State *L) {
|
||||||
const char *s;
|
const char *s;
|
||||||
int ch = luaL_optnumber(L, 1, 0);
|
int ch = luaL_optnumber(L, 1, 0);
|
||||||
|
@ -1289,6 +1306,8 @@ static const luaL_Reg base_funcs[] = {
|
||||||
{"sound_load", luaB_load_sound},
|
{"sound_load", luaB_load_sound},
|
||||||
{"sound_free", luaB_free_sound},
|
{"sound_free", luaB_free_sound},
|
||||||
{"sound_channel", luaB_channel_sound},
|
{"sound_channel", luaB_channel_sound},
|
||||||
|
{"sound_panning", luaB_panning_sound},
|
||||||
|
{"sound_volume", luaB_volume_sound},
|
||||||
{"sounds_free", luaB_free_sounds},
|
{"sounds_free", luaB_free_sounds},
|
||||||
|
|
||||||
{"mouse_pos", luaB_mouse_pos},
|
{"mouse_pos", luaB_mouse_pos},
|
||||||
|
|
|
@ -234,6 +234,15 @@ int snd_playing(int channel)
|
||||||
return Mix_Playing(channel);
|
return Mix_Playing(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int snd_panning(int channel, int left, int right)
|
||||||
|
{
|
||||||
|
if (channel >= MIX_CHANNELS)
|
||||||
|
channel %= MIX_CHANNELS;
|
||||||
|
if (channel < 0)
|
||||||
|
channel = -1;
|
||||||
|
return Mix_SetPanning(channel, left, right);
|
||||||
|
}
|
||||||
|
|
||||||
void snd_free_mus(mus_t mus)
|
void snd_free_mus(mus_t mus)
|
||||||
{
|
{
|
||||||
if (!sound_on)
|
if (!sound_on)
|
||||||
|
|
|
@ -28,5 +28,6 @@ extern int snd_vol_from_pcn(int v);
|
||||||
extern int snd_vol_to_pcn(int v);
|
extern int snd_vol_to_pcn(int v);
|
||||||
extern int snd_playing(int channel);
|
extern int snd_playing(int channel);
|
||||||
extern void snd_pause(int on);
|
extern void snd_pause(int on);
|
||||||
|
extern int snd_panning(int channel, int left, int right);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,9 @@ stead.sound_load = sound_load
|
||||||
stead.sound_free = sound_free
|
stead.sound_free = sound_free
|
||||||
stead.sounds_free = sounds_free
|
stead.sounds_free = sounds_free
|
||||||
stead.sound_channel = sound_channel
|
stead.sound_channel = sound_channel
|
||||||
|
stead.sound_volume = sound_volume
|
||||||
|
stead.sound_panning = sound_panning
|
||||||
|
|
||||||
sound = {
|
sound = {
|
||||||
nam = 'sound';
|
nam = 'sound';
|
||||||
object_type = true;
|
object_type = true;
|
||||||
|
@ -18,8 +21,17 @@ sound = {
|
||||||
stop = function(...)
|
stop = function(...)
|
||||||
stead.stop_sound(...);
|
stead.stop_sound(...);
|
||||||
end;
|
end;
|
||||||
channel = function(...)
|
playing = function(s,...)
|
||||||
return stead.sound_channel(...)
|
if type(s) ~= 'number' then
|
||||||
|
return stead.is_sound()
|
||||||
|
end
|
||||||
|
return stead.sound_channel(s,...)
|
||||||
|
end;
|
||||||
|
pan = function(...)
|
||||||
|
return stead.sound_panning(...)
|
||||||
|
end;
|
||||||
|
vol = function(...)
|
||||||
|
return stead.sound_volume(...)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue