Added new wave functions to lua binding

This commit is contained in:
raysan5 2016-10-12 10:27:14 +02:00
parent 97e3277d58
commit 76a67a149e
2 changed files with 84 additions and 1 deletions

View File

@ -908,7 +908,7 @@ RLAPI Sound LoadSound(const char *fileName); // Load so
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
RLAPI Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
RLAPI void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data
RLAPI void UnloadWave(Wave wave);
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound
RLAPI void PlaySound(Sound sound); // Play a sound
RLAPI void PauseSound(Sound sound); // Pause a sound

View File

@ -2824,6 +2824,28 @@ int lua_IsAudioDeviceReady(lua_State* L)
return 1;
}
int lua_LoadWave(lua_State* L)
{
const char * arg1 = LuaGetArgument_string(L, 1);
Wave result = LoadWave((char *)arg1);
LuaPush_Wave(L, result);
return 1;
}
int lua_LoadWaveEx(lua_State* L)
{
// TODO: Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels);
int arg1 = 0;
int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3);
int arg4 = LuaGetArgument_int(L, 4);
int arg5 = LuaGetArgument_int(L, 5);
Wave result = LoadWaveEx(arg1, arg2, arg3, arg4, arg5);
LuaPush_Wave(L, result);
return 1;
}
int lua_LoadSound(lua_State* L)
{
const char * arg1 = LuaGetArgument_string(L, 1);
@ -2849,6 +2871,22 @@ int lua_LoadSoundFromRES(lua_State* L)
return 1;
}
int lua_UpdateSound(lua_State* L)
{
Sound arg1 = LuaGetArgument_Sound(L, 1);
const char * arg2 = LuaGetArgument_string(L, 2);
int * arg3 = LuaGetArgument_int(L, 3);
UpdateSound(arg1, arg2, arg3);
return 0;
}
int lua_UnloadWave(lua_State* L)
{
Wave arg1 = LuaGetArgument_Wave(L, 1);
UnloadWave(arg1);
return 0;
}
int lua_UnloadSound(lua_State* L)
{
Sound arg1 = LuaGetArgument_Sound(L, 1);
@ -2908,6 +2946,43 @@ int lua_SetSoundPitch(lua_State* L)
return 0;
}
int lua_WaveFormat(lua_State* L)
{
Wave arg1 = LuaGetArgument_Wave(L, 1);
int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3);
int arg4 = LuaGetArgument_int(L, 4);
WaveFormat(arg1, arg2, arg3, arg4);
return 0;
}
int lua_LoadMusicStream(lua_State* L)
{
Wave arg1 = LuaGetArgument_Wave(L, 1);
Wave result = WaveCopy(arg1);
LuaPush_Wave(L, result);
return 1;
}
int lua_WaveCrop(lua_State* L)
{
Wave arg1 = LuaGetArgument_Wave(L, 1);
int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3);
WaveCrop(arg1, arg2, arg3);
return 0;
}
int lua_GetWaveData(lua_State* L)
{
// TODO: float *GetWaveData(Wave wave);
Wave arg1 = LuaGetArgument_Wave(L, 1);
float result = GetWaveData(arg1);
LuaPush_float(L, result);
return 1;
}
int lua_LoadMusicStream(lua_State* L)
{
const char * arg1 = LuaGetArgument_string(L, 1);
@ -3799,9 +3874,13 @@ static luaL_Reg raylib_functions[] = {
REG(InitAudioDevice)
REG(CloseAudioDevice)
REG(IsAudioDeviceReady)
REG(LoadWave)
REG(LoadWaveEx)
REG(LoadSound)
REG(LoadSoundFromWave)
REG(LoadSoundFromRES)
REG(UpdateSound)
REG(UnloadWave)
REG(UnloadSound)
REG(PlaySound)
REG(PauseSound)
@ -3810,6 +3889,10 @@ static luaL_Reg raylib_functions[] = {
REG(IsSoundPlaying)
REG(SetSoundVolume)
REG(SetSoundPitch)
REG(WaveFormat)
REG(WaveCopy)
REG(WaveCrop)
REG(GetWaveData)
REG(LoadMusicStream)
REG(UnloadMusicStream)