void CASWJukeboxPlaylist::PlayRandomTrack( float fadeInTime /*= 1.0f*/, const char *szDefaultTrack /*= null */ ) { // Choose a random track to play int count = m_CombatMusicPlaylist.Count(); int index = 0; CSoundPatch* pNewSound = null; CLocalPlayerFilter filter; if( count == 0 ) { DevMsg( "JUKEBOX: Playing Track: %s%s.mp3\n", "*#music/_mp3/", szDefaultTrack ); if( !Q_strcmp("", szDefaultTrack ) ) return; pNewSound = CSoundEnvelopeController::GetController().SoundCreate( filter, 0, CHAN_STATIC, szDefaultTrack, SNDLVL_NONE ); } else { // If there's more than one track, randomize it so the current track doesn't repeat itself if( count > 1 ) { do { index = rand() % (count ); } while( index == m_iCurrentTrack ); } DevMsg( "JUKEBOX: Playing Track: %s%s.mp3\n", "*#music/_mp3/", m_CombatMusicPlaylist[index].m_szHexname ); pNewSound = CSoundEnvelopeController::GetController().SoundCreate( filter, 0, CHAN_STATIC, CFmtStr( "%s%s.mp3", "*#music/_mp3/", m_CombatMusicPlaylist[index].m_szHexname), SNDLVL_NONE ); } if( !pNewSound ) { return; } // If combat music is playing and there's more than one track, fade it out and play the new music once it's done if( m_pCombatMusic ) { if( count == 1 ) return; StopTrack( false, fadeInTime ); CSoundEnvelopeController::GetController().Play( pNewSound, 0.0f, 100, 1.0f ); } else { CSoundEnvelopeController::GetController().Play( pNewSound, 0.0f, 100 ); } CSoundEnvelopeController::GetController().SoundChangeVolume( pNewSound, 1.0f, fadeInTime ); m_pCombatMusic = pNewSound; m_iCurrentTrack = index; }
void FullStop(void) { if( GetSlewStatus()==1 ) { StopSlew(NORTH); usleep(250000.); StopSlew(SOUTH); usleep(250000.); StopSlew(EAST); usleep(250000.); StopSlew(WEST); usleep(250000.); } StopTrack(); }
void CASWJukeboxPlaylist::MarkTrackForDeletion( int index ) { if( index >= m_CombatMusicPlaylist.Count() ) return; else { if( index == m_iCurrentTrack ) StopTrack( true, 0.0f ); m_CombatMusicPlaylist[index].m_bIsMarkedForDeletion = true; // Delete the audio file too const char *szFullpath = CFmtStr( "%s%s.mp3", "sound/music/_mp3/", m_CombatMusicPlaylist[index].m_szHexname ); if( filesystem->FileExists( szFullpath, NULL ) ) { filesystem->RemoveFile( szFullpath, NULL ); } } }
void CASWJukeboxPlaylist::FireGameEvent( IGameEvent *event ) { if( !event ) return; if( FStrEq( event->GetName(), "jukebox_play_random") ) { // Play some random music float fadeInTime = event->GetFloat( "fadeintime" ); const char *szDefaultTrack = event->GetString( "defaulttrack" ); PlayRandomTrack( fadeInTime, szDefaultTrack ); } else if( FStrEq( event->GetName(), "jukebox_stop" ) ) { // Always fade the music from the stop event float fadeOutTime = event->GetFloat( "fadeouttime" ); StopTrack( false, fadeOutTime ); } }
Tracker::~Tracker() { StopTrack(); delete m_pSensorfusion; }
void CASWJukeboxPlaylist::RemoveAllMusic( void ) { StopTrack( true, 0.0f ); m_CombatMusicPlaylist.RemoveAll(); }
void CASWJukeboxPlaylist::LevelShutdownPostEntity( void ) { // Stop music StopTrack( true ); RemoveAllMusic(); }