public static void _Update() { int currentGlobalSample = -1; foreach (KeyValuePair <int, MusicSync> trackpair in Songs[CurrentSong]) { MusicSync track = trackpair.Value; if (currentGlobalSample >= 0) { track.CurrentSample = currentGlobalSample; } else { currentGlobalSample = track.CurrentSample; } if (track.Volume < 1) { track.Volume += track.FadeSpeed; } else if (track.Volume > 1) { track.Volume += 1; } } }
public static void AddTrack(int songId, int trackId, MusicSync newTrack) { if (hasStarted == false) { _Start(); } Songs[songId].Add(trackId, newTrack); }
public static void PlaySong(int song) { if (hasStarted == false) { Debug.Assert(true, "MusicController.PlaySong() was called too fast, the tracks have not registered themselves yet!"); return; } foreach (KeyValuePair <int, MusicSync> trackpair in Songs[CurrentSong]) { MusicSync track = trackpair.Value; track.Stop(); track.Mute = true; track.Volume = 0; track.FadeSpeed = (1f / 60f); } CurrentSong = song; foreach (KeyValuePair <int, MusicSync> trackpair in Songs[CurrentSong]) { MusicSync track = trackpair.Value; track.Play(); track.Mute = true; track.Volume = 0; track.FadeSpeed = (1f / 60f); } if (CurrentSong == 0) { Songs[CurrentSong][0].Mute = false; } if (CurrentSong == 1) { Songs[CurrentSong][0].Mute = false; } if (CurrentSong == 2) { Songs[CurrentSong][0].Mute = false; Songs[CurrentSong][1].Mute = false; Songs[CurrentSong][2].Mute = false; Songs[CurrentSong][3].Mute = false; } }
public static void FadeInTrack(MusicSync track, float time) { track.Volume = 0; track.Mute = false; track.FadeSpeed = (1f / time) * (1f / 60f); }