/// <summary> /// Start playing audio /// </summary> public static void StartLazyPlayer() { Stop(); if (songPath == "") { return; } // Initialize the song try { song = new AudioTrack(songPath) { Rate = audioRate, Volume = Config.GetInt("Audio", "MusicVolume"), }; } catch (AudioEngineException) { PulsarcLogger.Error(ManagedBass.Bass.LastError.ToString(), LogType.Runtime); } song.ApplyRate(Config.GetBool("Audio", "RatePitch")); song.Play(); active = true; }
/// <summary> /// Initializes the GameAudioPlayer /// </summary> public static void GameAudioPlayer() { // Initialize variables threadLimiterWatch = new Stopwatch(); threadLimiterWatch.Start(); activeThreadLimiterWatch = true; if (songPath == "") { return; } running = true; var threadTime = new Stopwatch(); // Initialize the song song = new AudioTrack(songPath) { Rate = audioRate, Volume = Config.GetInt("Audio", "MusicVolume"), }; song.ApplyRate(Config.GetBool("Audio", "RatePitch")); threadLimiterWatch.Start(); // Add a delay while (threadLimiterWatch.ElapsedMilliseconds < startDelayMs - offset) { } // Start playing if the gameplay engine is active if (GameplayEngine.Active) { threadLimiterWatch.Restart(); song.Play(); threadTime.Start(); active = true; } }