private void LoadFile() { this.Enabled = false; Valid = false; if (_Reader != null) { _Reader.Dispose(); _Reader = null; } if (_File != null) { if (System.IO.File.Exists(_File) && !Path.GetFileName(_File).StartsWith("snd_bgm_TEST")) { Valid = true; } else { lblTime.Text = EMPTY_SOUND; return; } _Reader = new VGMStreamReader(_File); if (!_Reader.FileLoaded) { LogHelper.Warning(string.Format(Strings.WARNING_VGMSTREAM_LOAD_BGM, _File)); lblTime.Text = EMPTY_SOUND; return; } _FormatTotalTime = " / " + new TimeSpan(0, 0, _Reader.TotalSecondsToPlay).ToString(@"mm\:ss"); lblTime.Text = "00:00" + _FormatTotalTime; this.Enabled = true; } else { try { lblTime.Text = EMPTY_SOUND; } catch (Exception e) { LogHelper.Error(e.Message); } } }
public BGMEntry CreateBGMEntry(string bgmName) { string file = GetBGMFullPath("snd_bgm_" + bgmName + ".nus3bank"); VGMStreamReader reader = new VGMStreamReader(file); int lastId = GetNewBGMEntryID(); BGMEntry sEntryBGM = new BGMEntry(lastId); sEntryBGM.BGMTitle = bgmName; sEntryBGM.BGMUnk1 = 1; // Most common value is 1 sEntryBGM.BGMUnk2 = -1; sEntryBGM.BGMUnk3 = 0x190; //Most common value sEntryBGM.BGMUnk4 = -1; //Most common value is null sEntryBGM.MenuCheckPoint1 = -1; sEntryBGM.MenuCheckPoint2 = -1; sEntryBGM.MenuCheckPoint3 = -1; sEntryBGM.MenuCheckPoint4 = -1; if (reader.FileLoaded) { sEntryBGM.LoopStartTime = reader.LoopStartMilliseconds; sEntryBGM.LoopEndTime = reader.LoopEndMilliseconds; sEntryBGM.LoopStartSample = reader.LoopStartSample; sEntryBGM.LoopEndSample = reader.LoopEndSample; sEntryBGM.StreamTotalDuration = reader.TotalMilliseconds; sEntryBGM.StreamTotalSamples = reader.TotalSamples; reader.Dispose(); } else { LogHelper.Warning(string.Format(Strings.WARNING_VGMSTREAM_CREATE_BGMENTRY, file)); } _SoundEntriesBGMs.Add(sEntryBGM); _SoundEntriesBGMsPerID.Add(lastId, sEntryBGM); _SoundEntriesBGMsPerName.Add(bgmName, sEntryBGM); return(sEntryBGM); }