public InstrumentEditor(InstrumentArray instruments, byte index) { try { InitializeComponent(); Preview = new Music(); Entry_ByteBox.ValueChanged -= Entry_ByteBox_ValueChanged; Entry_ByteBox.Value = index; Entry_ByteBox.ValueChanged += Entry_ByteBox_ValueChanged; Instruments = instruments; Instrument_PianoBox.SelectionChanged += Instrument_PianoBox_SelectionChanged; Address_Label.Text = Instruments.Address.ToString(); Type_ComboBox.SelectedIndexChanged -= Type_ComboBox_SelectedIndexChanged; Type_ComboBox.DataSource = InstrumentTypes; Type_ComboBox.SelectedIndexChanged += Type_ComboBox_SelectedIndexChanged; BaseKey_ByteArrayBox.Load("Music Notes.txt"); } catch (Exception ex) { Program.ShowError("Could not properly open the " + this.Text, ex); Core_CloseEditor(this, null); } }
void Core_LoadInstruments() { try { if (CurrentMusic.TrackAmount == 0) { Instrument_PointerBox.Value = new Pointer(); Instrument_ListBox.DataSource = null; } else { Instrument_PointerBox.ValueChanged -= Instrument_PointerBox_ValueChanged; Instrument_PointerBox.Value = CurrentMusic.Instruments; Instrument_PointerBox.ValueChanged += Instrument_PointerBox_ValueChanged; Instruments = new InstrumentArray(CurrentMusic.Instruments); List <string> instruments = new List <string>(); string instrument; for (byte i = 0; i < 128; i++) { if (Instruments[i].IsUnused()) { if (View_HideInstruments.Checked) { continue; } else { instrument = "None"; } } else { switch (Instruments[i].Type) { case InstrumentType.Direct: instrument = "DirectSound"; break; case InstrumentType.Square1: instrument = "PSG Square 1"; break; case InstrumentType.Square2: instrument = "PSG Square 2"; break; case InstrumentType.Wave: instrument = "PSG Waveform"; break; case InstrumentType.Noise: instrument = "PSG Noise"; break; case InstrumentType.Fixed: instrument = "Fixed Pitch"; break; case InstrumentType.Multi: instrument = "MultiSample"; break; case InstrumentType.Drums: instrument = "Percussion"; break; default: instrument = ""; break; } } instruments.Add(Util.ByteToHex(i) + " - " + instrument); } Instrument_ListBox.DataSource = instruments; } } catch (Exception ex) { Program.ShowError("There has been an error while loading the instrument array.", ex); } }