From 859ad4ceb39e2e3cc2e7f29b5ab3dbc6cc88a51c Mon Sep 17 00:00:00 2001 From: hryx Date: Thu, 12 Jun 2014 21:31:44 -0700 Subject: [PATCH 1/2] Lua: Added song:play() and song:stop() as aliases to song:play(bool) --- demos/modipulate-lua/8vb/main.lua | 2 +- demos/modipulate-lua/console/main.lua | 4 ++-- demos/modipulate-lua/not-ddr/main.lua | 2 +- src/modipulate_lua/main.cpp | 26 ++++++++++++++++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/demos/modipulate-lua/8vb/main.lua b/demos/modipulate-lua/8vb/main.lua index 2770926..e13b261 100644 --- a/demos/modipulate-lua/8vb/main.lua +++ b/demos/modipulate-lua/8vb/main.lua @@ -103,7 +103,7 @@ function love.load() --love.timer.sleep(500) - song:play(true) + song:play() end ---- diff --git a/demos/modipulate-lua/console/main.lua b/demos/modipulate-lua/console/main.lua index a1e3af4..bc590e4 100644 --- a/demos/modipulate-lua/console/main.lua +++ b/demos/modipulate-lua/console/main.lua @@ -49,7 +49,7 @@ function love.load() song:onRowChange(rowChanged) song:onNote(noteChanged) - song:play(true) + song:play() end @@ -112,7 +112,7 @@ function love.keypressed(k) elseif k == 'o' then -- Load & play a new song (at the same time) song2 = modipulate.loadSong('../../media/8vb1.it') - song2:play(true) + song2:play() end end diff --git a/demos/modipulate-lua/not-ddr/main.lua b/demos/modipulate-lua/not-ddr/main.lua index 0ecc88f..8ad13d6 100644 --- a/demos/modipulate-lua/not-ddr/main.lua +++ b/demos/modipulate-lua/not-ddr/main.lua @@ -83,7 +83,7 @@ a / s Transpose (octave)\ font = love.graphics.newFont('Courier_New.ttf', 12) love.graphics.setFont(font) - song:play(true) + song:play() end ---- diff --git a/src/modipulate_lua/main.cpp b/src/modipulate_lua/main.cpp index fcbcc53..d038eda 100644 --- a/src/modipulate_lua/main.cpp +++ b/src/modipulate_lua/main.cpp @@ -95,12 +95,29 @@ static int modipulateLua_song_destroy(lua_State *L) { static int modipulateLua_song_play(lua_State *L) { - const char* usage = "Usage: play(bool) where bool is true to play the song, false to stop it"; - luaL_argcheck(L, lua_gettop(L) == 2, 0, usage); + const char* usage = "Usage: play() or play(bool) where bool is true to play or false to stop"; + int nargs = lua_gettop(L); + int playbool = 1; + luaL_argcheck(L, nargs >= 1 && nargs <= 2, 0, usage); + modipulate_song_t* lua_song = check_modipulate_song_t(L, 1); + if (nargs == 2) + { + luaL_argcheck(L, lua_isboolean(L, 2), 2, usage); + playbool = (int) lua_toboolean(L, 2); + } + + MODIPULATE_LUA_ERROR(L, modipulate_song_play(lua_song->song, playbool)); + + return 0; +} + + +static int modipulateLua_song_stop(lua_State *L) { + const char* usage = "Usage: stop()"; + luaL_argcheck(L, lua_gettop(L) == 1, 0, usage); modipulate_song_t* lua_song = check_modipulate_song_t(L, 1); - luaL_argcheck(L, lua_isboolean(L, 2), 2, usage); - MODIPULATE_LUA_ERROR(L, modipulate_song_play(lua_song->song, (int) lua_toboolean(L, 2))); + MODIPULATE_LUA_ERROR(L, modipulate_song_play(lua_song->song, 0)); return 0; } @@ -410,6 +427,7 @@ static const luaL_reg modipulate_song_meta_methods[] = { static const luaL_reg modipulate_song_methods[] = { {"play", modipulateLua_song_play}, +{"stop", modipulateLua_song_stop}, {"getSampleName", modipulateLua_song_get_sample_name}, {"getInstrumentName", modipulateLua_song_get_instrument_name}, {"volumeCommand", modipulateLua_song_volume_command}, From d4d9a2d9d8e854d302d32daea4abb55e539b4861 Mon Sep 17 00:00:00 2001 From: hryx Date: Thu, 12 Jun 2014 21:53:30 -0700 Subject: [PATCH 2/2] Removing notes file -- info lives in issue #76 --- src/modipulate-osc/patterns.txt | 39 --------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/modipulate-osc/patterns.txt diff --git a/src/modipulate-osc/patterns.txt b/src/modipulate-osc/patterns.txt deleted file mode 100644 index bcef1e8..0000000 --- a/src/modipulate-osc/patterns.txt +++ /dev/null @@ -1,39 +0,0 @@ -OSC message patterns for modipulate-osc - -Notes: -- Simple naming -- Useful functions -- No low-level things (modipulate_global_update, etc.) -- Avoid too many get/set pairs? - ----- Tools ---- -/ping --> /pong - ----- System ---- -/modipulate/init -/modipulate/shutdown - ----- Song file ---- -/modipulate/load s -/modipulate/unload - ----- Song editing and mixing ---- -/modipulate/song/info --> ... -/modipulate/song/gettransposition --> ... -/modipulate/song/settransposition i -/modipulate/song/channel//getvolume --> ... -/modipulate/song/channel//setvolume f -/modipulate/song/channel//enable -/modipulate/song/channel//disable -/modipulate/song/channel//getenabled --> ... - ----- Global mixer ---- -/modipulate/mixer/setvolume f - ----- Transport ---- -/modipulate/transport/start -/modipulate/transport/stop -/modipulate/transport/gotopattern i - ----- ???? ---- -...