handle sample timings in ms
This commit is contained in:
@@ -242,6 +242,27 @@ bool DWILoader::LoadFromDWITokens(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* STUPID ALERT!
|
||||||
|
* This value can be in either "HH:MM:SS.sssss", "MM:SS.sssss", "SSS.sssss"
|
||||||
|
* or milliseconds.
|
||||||
|
* What's even more dumb is that the value can contain a ':'. Colon is supposed to be a parameter separator!
|
||||||
|
*/
|
||||||
|
float DWILoader::ParseBrokenDWITimestamp(const CString *sParams, int iNumParams)
|
||||||
|
{
|
||||||
|
if( iNumParams == 4 )
|
||||||
|
return TimeToSeconds( sParams[1]+":"+sParams[2]+":"+sParams[3] );
|
||||||
|
|
||||||
|
if( iNumParams == 3 )
|
||||||
|
return TimeToSeconds( sParams[1]+":"+sParams[2] );
|
||||||
|
|
||||||
|
// iNumParams == 2
|
||||||
|
/* If the value contains a period, treat it as seconds; otherwise ms. */
|
||||||
|
if(sParams[1].find_first_of(".") != sParams[1].npos)
|
||||||
|
return (float)atof(sParams[1].GetString());
|
||||||
|
else
|
||||||
|
return float(atof(sParams[1].GetString())) / 1000.f;
|
||||||
|
}
|
||||||
|
|
||||||
bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Song::LoadFromDWIFile(%s)", sPath.GetString() );
|
LOG->Trace( "Song::LoadFromDWIFile(%s)", sPath.GetString() );
|
||||||
@@ -258,6 +279,12 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
|||||||
CString* sParams = msd.m_sParams[i];
|
CString* sParams = msd.m_sParams[i];
|
||||||
CString sValueName = sParams[0];
|
CString sValueName = sParams[0];
|
||||||
|
|
||||||
|
if(iNumParams < 1)
|
||||||
|
{
|
||||||
|
LOG->Warn("Got \"%s\" tag with no parameters", sValueName.GetString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// handle the data
|
// handle the data
|
||||||
if( 0==stricmp(sValueName,"FILE") )
|
if( 0==stricmp(sValueName,"FILE") )
|
||||||
out.m_sMusicFile = sParams[1];
|
out.m_sMusicFile = sParams[1];
|
||||||
@@ -279,27 +306,10 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
|||||||
out.m_fBeat0OffsetInSeconds = -atoi( sParams[1] ) / 1000.0f;
|
out.m_fBeat0OffsetInSeconds = -atoi( sParams[1] ) / 1000.0f;
|
||||||
|
|
||||||
else if( 0==stricmp(sValueName,"SAMPLESTART") )
|
else if( 0==stricmp(sValueName,"SAMPLESTART") )
|
||||||
{
|
out.m_fMusicSampleStartSeconds = ParseBrokenDWITimestamp(sParams, iNumParams);
|
||||||
// STUPID ALERT!
|
|
||||||
// This value can be in either "HH:MM:SS.sssss", "MM:SS.sssss", or "SSS.sssss".
|
|
||||||
// What's even more dumb is that the value can contain a ':'. Colon is supposed to be a parameter separator!
|
|
||||||
if( iNumParams == 4 )
|
|
||||||
out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1]+":"+sParams[2]+":"+sParams[3] );
|
|
||||||
else if( iNumParams == 3 )
|
|
||||||
out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1]+":"+sParams[2] );
|
|
||||||
else // if( iNumParams == 2 )
|
|
||||||
out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1] );
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( 0==stricmp(sValueName,"SAMPLELENGTH") )
|
else if( 0==stricmp(sValueName,"SAMPLELENGTH") )
|
||||||
{
|
out.m_fMusicSampleLengthSeconds = ParseBrokenDWITimestamp(sParams, iNumParams);
|
||||||
if( iNumParams == 4 )
|
|
||||||
out.m_fMusicSampleLengthSeconds = TimeToSeconds( sParams[1]+":"+sParams[2]+":"+sParams[3] );
|
|
||||||
else if( iNumParams == 3 )
|
|
||||||
out.m_fMusicSampleLengthSeconds = TimeToSeconds( sParams[1]+":"+sParams[2] );
|
|
||||||
else // if( iNumParams == 2 )
|
|
||||||
out.m_fMusicSampleLengthSeconds = TimeToSeconds( sParams[1] );
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( 0==stricmp(sValueName,"FREEZE") )
|
else if( 0==stricmp(sValueName,"FREEZE") )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class DWILoader: public NotesLoader {
|
|||||||
|
|
||||||
bool LoadFromDWIFile( CString sPath, Song &out );
|
bool LoadFromDWIFile( CString sPath, Song &out );
|
||||||
|
|
||||||
|
static float ParseBrokenDWITimestamp(const CString *sParams, int iNumParams);
|
||||||
public:
|
public:
|
||||||
void GetApplicableFiles( CString sPath, CStringArray &out );
|
void GetApplicableFiles( CString sPath, CStringArray &out );
|
||||||
bool Loadable( CString sPath );
|
bool Loadable( CString sPath );
|
||||||
|
|||||||
Reference in New Issue
Block a user