From 7c75347e40172a13c6acb77da6525b0098d30bd4 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sat, 30 Jul 2011 15:56:30 -0400 Subject: [PATCH] Revert "Remove #INSTRUMENTTRACK. It's guitar only." This reverts commit 176b6f55ea539937a7ef17743fba84648c9f39e4. Glad I learned this command. --- Docs/Changelog_SSCformat.txt | 3 --- Docs/Changelog_sm5.txt | 4 +--- Docs/SimfileFormats/ssc_msd5.txt | 1 + src/AutoKeysounds.cpp | 20 +++++++++++++++++ src/NotesLoaderSM.cpp | 23 ++++++++++++++++++++ src/NotesLoaderSMA.cpp | 5 +++++ src/NotesLoaderSSC.cpp | 5 +++++ src/NotesWriterSSC.cpp | 8 +++++++ src/Song.cpp | 37 +++++++++++++++++++++++++++++++- src/Song.h | 19 +++++++++++++++- 10 files changed, 117 insertions(+), 8 deletions(-) diff --git a/Docs/Changelog_SSCformat.txt b/Docs/Changelog_SSCformat.txt index eedde716c3..75c9fe55ec 100644 --- a/Docs/Changelog_SSCformat.txt +++ b/Docs/Changelog_SSCformat.txt @@ -9,9 +9,6 @@ change to JSON, but it is unsure if this will be done. Implement .ssc at your own risk. ________________________________________________________________________________ -[v0.78] - Wolfman2000 -* Remove the #INSTRUMENTTRACK tag. - [v0.77] - Wolfman2000 * Add the cache tag #STEPFILENAME to gain access to the proper #NOTES when required. diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 50b2a88c47..9df8b71633 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -11,9 +11,7 @@ StepMania 5.0 Preview 3 | 20110??? 2011/07/30 ---------- * [ProfileManager] Fix an issue when deleting recently created profiles. [AJ] -* Start removing anything related to Guitar mode. This was rushed in, and it - is not worth us keeping at this time. This also means the #INSTRUMENTTRACK - tag is no longer valid. [Wolfman2000] +* Remove the guitar game. Keeping #INSTRUMENTTRACK for now. [Wolfman2000] 2011/07/26 ---------- diff --git a/Docs/SimfileFormats/ssc_msd5.txt b/Docs/SimfileFormats/ssc_msd5.txt index cb65462186..b8e5a2aea3 100644 --- a/Docs/SimfileFormats/ssc_msd5.txt +++ b/Docs/SimfileFormats/ssc_msd5.txt @@ -13,6 +13,7 @@ #LYRICSPATH:; #CDTITLE:; #MUSIC:; +#INSTRUMENTTRACK:; #MUSICLENGTH:; #OFFSET:; #BPMS:; diff --git a/src/AutoKeysounds.cpp b/src/AutoKeysounds.cpp index 932ab930d7..b536a3aa95 100644 --- a/src/AutoKeysounds.cpp +++ b/src/AutoKeysounds.cpp @@ -132,6 +132,15 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra if( !sMusicPath.empty() ) vsMusicFile.push_back( sMusicPath ); + FOREACH_ENUM( InstrumentTrack, it ) + { + if( it == InstrumentTrack_Guitar ) + continue; + if( pSong->HasInstrumentTrack(it) ) + vsMusicFile.push_back( pSong->GetInstrumentTrackPath(it) ); + } + + vector vpSounds; FOREACH( RString, vsMusicFile, s ) { @@ -165,6 +174,17 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra pShared = pSongReader; } + + if( pSong->HasInstrumentTrack(InstrumentTrack_Guitar) ) + { + RString sError; + RageSoundReader *pGuitarTrackReader = RageSoundReader_FileReader::OpenFile( pSong->GetInstrumentTrackPath(InstrumentTrack_Guitar), sError ); + // Load the buffering filter before the effects filters, so effects aren't delayed. + pGuitarTrackReader = new RageSoundReader_Extend( pGuitarTrackReader ); + pGuitarTrackReader = new RageSoundReader_ThreadedBuffer( pGuitarTrackReader ); + pPlayer1 = pGuitarTrackReader; + } + return; //if( pSongReader->GetNumChannels() <= 2 ) diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index 80760a8c07..889fafe2ce 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -179,6 +179,23 @@ void SMLoader::ProcessAttacks( AttackArray &attacks, MsdFile::value_t params ) } } +void SMLoader::ProcessInstrumentTracks( Song &out, const RString &sParam ) +{ + vector vs1; + split( sParam, ",", vs1 ); + FOREACH_CONST( RString, vs1, s ) + { + vector vs2; + split( *s, "=", vs2 ); + if( vs2.size() >= 2 ) + { + InstrumentTrack it = StringToInstrumentTrack( vs2[0] ); + if( it != InstrumentTrack_Invalid ) + out.m_sInstrumentTrackFile[it] = vs2[1]; + } + } +} + bool SMLoader::ProcessBPMs( TimingData &out, const RString line, const int rowsPerBeat ) { vector arrayBPMChangeExpressions; @@ -766,6 +783,12 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache { ProcessTickcounts(out.m_SongTiming, sParams[1]); } + + + else if( sValueName=="INSTRUMENTTRACK" ) + { + ProcessInstrumentTracks( out, sParams[1] ); + } else if( sValueName=="MUSICLENGTH" ) { diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index 6e5e689c3a..293e7bff17 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -224,6 +224,11 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="MUSIC" ) out.m_sMusicFile = sParams[1]; + else if( sValueName=="INSTRUMENTTRACK" ) + { + SMLoader::ProcessInstrumentTracks( out, sParams[1] ); + } + else if( sValueName=="MUSICLENGTH" ) { continue; diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index 1ee4c0164c..bcefb97fad 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -341,6 +341,11 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach out.m_sMusicFile = sParams[1]; } + else if( sValueName=="INSTRUMENTTRACK" ) + { + SMLoader::ProcessInstrumentTracks( out, sParams[1] ); + } + else if( sValueName=="MUSICLENGTH" ) { if( !bFromCache ) diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 932bfa3858..e341782478 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -227,6 +227,14 @@ static void WriteGlobalTags( RageFile &f, const Song &out ) f.PutLine( ssprintf( "#CDTITLE:%s;", SmEscape(out.m_sCDTitleFile).c_str() ) ); f.PutLine( ssprintf( "#MUSIC:%s;", SmEscape(out.m_sMusicFile).c_str() ) ); + { + vector vs = out.GetInstrumentTracksToVectorString(); + if( !vs.empty() ) + { + RString s = join( ",", vs ); + f.PutLine( "#INSTRUMENTTRACK:" + s + ";\n" ); + } + } f.PutLine( ssprintf( "#OFFSET:%.6f;", out.m_SongTiming.m_fBeat0OffsetInSeconds ) ); f.PutLine( ssprintf( "#SAMPLESTART:%.6f;", out.m_fMusicSampleStartSeconds ) ); f.PutLine( ssprintf( "#SAMPLELENGTH:%.6f;", out.m_fMusicSampleLengthSeconds ) ); diff --git a/src/Song.cpp b/src/Song.cpp index 4317d23f53..0ccf1d9762 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -41,7 +41,7 @@ * @brief The internal version of the cache for StepMania. * * Increment this value to invalidate the current cache. */ -const int FILE_CACHE_VERSION = 199; +const int FILE_CACHE_VERSION = 198; /** @brief How long does a song sample last by default? */ const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f; @@ -50,6 +50,14 @@ static Preference g_fLongVerSongSeconds( "LongVerSongSeconds", 60*2.5f ); static Preference g_fMarathonVerSongSeconds( "MarathonVerSongSeconds", 60*5.f ); static Preference g_BackUpAllSongSaves( "BackUpAllSongSaves", false ); +static const char *InstrumentTrackNames[] = { + "Guitar", + "Rhythm", + "Bass", +}; +XToString( InstrumentTrack ); +StringToX( InstrumentTrack ); + Song::Song() { FOREACH_BackgroundLayer( i ) @@ -446,6 +454,9 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) ASSERT_M( m_sSongDir.Left(3) != "../", m_sSongDir ); // meaningless FixupPath( m_sSongDir, "" ); FixupPath( m_sMusicFile, m_sSongDir ); + FOREACH_ENUM( InstrumentTrack, i ) + if( !m_sInstrumentTrackFile[i].empty() ) + FixupPath( m_sInstrumentTrackFile[i], m_sSongDir ); FixupPath( m_sBannerFile, m_sSongDir ); //FixupPath( m_sJacketFile, m_sSongDir ); //FixupPath( m_sDiscFile, m_sSongDir ); @@ -1193,6 +1204,10 @@ bool Song::HasBanner() const { return m_sBannerFile != "" && IsAFile(GetBannerPath()); } +bool Song::HasInstrumentTrack( InstrumentTrack it ) const +{ + return m_sInstrumentTrackFile[it] != "" && IsAFile(GetInstrumentTrackPath(it)); +} bool Song::HasLyrics() const { return m_sLyricsFile != "" && IsAFile(GetLyricsPath()); @@ -1260,6 +1275,21 @@ vector Song::GetFGChanges1ToVectorString() const return this->GetChangesToVectorString(this->GetForegroundChanges()); } +vector Song::GetInstrumentTracksToVectorString() const +{ + vector ret; + FOREACH_ENUM(InstrumentTrack, it) + { + if (this->HasInstrumentTrack(it)) + { + ret.push_back(InstrumentTrackToString(it) + + "=" + + this->m_sInstrumentTrackFile[it]); + } + } + return ret; +} + RString GetSongAssetPath( RString sPath, const RString &sSongPath ) { if( sPath == "" ) @@ -1294,6 +1324,11 @@ RString Song::GetMusicPath() const return GetSongAssetPath( m_sMusicFile, m_sSongDir ); } +RString Song::GetInstrumentTrackPath( InstrumentTrack it ) const +{ + return GetSongAssetPath( m_sInstrumentTrackFile[it], m_sSongDir ); +} + RString Song::GetBannerPath() const { return GetSongAssetPath( m_sBannerFile, m_sSongDir ); diff --git a/src/Song.h b/src/Song.h index 462d405ffd..5f17ad8969 100644 --- a/src/Song.h +++ b/src/Song.h @@ -20,7 +20,7 @@ void FixupPath( RString &path, const RString &sSongPath ); RString GetSongAssetPath( RString sPath, const RString &sSongPath ); /** @brief The version of the .ssc file format. */ -const static float STEPFILE_VERSION_NUMBER = 0.78f; +const static float STEPFILE_VERSION_NUMBER = 0.77f; /** @brief How many edits for this song can each profile have? */ const int MAX_EDITS_PER_SONG_PER_PROFILE = 15; @@ -42,6 +42,18 @@ enum BackgroundLayer /** @brief A custom foreach loop for the different background layers. */ #define FOREACH_BackgroundLayer( bl ) FOREACH_ENUM( BackgroundLayer, bl ) +/** @brief The different instrument tracks for band type games. */ +enum InstrumentTrack +{ + InstrumentTrack_Guitar, + InstrumentTrack_Rhythm, + InstrumentTrack_Bass, + NUM_InstrumentTrack, + InstrumentTrack_Invalid +}; +const RString& InstrumentTrackToString( InstrumentTrack it ); +InstrumentTrack StringToInstrumentTrack( const RString& s ); + /** @brief The collection of lyrics for the Song. */ struct LyricSegment { @@ -213,6 +225,7 @@ public: RString m_sOrigin; // song origin (for .ssc format) RString m_sMusicFile; + RString m_sInstrumentTrackFile[NUM_InstrumentTrack]; /** @brief The length of the music file. */ float m_fMusicLengthSeconds; @@ -235,6 +248,7 @@ public: vector m_sAttackString; RString GetMusicPath() const; + RString GetInstrumentTrackPath( InstrumentTrack it ) const; RString GetBannerPath() const; //RString GetJacketPath() const; //RString GetCDImagePath() const; @@ -247,6 +261,7 @@ public: bool m_bHasMusic, m_bHasBanner, m_bHasBackground; bool HasMusic() const; + bool HasInstrumentTrack( InstrumentTrack it ) const; /** * @brief Does this song have a banner? * @return true if it does, false otherwise. */ @@ -316,6 +331,8 @@ public: vector GetBGChanges2ToVectorString() const; vector GetFGChanges1ToVectorString() const; + vector GetInstrumentTracksToVectorString() const; + /** * @brief The list of LyricSegments. *