internal TrackEditor()
        {
            int w = 300 - 12 - 6, h = 400 - 24;
            listView = new ObjectListView
            {
                FullRowSelect = true,
                HeaderStyle = ColumnHeaderStyle.Nonclickable,
                HideSelection = false,
                Location = new Point(12, 12),
                MultiSelect = false,
                RowFormatter = RowFormatter,
                ShowGroups = false,
                Size = new Size(w, h),
                UseFiltering = true,
                UseFilterIndicator = true
            };
            OLVColumn c1, c2, c3, c4;
            c1 = new OLVColumn("Event", "Command.Name");
            c2 = new OLVColumn("Arguments", "Command.Arguments") { UseFiltering = false };
            c3 = new OLVColumn("Offset", "Offset") { AspectToStringFormat = "0x{0:X}", UseFiltering = false };
            c4 = new OLVColumn("Ticks", "AbsoluteTicks") { UseFiltering = false };
            c1.Width = c2.Width = c3.Width = 72;
            c4.Width = 45;
            c1.Hideable = c2.Hideable = c3.Hideable = c4.Hideable = false;
            c1.TextAlign = c2.TextAlign = c3.TextAlign = c4.TextAlign = HorizontalAlignment.Center;
            listView.AllColumns.AddRange(new OLVColumn[] { c1, c2, c3, c4 });
            listView.RebuildColumns();
            listView.SelectedIndexChanged += SelectedIndexChanged;
            listView.ItemActivate += ListView_ItemActivate;

            int h2 = h / 3 - 4;
            var panel1 = new ThemedPanel { Location = new Point(306, 12), Size = new Size(w, h2) };
            var panel2 = new ThemedPanel { Location = new Point(306, 140), Size = new Size(w, h2 - 1) };
            var panel3 = new ThemedPanel { Location = new Point(306, 267), Size = new Size(w, h2) };

            // Arguments Info
            for (int i = 0; i < 3; i++)
            {
                int y = 17 + (33 * i);
                argLabels[i] = new ThemedLabel
                {
                    AutoSize = true,
                    Location = new Point(52, y + 3),
                    Text = "Arg. " + (i + 1).ToString(),
                    Visible = false,
                };
                argNumerics[i] = new ThemedNumeric
                {
                    Location = new Point(w - 152, y),
                    Maximum = int.MaxValue,
                    Minimum = int.MinValue,
                    Size = new Size(100, 25),
                    Visible = false
                };
                argNumerics[i].ValueChanged += ArgumentChanged;
                panel1.Controls.AddRange(new Control[] { argLabels[i], argNumerics[i] });
            }

            // Track controls
            tracksBox = new ComboBox
            {
                Location = new Point(4, 4),
                Size = new Size(100, 21)
            };
            tracksBox.SelectedIndexChanged += TracksBox_SelectedIndexChanged;
            trackChangeVoicesButton = new ThemedButton
            {
                Location = new Point(13, 30),
                Text = "Change Voices"
            };
            trackChangeVoicesButton.Click += ChangeEvents;
            trackAddEventButton = new ThemedButton
            {
                Location = new Point(13, 30 + 25 + 5),
                Text = "Add Event"
            };
            trackAddEventButton.Click += AddEvent;
            commandsBox = new ComboBox
            {
                Location = new Point(115, 30 + 25 + 5 + 2),
                Size = new Size(100, 21)
            };
            trackRemoveEventButton = new ThemedButton
            {
                Location = new Point(13, 30 + 25 + 5 + 25 + 5),
                Text = "Remove Event"
            };
            treButton.Click += RemoveEvent;
            tracksBox.Enabled = tvButton.Enabled = taeButton.Enabled = treButton.Enabled = commandsBox.Enabled = false;
            tvButton.Size = taeButton.Size = treButton.Size = new Size(95, 25);
            var tvFrom = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            tvArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var tvTo = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            tvArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            tvArgs[0].Maximum = tvArgs[1].Maximum = 0xFF;
            tvArgs[0].Size = tvArgs[1].Size = new Size(45, 23);
            tvArgs[0].TextAlign = tvArgs[1].TextAlign = HorizontalAlignment.Center;
            tvFrom.AutoSize = tvTo.AutoSize = true;
            panel2.Controls.AddRange(new Control[] { tracksBox, tvButton, tvFrom, tvTo, tvArgs[0], tvArgs[1], taeButton, commandsBox, treButton });
            removeEventButton.Click += RemoveEvent;

            //Track controls box preparation
            tracksBox.Enabled = changeVoicesButton.Enabled = addEventButton.Enabled = removeEventButton.Enabled = commandsBox.Enabled = false;
            changeVoicesButton.Size = addEventButton.Size = removeEventButton.Size = new Size(95, 25);
            var originalVoiceLabel = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            trackVoiceDetails[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            trackVoiceDetails[0].Enabled = false;
            var newVoiceIDLabel = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            trackVoiceDetails[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            trackVoiceDetails[0].Maximum = trackVoiceDetails[1].Maximum = 0xFF;
            trackVoiceDetails[0].Size = trackVoiceDetails[1].Size = new Size(45, 23);
            trackVoiceDetails[0].TextAlign = trackVoiceDetails[1].TextAlign = HorizontalAlignment.Center;
            originalVoiceLabel.AutoSize = newVoiceIDLabel.AutoSize = true;
            trackEditPanel.Controls.AddRange(new Control[] { tracksBox, changeVoicesButton, originalVoiceLabel, newVoiceIDLabel, trackVoiceDetails[0], trackVoiceDetails[1], addEventButton, commandsBox, removeEventButton });

            trackRemoveEventButton.Click += RemoveEvent;
            tracksBox.Enabled = trackChangeVoicesButton.Enabled = trackAddEventButton.Enabled = trackRemoveEventButton.Enabled = commandsBox.Enabled = false;
            trackChangeVoicesButton.Size = trackAddEventButton.Size = trackRemoveEventButton.Size = new Size(95, 25);
            var trackFromVoiceButton = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            trackVoiceArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var trackToVoiceButton = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            trackVoiceArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            trackVoiceArgs[0].Maximum = trackVoiceArgs[1].Maximum = 0xFF;
            trackVoiceArgs[0].Size = trackVoiceArgs[1].Size = new Size(45, 23);
            trackVoiceArgs[0].TextAlign = trackVoiceArgs[1].TextAlign = HorizontalAlignment.Center;
            trackFromVoiceButton.AutoSize = trackToVoiceButton.AutoSize = true;
            panel2.Controls.AddRange(new Control[] { tracksBox, trackChangeVoicesButton, trackFromVoiceButton, trackToVoiceButton, trackVoiceArgs[0], trackVoiceArgs[1], trackAddEventButton, commandsBox, trackRemoveEventButton });

            // Global controls
            remapsBox = new ComboBox
            {
                DataSource = Config.InstrumentRemaps.Keys.ToArray(),
                Location = new Point(4, 4),
                Size = new Size(100, 21)
            };
            remapFromButton = new ThemedButton
            {
                Location = new Point(116, 3),
                Text = "From"
            };
            remapFromButton.Click += (s, e) => ApplyRemap(true);
            remapToButton = new ThemedButton
            {
                Location = new Point(203, 3),
                Text = "To"
            };
            remapToButton.Click += (s, e) => ApplyRemap(false);
            globalChangeVoicesButton = new ThemedButton
            {
                Location = new Point(13, 30),
                Size = new Size(95, 25),
                Text = "Change Voices"
            };
            globalChangeVoicesButton.Click += ChangeAllEvents;
            var globalFromVoiceButton = new ThemedLabel { Location = new Point(115, 30 + 2 + 3), Text = "From" };
            globalVoiceArgs[0] = new ThemedNumeric { Location = new Point(149, 30 + 2) };
            var globalToVoiceButton = new ThemedLabel { Location = new Point(204, 30 + 2 + 3), Text = "To" };
            globalVoiceArgs[1] = new ThemedNumeric { Location = new Point(224, 30 + 2) };
            globalVoiceArgs[0].Maximum = globalVoiceArgs[1].Maximum = 0xFF;
            globalVoiceArgs[0].Size = globalVoiceArgs[1].Size = new Size(45, 23);
            globalVoiceArgs[0].TextAlign = globalVoiceArgs[1].TextAlign = HorizontalAlignment.Center;
            globalFromVoiceButton.AutoSize = globalToVoiceButton.AutoSize = true;
            remapsBox.Enabled = remapFromButton.Enabled = remapToButton.Enabled = globalChangeVoicesButton.Enabled = false;
            panel3.Controls.AddRange(new Control[] { remapsBox, remapFromButton, remapToButton, globalChangeVoicesButton, globalFromVoiceButton, globalToVoiceButton, globalVoiceArgs[0], globalVoiceArgs[1] });

            ClientSize = new Size(600, 400);
            Controls.AddRange(new Control[] { listView, panel1, panel2, panel3 });
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox = false;
            Text = "GBA Music Studio ― Track Editor";

            UpdateTracks();
        }
        object entry; // The voice entry being edited

        public VoiceTableEditor()
        {
            int w = (600 / 2) - 12 - 6, h = 400 - 12 - 11;

            // Main VoiceTable view
            voicesListView = new ObjectListView
            {
                FullRowSelect = true,
                HeaderStyle   = ColumnHeaderStyle.Nonclickable,
                HideSelection = false,
                Location      = new Point(12, 12),
                MultiSelect   = false,
                ShowGroups    = false,
                Size          = new Size(w, h)
            };
            voicesListView.FormatRow += FormatRow;
            OLVColumn c1, c2, c3;

            c1 = new OLVColumn("#", "");
            c2 = new OLVColumn("Type", "ToString");
            c3 = new OLVColumn("Offset", "GetOffset")
            {
                AspectToStringFormat = "0x{0:X7}"
            };
            c1.Width     = 45;
            c2.Width     = c3.Width = 108;
            c1.Hideable  = c2.Hideable = c3.Hideable = false;
            c1.TextAlign = c2.TextAlign = c3.TextAlign = HorizontalAlignment.Center;
            voicesListView.AllColumns.AddRange(new OLVColumn[] { c1, c2, c3 });
            voicesListView.RebuildColumns();
            voicesListView.SelectedIndexChanged += MainIndexChanged;

            int h2 = (h / 2) - 5;

            // View of the selected voice's sub-voices
            subVoicesListView = new ObjectListView
            {
                FullRowSelect = true,
                HeaderStyle   = ColumnHeaderStyle.Nonclickable,
                HideSelection = false,
                Location      = new Point(306, 12),
                MultiSelect   = false,
                ShowGroups    = false,
                Size          = new Size(w, h2)
            };
            subVoicesListView.FormatRow += FormatRow;
            c1 = new OLVColumn("#", "");
            c2 = new OLVColumn("Type", "ToString");
            c3 = new OLVColumn("Offset", "GetOffset")
            {
                AspectToStringFormat = "0x{0:X7}"
            };
            c1.Width     = 45;
            c2.Width     = c3.Width = 108;
            c1.Hideable  = c2.Hideable = c3.Hideable = false;
            c1.TextAlign = c2.TextAlign = c3.TextAlign = HorizontalAlignment.Center;
            subVoicesListView.AllColumns.AddRange(new OLVColumn[] { c1, c2, c3 });
            subVoicesListView.RebuildColumns();
            subVoicesListView.SelectedIndexChanged += SubIndexChanged;

            // Panel to edit a voice
            voicePanel = new ThemedPanel {
                Location = new Point(306, 206), Size = new Size(w, h2)
            };

            // Panel controls
            addressLabel = new ThemedLabel {
                Location = new Point(2, 130), Text = "Address:"
            };
            voiceALabel = new ThemedLabel {
                Location = new Point(0 * w / 4 + 2, 160), Text = "A:"
            };
            voiceDLabel = new ThemedLabel {
                Location = new Point(1 * w / 4 + 2, 160), Text = "D:"
            };
            voiceSLabel = new ThemedLabel {
                Location = new Point(2 * w / 4 + 2, 160), Text = "S:"
            };
            voiceRLabel = new ThemedLabel {
                Location = new Point(3 * w / 4 + 2, 160), Text = "R:"
            };
            addressLabel.AutoSize    =
                voiceALabel.AutoSize = voiceDLabel.AutoSize = voiceSLabel.AutoSize = voiceRLabel.AutoSize = true;

            addressValue = new ValueTextBox {
                Location = new Point(w / 5, 127), Size = new Size(78, 24)
            };
            voiceAValue = new ValueTextBox {
                Location = new Point(0 * w / 4 + 20, 157)
            };
            voiceDValue = new ValueTextBox {
                Location = new Point(1 * w / 4 + 20, 157)
            };
            voiceSValue = new ValueTextBox {
                Location = new Point(2 * w / 4 + 20, 157)
            };
            voiceRValue = new ValueTextBox {
                Location = new Point(3 * w / 4 + 20, 157)
            };
            voiceAValue.Size          = voiceDValue.Size = voiceSValue.Size = voiceRValue.Size = new Size(44, 22);
            voiceAValue.ValueChanged += ArgumentChanged; voiceDValue.ValueChanged += ArgumentChanged; voiceSValue.ValueChanged += ArgumentChanged; voiceRValue.ValueChanged += ArgumentChanged;

            voicePanel.Controls.AddRange(new Control[] { addressLabel, addressValue,
                                                         voiceALabel, voiceDLabel, voiceSLabel, voiceRLabel,
                                                         voiceAValue, voiceDValue, voiceSValue, voiceRValue });

            ClientSize = new Size(600, 400);
            Controls.AddRange(new Control[] { voicesListView, subVoicesListView, voicePanel });
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox     = false;

            UpdateTable();
        }