/// <summary> /// Play current song. /// </summary> public void Play(SongFiles song) { if (!InitSynth()) { return; } // Stop if playing another song Stop(); // Ensure audio source is enabled audioSource.enabled = true; // Load song data string filename = EnumToFilename(song); byte[] songData = LoadSong(filename); if (songData == null) { return; } // Create song MidiFile midiFile = new MidiFile(new MyMemoryFile(songData, filename)); if (midiSequencer.LoadMidi(midiFile)) { midiSequencer.Play(); currentMidiName = filename; playEnabled = true; } }
void SelectCurrentSong() { if (currentPlaylist == null) { return; } int index = UnityEngine.Random.Range(0, currentPlaylist.Length); currentSong = currentPlaylist[index]; }
public override void RestoreSaveData(object dataIn) { if (dataIn == null) { return; } SaveData_v1 data = (SaveData_v1)dataIn; songFile = data.song; }
/// <summary> /// Play current song. /// </summary> public void Play(SongFiles song) { if (!InitSynth()) { return; } // Stop if playing another song Stop(); // Import custom song from disk if (SoundReplacement.CustomSongExist(song)) { // Load song file WWW customSongFile = SoundReplacement.LoadCustomSong(song); if (customSongFile != null) { // Let www import the song customSong.IsReady = false; // Play song StartCoroutine(PlayCustomSong(customSongFile)); // Settings Song = song; customSong.UseCustomSong = true; IsPlaying = true; return; } Debug.LogError("Can't load custom song " + song); } // Load song data string filename = EnumToFilename(song); byte[] songData = LoadSong(filename); if (songData == null) { return; } // Create song MidiFile midiFile = new MidiFile(new MyMemoryFile(songData, filename)); if (midiSequencer.LoadMidi(midiFile)) { midiSequencer.Play(); currentMidiName = filename; playEnabled = true; IsPlaying = true; } }
void SelectCurrentSong() { if (currentPlaylist == null) { return; } UnityEngine.Random.seed = System.DateTime.Now.Millisecond; int index = UnityEngine.Random.Range(0, currentPlaylist.Length); currentSong = currentPlaylist[index]; currentSongIndex = index; }
void SelectCurrentSong() { if (currentPlaylist == null || currentPlaylist.Length == 0) { return; } UnityEngine.Random.InitState(DateTime.Now.Millisecond); int index = UnityEngine.Random.Range(0, currentPlaylist.Length); currentSong = currentPlaylist[index]; currentSongIndex = index; }
/// <summary> /// Play next song in current playlist. /// </summary> public void PlayNextSong() { if (currentPlaylist == null) { return; } if (++currentSongIndex >= currentPlaylist.Length) { currentSongIndex = 0; } currentSong = currentPlaylist[currentSongIndex]; PlayCurrentSong(); }
/// <summary> /// Play previous song in current playlist. /// </summary> public void PlayPreviousSong() { if (currentPlaylist == null) { return; } if (--currentSongIndex < 0) { currentSongIndex = currentPlaylist.Length - 1; } currentSong = currentPlaylist[currentSongIndex]; PlayCurrentSong(); }
/// <summary> /// Play current song. /// </summary> public void Play(SongFiles song) { if (!InitSynth()) { return; } // Stop if playing another song Stop(); // Import custom song AudioClip clip; if (isImported = SoundReplacement.TryImportSong(song, out clip)) { Song = song; audioSource.clip = clip; isLoading = true; return; } // Load song data string filename = EnumToFilename(song); byte[] songData = LoadSong(filename); if (songData == null) { return; } // Create song MidiFile midiFile = new MidiFile(new MyMemoryFile(songData, filename)); if (midiSequencer.LoadMidi(midiFile)) { midiSequencer.Play(); currentMidiName = filename; playEnabled = true; IsPlaying = true; } }
void SelectCurrentSong() { if (currentPlaylist == null || currentPlaylist.Length == 0) { return; } int index = 0; // General MIDI song selection { uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); DFRandom.srand(gameMinutes / 1440); uint random = DFRandom.rand(); if (currentPlaylist == NightSongs) { index = (int)(random % NightSongs.Length); } else if (currentPlaylist == SunnySongs) { index = (int)(random % SunnySongs.Length); } else if (currentPlaylist == CloudySongs) { index = (int)(random % CloudySongs.Length); } else if (currentPlaylist == OvercastSongs) { index = (int)(random % OvercastSongs.Length); } else if (currentPlaylist == RainSongs) { index = (int)(random % RainSongs.Length); } else if (currentPlaylist == SnowSongs) { index = (int)(random % SnowSongs.Length); } else if (currentPlaylist == TempleSongs && playerEnterExit) { byte[] templeFactions = { 0x52, 0x54, 0x58, 0x5C, 0x5E, 0x62, 0x6A, 0x24 }; uint factionOfPlayerEnvironment = playerEnterExit.FactionID; index = Array.IndexOf(templeFactions, (byte)factionOfPlayerEnvironment); if (index < 0) { byte[] godFactions = { 0x15, 0x16, 0x18, 0x1A, 0x1B, 0x1D, 0x21, 0x23 }; index = Array.IndexOf(godFactions, (byte)factionOfPlayerEnvironment); } } else if (currentPlaylist == TavernSongs) { index = (int)(gameMinutes / 1440 % TavernSongs.Length); } else if (currentPlaylist == DungeonInteriorSongs) { PlayerGPS gps = GameManager.Instance.PlayerGPS; ushort unknown2 = 0; int region = 0; if (gps.HasCurrentLocation) { unknown2 = (ushort)gps.CurrentLocation.Dungeon.RecordElement.Header.Unknown2; region = gps.CurrentRegionIndex; } DFRandom.srand(unknown2 ^ ((byte)region << 8)); random = DFRandom.rand(); index = (int)(random % 15); } else if (currentPlaylist == SneakingSongs) { index = UnityEngine.Random.Range(0, SneakingSongs.Length); } } currentSong = currentPlaylist[index]; currentSongIndex = index; }
private string EnumToFilename(SongFiles song) { string enumName = song.ToString(); return(enumName.Remove(0, "song_".Length) + ".mid"); }
/// <summary> /// Seek song from mods. /// </summary> /// <param name="song">Song to seek.</param> /// <param name="audioClip">Audioclip with imported sound data.</param> /// <returns>True if song is found.</returns> public static bool TryImportSong(SongFiles song, out AudioClip audioClip) { return(TryImportAudioClip(song.ToString(), ".ogg", true, out audioClip)); }
/// <summary> /// Load custom sound file from disk. /// </summary> /// <param name="song"></param> /// <returns></returns> static public WWW LoadCustomSong(SongFiles song) { return(GetWwwFile(song.ToString() + songExtension)); }
/// <summary> /// Play current song. /// </summary> public void Play(SongFiles song) { if (!InitSynth()) return; // Stop if playing another song Stop(); // Load song data string filename = EnumToFilename(song); byte[] songData = LoadSong(filename); if (songData == null) return; // Create song MidiFile midiFile = new MidiFile(new MyMemoryFile(songData, filename)); if (midiSequencer.LoadMidi(midiFile)) { midiSequencer.Play(); currentMidiName = filename; playEnabled = true; } }
void SelectCurrentSong() { if (currentPlaylist == null) return; UnityEngine.Random.InitState(DateTime.Now.Millisecond); int index = UnityEngine.Random.Range(0, currentPlaylist.Length); currentSong = currentPlaylist[index]; currentSongIndex = index; }
/// <summary> /// Play previous song in current playlist. /// </summary> public void PlayPreviousSong() { if (currentPlaylist == null) return; if (--currentSongIndex < 0) currentSongIndex = currentPlaylist.Length - 1; currentSong = currentPlaylist[currentSongIndex]; PlayCurrentSong(); }
/// <summary> /// Play next song in current playlist. /// </summary> public void PlayNextSong() { if (currentPlaylist == null) return; if (++currentSongIndex >= currentPlaylist.Length) currentSongIndex = 0; currentSong = currentPlaylist[currentSongIndex]; PlayCurrentSong(); }
private string EnumToFilename(SongFiles song) { string enumName = song.ToString(); return enumName.Remove(0, "song_".Length) + ".mid"; }
/// <summary> /// Check if song file exist on disk. /// </summary> /// <param name="song">Name of song.</param> /// <returns></returns> static public bool CustomSongExist(SongFiles song) { return(SoundFileExist(song.ToString() + songExtension)); }