Added get_music_file_length and RageSound:get_length lua functions. Updated changelog.
This commit is contained in:
@@ -4,6 +4,14 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
|
|||||||
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
|
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
2015/06/10
|
||||||
|
----------
|
||||||
|
* [global] get_music_file_length lua function added. [kyzentun]
|
||||||
|
multiapproach lua function now takes an optional 4th argument to multiply
|
||||||
|
the speeds by. [kyzentun]
|
||||||
|
* [NoteDisplay] 1px seam in hold cap rendering fixed. [A.C/waiei]
|
||||||
|
* [RageSound] get_length lua function added. [kyzentun]
|
||||||
|
|
||||||
2015/06/06
|
2015/06/06
|
||||||
----------
|
----------
|
||||||
* [ScreenInitialScreenIsInvalid] Error screen for themes that set an invalid
|
* [ScreenInitialScreenIsInvalid] Error screen for themes that set an invalid
|
||||||
|
|||||||
@@ -221,6 +221,7 @@
|
|||||||
<Function name='getenv'/>
|
<Function name='getenv'/>
|
||||||
<Function name='getfenv'/>
|
<Function name='getfenv'/>
|
||||||
<Function name='getmetatable'/>
|
<Function name='getmetatable'/>
|
||||||
|
<Function name='get_music_file_length'/>
|
||||||
<Function name='ipairs'/>
|
<Function name='ipairs'/>
|
||||||
<Function name='ivalues'/>
|
<Function name='ivalues'/>
|
||||||
<Function name='join'/>
|
<Function name='join'/>
|
||||||
@@ -1393,6 +1394,7 @@
|
|||||||
<Function name='GetDescriptions'/>
|
<Function name='GetDescriptions'/>
|
||||||
</Class>
|
</Class>
|
||||||
<Class name='RageSound'>
|
<Class name='RageSound'>
|
||||||
|
<Function name='get_length'/>
|
||||||
<Function name='SetParam'/>
|
<Function name='SetParam'/>
|
||||||
<Function name='SetProperty'/>
|
<Function name='SetProperty'/>
|
||||||
<Function name='pitch'/>
|
<Function name='pitch'/>
|
||||||
|
|||||||
@@ -208,6 +208,10 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Function name='GetLifeDifficulty' return='int' arguments=''>
|
<Function name='GetLifeDifficulty' return='int' arguments=''>
|
||||||
Returns the current Life Difficulty.
|
Returns the current Life Difficulty.
|
||||||
</Function>
|
</Function>
|
||||||
|
<Function name='get_music_file_length' return='float' arguments='string path'>
|
||||||
|
Returns the length of the music file found at path.<br />
|
||||||
|
If you are loading the sound into an ActorSound, ActorSound:get to get its RageSound then use RageSound's get_length function instead to avoid loading the file twice.
|
||||||
|
</Function>
|
||||||
<Function name='GetOSName' return='string' arguments=''>
|
<Function name='GetOSName' return='string' arguments=''>
|
||||||
Returns a string representing the name of the operating system being used. (e.g. "Windows", "Linux", "Mac, "Unknown")
|
Returns a string representing the name of the operating system being used. (e.g. "Windows", "Linux", "Mac, "Unknown")
|
||||||
</Function>
|
</Function>
|
||||||
@@ -402,9 +406,10 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Function name='MonthToString' return='string' arguments='Month m'>
|
<Function name='MonthToString' return='string' arguments='Month m'>
|
||||||
Returns Month <code>m</code> as a string.
|
Returns Month <code>m</code> as a string.
|
||||||
</Function>
|
</Function>
|
||||||
<Function name='multiapproach' return='table' arguments='table currents, table goals, table speeds'>
|
<Function name='multiapproach' return='table' arguments='table currents, table goals, table speeds, float multiplier'>
|
||||||
Similar to approach, but operates on tables of values instead of single values. This will modify the contents of <code>currents</code> in place, as well as returning <code>currents</code>.<br />
|
Similar to approach, but operates on tables of values instead of single values. This will modify the contents of <code>currents</code> in place, as well as returning <code>currents</code>.<br />
|
||||||
<code>currents</code>, <code>goals</code>, and <code>speeds</code> must all be the same size and contain only numbers.<br />
|
<code>currents</code>, <code>goals</code>, and <code>speeds</code> must all be the same size and contain only numbers.<br />
|
||||||
|
<code>multiplier</code> is optional. The speeds in the speeds table will be multiplied by <code>multiplier</code>. This makes it more convenient to use multiapproach in a per-frame update: pass in the frame delta and the speeds will be scaled to the time that passed.<br />
|
||||||
Note: When you see the error "approach: speed 1 is negative." it means that a speed value passed was negative. The 1 tells you which entry in the table was invalid.
|
Note: When you see the error "approach: speed 1 is negative." it means that a speed value passed was negative. The 1 tells you which entry in the table was invalid.
|
||||||
</Function>
|
</Function>
|
||||||
<Function name='next' return='void' arguments='table t, int index'>
|
<Function name='next' return='void' arguments='table t, int index'>
|
||||||
@@ -4112,6 +4117,9 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Description>
|
<Description>
|
||||||
See <Link class='ActorSound' /> for loading a sound.
|
See <Link class='ActorSound' /> for loading a sound.
|
||||||
</Description>
|
</Description>
|
||||||
|
<Function name='get_length' return='float' arguments=''>
|
||||||
|
Returns the length of the sound loaded into this RageSound. Returns -1 if no sound is loaded.
|
||||||
|
</Function>
|
||||||
<Function name='SetParam' return='void' arguments='string sProperty, float fVal'>
|
<Function name='SetParam' return='void' arguments='string sProperty, float fVal'>
|
||||||
Actually sets the value of <code>sProperty</code> to <code>fVal</code>. The supported properties depend on how the associated <Link class='ActorSound' /> was loaded.
|
Actually sets the value of <code>sProperty</code> to <code>fVal</code>. The supported properties depend on how the associated <Link class='ActorSound' /> was loaded.
|
||||||
</Function>
|
</Function>
|
||||||
|
|||||||
@@ -645,6 +645,19 @@ void RageSound::SetStopModeFromString( const RString &sStopMode )
|
|||||||
class LunaRageSound: public Luna<RageSound>
|
class LunaRageSound: public Luna<RageSound>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static int get_length(T* p, lua_State* L)
|
||||||
|
{
|
||||||
|
RageSoundReader* reader= p->GetSoundReader();
|
||||||
|
if(reader == NULL)
|
||||||
|
{
|
||||||
|
lua_pushnumber(L, -1.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lua_pushnumber(L, reader->GetLength() / 1000.0f);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
static int pitch( T* p, lua_State *L )
|
static int pitch( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
RageSoundParams params( p->GetParams() );
|
RageSoundParams params( p->GetParams() );
|
||||||
@@ -703,6 +716,7 @@ public:
|
|||||||
|
|
||||||
LunaRageSound()
|
LunaRageSound()
|
||||||
{
|
{
|
||||||
|
ADD_METHOD(get_length);
|
||||||
ADD_METHOD( pitch );
|
ADD_METHOD( pitch );
|
||||||
ADD_METHOD( speed );
|
ADD_METHOD( speed );
|
||||||
ADD_METHOD( volume );
|
ADD_METHOD( volume );
|
||||||
|
|||||||
+33
-7
@@ -3,6 +3,7 @@
|
|||||||
#include "RageMath.h"
|
#include "RageMath.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageFile.h"
|
#include "RageFile.h"
|
||||||
|
#include "RageSoundReader_FileReader.h"
|
||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
#include "LocalizedString.h"
|
#include "LocalizedString.h"
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
@@ -2431,8 +2432,8 @@ int LuaFunc_commify(lua_State* L)
|
|||||||
}
|
}
|
||||||
LUAFUNC_REGISTER_COMMON(commify);
|
LUAFUNC_REGISTER_COMMON(commify);
|
||||||
|
|
||||||
void luafunc_approach_internal(lua_State* L, int valind, int goalind, int speedind);
|
void luafunc_approach_internal(lua_State* L, int valind, int goalind, int speedind, const float mult);
|
||||||
void luafunc_approach_internal(lua_State* L, int valind, int goalind, int speedind, int process_index)
|
void luafunc_approach_internal(lua_State* L, int valind, int goalind, int speedind, const float mult, int process_index)
|
||||||
{
|
{
|
||||||
#define TONUMBER_NICE(dest, num_name, index) \
|
#define TONUMBER_NICE(dest, num_name, index) \
|
||||||
if(!lua_isnumber(L, index)) \
|
if(!lua_isnumber(L, index)) \
|
||||||
@@ -2451,7 +2452,7 @@ void luafunc_approach_internal(lua_State* L, int valind, int goalind, int speedi
|
|||||||
{
|
{
|
||||||
luaL_error(L, "approach: speed %d is negative.", process_index);
|
luaL_error(L, "approach: speed %d is negative.", process_index);
|
||||||
}
|
}
|
||||||
fapproach(val, goal, speed);
|
fapproach(val, goal, speed*mult);
|
||||||
lua_pushnumber(L, val);
|
lua_pushnumber(L, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2460,7 +2461,7 @@ int LuaFunc_approach(lua_State* L)
|
|||||||
{
|
{
|
||||||
// Args: current, goal, speed
|
// Args: current, goal, speed
|
||||||
// Returns: new_current
|
// Returns: new_current
|
||||||
luafunc_approach_internal(L, 1, 2, 3, 1);
|
luafunc_approach_internal(L, 1, 2, 3, 1.0f, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
LUAFUNC_REGISTER_COMMON(approach);
|
LUAFUNC_REGISTER_COMMON(approach);
|
||||||
@@ -2468,16 +2469,24 @@ LUAFUNC_REGISTER_COMMON(approach);
|
|||||||
int LuaFunc_multiapproach(lua_State* L);
|
int LuaFunc_multiapproach(lua_State* L);
|
||||||
int LuaFunc_multiapproach(lua_State* L)
|
int LuaFunc_multiapproach(lua_State* L)
|
||||||
{
|
{
|
||||||
// Args: {currents}, {goals}, {speeds}
|
// Args: {currents}, {goals}, {speeds}, speed_multiplier
|
||||||
|
// speed_multiplier is optional, and is intended to be the delta time for
|
||||||
|
// the frame, so that this can be used every frame and have the current
|
||||||
|
// approach the goal at a framerate independent speed.
|
||||||
// Returns: {currents}
|
// Returns: {currents}
|
||||||
// Modifies the values in {currents} in place.
|
// Modifies the values in {currents} in place.
|
||||||
if(lua_gettop(L) != 3)
|
if(lua_gettop(L) < 3)
|
||||||
{
|
{
|
||||||
luaL_error(L, "multiapproach: A table of current values, a table of goal values, and a table of speeds must be passed.");
|
luaL_error(L, "multiapproach: A table of current values, a table of goal values, and a table of speeds must be passed.");
|
||||||
}
|
}
|
||||||
size_t currents_len= lua_objlen(L, 1);
|
size_t currents_len= lua_objlen(L, 1);
|
||||||
size_t goals_len= lua_objlen(L, 2);
|
size_t goals_len= lua_objlen(L, 2);
|
||||||
size_t speeds_len= lua_objlen(L, 3);
|
size_t speeds_len= lua_objlen(L, 3);
|
||||||
|
float mult= 1.0f;
|
||||||
|
if(lua_isnumber(L, 4))
|
||||||
|
{
|
||||||
|
mult= lua_tonumber(L, 4);
|
||||||
|
}
|
||||||
if(currents_len != goals_len || currents_len != speeds_len)
|
if(currents_len != goals_len || currents_len != speeds_len)
|
||||||
{
|
{
|
||||||
luaL_error(L, "multiapproach: There must be the same number of current values, goal values, and speeds.");
|
luaL_error(L, "multiapproach: There must be the same number of current values, goal values, and speeds.");
|
||||||
@@ -2491,7 +2500,7 @@ int LuaFunc_multiapproach(lua_State* L)
|
|||||||
lua_rawgeti(L, 1, i);
|
lua_rawgeti(L, 1, i);
|
||||||
lua_rawgeti(L, 2, i);
|
lua_rawgeti(L, 2, i);
|
||||||
lua_rawgeti(L, 3, i);
|
lua_rawgeti(L, 3, i);
|
||||||
luafunc_approach_internal(L, -3, -2, -1, i);
|
luafunc_approach_internal(L, -3, -2, -1, mult, i);
|
||||||
lua_rawseti(L, 1, i);
|
lua_rawseti(L, 1, i);
|
||||||
lua_pop(L, 3);
|
lua_pop(L, 3);
|
||||||
}
|
}
|
||||||
@@ -2500,6 +2509,23 @@ int LuaFunc_multiapproach(lua_State* L)
|
|||||||
}
|
}
|
||||||
LUAFUNC_REGISTER_COMMON(multiapproach);
|
LUAFUNC_REGISTER_COMMON(multiapproach);
|
||||||
|
|
||||||
|
int LuaFunc_get_music_file_length(lua_State* L);
|
||||||
|
int LuaFunc_get_music_file_length(lua_State* L)
|
||||||
|
{
|
||||||
|
// Args: file_path
|
||||||
|
// Returns: The length of the music in seconds.
|
||||||
|
RString path= SArg(1);
|
||||||
|
RString error;
|
||||||
|
RageSoundReader* sample= RageSoundReader_FileReader::OpenFile(path, error);
|
||||||
|
if(sample == NULL)
|
||||||
|
{
|
||||||
|
luaL_error(L, "The music file '%s' does not exist.", path.c_str());
|
||||||
|
}
|
||||||
|
lua_pushnumber(L, sample->GetLength() / 1000.0f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
LUAFUNC_REGISTER_COMMON(get_music_file_length);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
Reference in New Issue
Block a user