private void MusicTest_Load(object sender, EventArgs e) { actx = new AudioContext(); tfx = new TFXFile(); var m = new TFXMacro { Steps = new List <TFXMacroCommand>() }; m.Steps.Add(new TFXMacroCommand(0x07000000)); tfx.Macros.Add(m); var p = new TFXPattern { Steps = new List <TFXPatternCommand>() }; p.Steps.Add(new TFXPatternCommand(0xF0000000)); tfx.Patterns.Add(p); UpdateTrackstepView(tfx); UpdateSongView(tfx); numericUpDownPattern.Maximum = tfx.Patterns.Count - 1; numericUpDownMacro.Maximum = tfx.Macros.Count - 1; UpdateMacroView(tfx.Macros[(int)numericUpDownMacro.Value]); UpdatePatternView(tfx.Patterns[(int)numericUpDownPattern.Value]); textBoxMessage.Lines = new string[] { tfx.TextLines[0].TrimEnd(), tfx.TextLines[1].TrimEnd(), tfx.TextLines[2].TrimEnd(), tfx.TextLines[3].TrimEnd() }; comboBoxPreviewNote.Items.Clear(); for (int i = 0; i < 64; ++i) { comboBoxPreviewNote.Items.Add(Note.Format(i)); } comboBoxPreviewNote.SelectedIndex = 42; sampledata = new byte[1]; var def = @"..\..\..\game\unpacked\WORLD1.TFX"; //def = "last.tfx"; if (File.Exists(def)) { Open(def); } var animationTimer = new Timer { Interval = 1000 / 60 }; animationTimer.Tick += AnimationTimer_Tick; animationTimer.Start(); }
void UpdatePatternView(TFXPattern pattern) { var listview = listViewPattern; listview.BeginUpdate(); for (int i = 0; i < pattern.Steps.Count; ++i) { var step = pattern.Steps[i]; int note = -1; if (step.Note < 0x80) { note = step.Note; // note without wait } else if (step.Note < 0xC0) { note = step.Note - 0x80; // note with wait } else if (step.Note < 0xF0) { note = step.Note - 0xC0; // note with portamento } var item = new ListViewItem(i.ToString()); item.SubItems.Add(step.Note.ToString("X2")); string status = "..."; switch (step.Note) { case 0xF0: status = "End"; break; case 0xF1: status = "Loop"; break; case 0xF2: status = "Jump"; break; case 0xF3: status = "Wait"; break; case 0xF4: status = "STOP"; break; case 0xF5: status = "Kup^"; break; case 0xF6: status = "Vibr"; break; case 0xF7: status = "Enve"; break; case 0xF8: status = "GsPt"; break; case 0xF9: status = "RoPt"; break; case 0xFA: status = "Fade"; break; case 0xFB: status = "PPat"; break; case 0xFC: status = "Port"; break; case 0xFD: status = "Lock"; break; case 0xFE: status = "StCu"; break; case 0xFF: status = "NOP!"; break; default: status = note >= 0 ? Note.Format(note) : "-"; break; } item.SubItems.Add(status); item.SubItems.Add(step.Macro.ToString("X2")); item.SubItems.Add("..."); item.SubItems.Add(step.Volume.ToString("X")); item.SubItems.Add(step.Channel.ToString("X")); item.SubItems.Add(step.Detune.ToString("X2")); if (i < listview.Items.Count) { listview.Items[i] = item; } else { listview.Items.Add(item); } } while (listview.Items.Count > pattern.Steps.Count) { listview.Items.RemoveAt(listview.Items.Count - 1); } listview.EndUpdate(); }