Setting sample length for songs with preview file to 0 uses length of preview file

This commit is contained in:
Joe
2015-05-15 15:46:20 +01:00
parent 3df07863f5
commit d3e866db26
2 changed files with 90 additions and 59 deletions
+1
View File
@@ -1588,6 +1588,7 @@ void BMSSongLoader::AddToSong()
out->m_sMusicFile = main.info.musicFile;
out->m_PreviewFile= main.info.previewFile;
out->m_fMusicSampleLengthSeconds = 0.00f; // to ensure whole preview file is heard
out->m_SongTiming = main.steps->m_Timing;
}
+30
View File
@@ -748,6 +748,34 @@ void Song::TidyUpData( bool from_cache, bool /* duringCache */ )
m_fMusicLengthSeconds);
m_fMusicLengthSeconds = 0;
}
if(!m_PreviewFile.empty() && m_fMusicSampleLengthSeconds <= 0.00f) { // if there's a preview file and sample length isn't specified, set sample length to length of preview file
RString error;
RageSoundReader *Sample = RageSoundReader_FileReader::OpenFile(GetPreviewMusicPath(), error);
if(Sample == NULL && m_sMusicFile != "")
{
LOG->UserLog("Sound file", GetPreviewMusicPath(), "couldn't be opened: %s", error.c_str());
// Don't use this file.
m_PreviewFile = "";
m_fMusicSampleLengthSeconds = DEFAULT_MUSIC_SAMPLE_LENGTH;
}
else if(Sample != NULL)
{
m_fMusicSampleLengthSeconds = Sample->GetLength() / 1000.0f;
delete Sample;
if(m_fMusicSampleLengthSeconds < 0)
{
// It failed; bad file or something. It's already logged a warning.
m_fMusicSampleLengthSeconds = DEFAULT_MUSIC_SAMPLE_LENGTH;
}
else if(m_fMusicSampleLengthSeconds == 0)
{
LOG->UserLog("Sound file", GetPreviewMusicPath(), "is empty.");
}
}
} else { // no preview file, calculate sample from music as normal
if(m_fMusicSampleStartSeconds == -1 ||
m_fMusicSampleLengthSeconds == 0 ||
m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds)
@@ -769,6 +797,8 @@ void Song::TidyUpData( bool from_cache, bool /* duringCache */ )
if(m_fMusicSampleLengthSeconds <= 0.00f)
{ m_fMusicSampleLengthSeconds = DEFAULT_MUSIC_SAMPLE_LENGTH; }
}
// Here's the problem: We have a directory full of images. We want to
// determine which image is the banner, which is the background, and
// which is the CDTitle.