diff --git a/stepmania/Themes/default/Sounds/ScreenSelectMusic loop music.redir b/stepmania/Themes/default/Sounds/ScreenSelectMusic loop music.redir new file mode 100644 index 0000000000..0bff0de1a5 --- /dev/null +++ b/stepmania/Themes/default/Sounds/ScreenSelectMusic loop music.redir @@ -0,0 +1 @@ +_common menu music diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 18eef9ee55..e6e250c33c 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -462,6 +462,7 @@ Fallback="ScreenWithMenuElements" NextScreen=GetSelectMusicNext() PrevScreen=ScreenTitleBranch() MusicWheelType="MusicWheel" +SampleMusicLoops=false ShowOptionsMessageSeconds=1.5 BannerX=0 BannerY=0 diff --git a/stepmania/src/GameSoundManager.cpp b/stepmania/src/GameSoundManager.cpp index e83db96b14..19b36383ce 100644 --- a/stepmania/src/GameSoundManager.cpp +++ b/stepmania/src/GameSoundManager.cpp @@ -42,6 +42,8 @@ static FadeState g_FadeState = FADE_NONE; static float g_fDimVolume = 1.0f; static float g_fOriginalVolume = 1.0f; static float g_fDimDurationRemaining = 0.0f; +static bool g_bWasPlayingOnLastUpdate = false; +static RString g_sFallbackMusicPath; struct MusicPlaying { @@ -85,7 +87,7 @@ struct MusicToPlay TimingData m_TimingData; NoteData m_LightsData; bool bForceLoop; - float fStartSecond, fLengthSeconds, fFadeOutLengthSeconds; + float fStartSecond, fLengthSeconds, fFadeInLengthSeconds, fFadeOutLengthSeconds; bool bAlignBeat; MusicToPlay() { @@ -235,6 +237,7 @@ static void StartMusic( MusicToPlay &ToPlay ) RageSoundParams p; p.m_StartSecond = ToPlay.fStartSecond; p.m_LengthSeconds = ToPlay.fLengthSeconds; + p.m_fFadeInSeconds = ToPlay.fFadeInLengthSeconds; p.m_fFadeOutSeconds = ToPlay.fFadeOutLengthSeconds; p.m_StartTime = when; if( ToPlay.bForceLoop ) @@ -463,6 +466,18 @@ float GameSoundManager::GetFrameTimingAdjustment( float fDeltaTime ) void GameSoundManager::Update( float fDeltaTime ) { + { + g_Mutex->Lock(); + bool bIsPlaying = g_Playing->m_Music->IsPlaying(); + g_Mutex->Unlock(); + if( !bIsPlaying && g_bWasPlayingOnLastUpdate && !g_sFallbackMusicPath.empty() ) + { + PlayMusic( g_sFallbackMusicPath, NULL, false, 0, -1, 1.5f ); + g_sFallbackMusicPath = ""; + } + g_bWasPlayingOnLastUpdate = bIsPlaying; + } + LockMut( *g_Mutex ); { @@ -502,7 +517,6 @@ void GameSoundManager::Update( float fDeltaTime ) return; const float fAdjust = GetFrameTimingAdjustment( fDeltaTime ); - if( !g_Playing->m_Music->IsPlaying() ) { /* There's no song playing. Fake it. */ @@ -630,14 +644,19 @@ RString GameSoundManager::GetMusicPath() const } void GameSoundManager::PlayMusic( - const RString &sFile, + RString sFile, const TimingData *pTiming, bool bForceLoop, float fStartSecond, float fLengthSeconds, + float fFadeInLengthSeconds, float fFadeOutLengthSeconds, - bool bAlignBeat ) + bool bAlignBeat, + RString sFallback + ) { + g_sFallbackMusicPath = sFallback; + // LOG->Trace("play '%s' (current '%s')", file.c_str(), g_Playing->m_Music->GetLoadedFilePath().c_str()); MusicToPlay ToPlay; @@ -657,6 +676,7 @@ void GameSoundManager::PlayMusic( ToPlay.bForceLoop = bForceLoop; ToPlay.fStartSecond = fStartSecond; ToPlay.fLengthSeconds = fLengthSeconds; + ToPlay.fFadeInLengthSeconds = fFadeInLengthSeconds; ToPlay.fFadeOutLengthSeconds = fFadeOutLengthSeconds; ToPlay.bAlignBeat = bAlignBeat; diff --git a/stepmania/src/GameSoundManager.h b/stepmania/src/GameSoundManager.h index ed47baf4a6..e9119caa45 100644 --- a/stepmania/src/GameSoundManager.h +++ b/stepmania/src/GameSoundManager.h @@ -17,13 +17,15 @@ public: void Update( float fDeltaTime ); void PlayMusic( - const RString &file, + RString sFile, const TimingData *pTiming = NULL, bool force_loop = false, float start_sec = 0, float length_sec = -1, + float fFadeInLengthSeconds = 0, float fade_len = 0, - bool align_beat = true ); + bool align_beat = true, + RString sFallback = "" ); void StopMusic() { PlayMusic(""); } void DimMusic( float fVolume, float fDurationSeconds ); RString GetMusicPath() const; diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 0da2bc9521..9ddd30f99b 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -825,6 +825,7 @@ void ScreenEdit::PlayPreviewMusic() false, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds, + 0.0f, 1.5f ); } diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 4cef805874..fd224159e7 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -63,6 +63,7 @@ ScreenSelectMusic::ScreenSelectMusic() void ScreenSelectMusic::Init() { SAMPLE_MUSIC_DELAY.Load( m_sName, "SampleMusicDelay" ); + SAMPLE_MUSIC_LOOPS.Load( m_sName, "SampleMusicLoops" ); DO_ROULETTE_ON_MENU_TIMER.Load( m_sName, "DoRouletteOnMenuTimer" ); ALIGN_MUSIC_BEATS.Load( m_sName, "AlignMusicBeat" ); CODES.Load( m_sName, "Codes" ); @@ -89,6 +90,7 @@ void ScreenSelectMusic::Init() m_sRouletteMusicPath = THEME->GetPathS(m_sName,"roulette music"); m_sRandomMusicPath = THEME->GetPathS(m_sName,"random music"); m_sCourseMusicPath = THEME->GetPathS(m_sName,"course music"); + m_sLoopMusicPath = THEME->GetPathS(m_sName,"loop music"); m_sFallbackCDTitlePath = THEME->GetPathG(m_sName,"fallback cdtitle"); @@ -289,9 +291,11 @@ void ScreenSelectMusic::CheckBackgroundRequests( bool bForce ) SOUND->PlayMusic( m_sSampleMusicToPlay, m_pSampleMusicTimingData, - true, m_fSampleStartSeconds, m_fSampleLengthSeconds, + SAMPLE_MUSIC_LOOPS, m_fSampleStartSeconds, m_fSampleLengthSeconds, + 0.0f, 1.5f, /* fade out for 1.5 seconds */ - ALIGN_MUSIC_BEATS ); + ALIGN_MUSIC_BEATS, + m_sLoopMusicPath ); } } diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index 086ccf837c..4d8d619fac 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -61,6 +61,7 @@ protected: int m_iSelection[NUM_PLAYERS]; ThemeMetric SAMPLE_MUSIC_DELAY; + ThemeMetric SAMPLE_MUSIC_LOOPS; ThemeMetric DO_ROULETTE_ON_MENU_TIMER; ThemeMetric ALIGN_MUSIC_BEATS; ThemeMetric CODES; @@ -99,6 +100,7 @@ protected: RString m_sRouletteMusicPath; RString m_sRandomMusicPath; RString m_sCourseMusicPath; + RString m_sLoopMusicPath; RString m_sFallbackCDTitlePath; FadingBanner m_Banner;