From e79105f12de9e3d2fd22bccfc09410db04ae9497 Mon Sep 17 00:00:00 2001 From: 110-kenichi <110.kenichi@gmail.com> Date: Sat, 7 Nov 2020 12:10:05 +0900 Subject: [PATCH] 2.5.1.0 Improved MIDI file Player UI. --- README.md | 3 +- src/mamidimemo/Gui/FormMain.Designer.cs | 21 ++++++++-- src/mamidimemo/Gui/FormMain.cs | 53 +++++++++++++++++++++++++ src/mamidimemo/Gui/FormMain.resx | 52 +++++++++++++++++++----- src/mamidimemo/Program.cs | 2 +- 5 files changed, 114 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 58e5727aefd13..a3aa2f2ea1185 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -MAmidiMEmo V2.5.0.0 / Itoken (c)2019, 2020 / GPL-2.0 +MAmidiMEmo V2.5.1.0 / Itoken (c)2019, 2020 / GPL-2.0 *** What is the MAmidiMEmo? *** @@ -234,6 +234,7 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing *** Changes *** +2.5.1.0 Improved MIDI file Player UI. 2.5.0.0 Added MIDI file Player tab. Supported MAmidi file that is MAmi file and midi file are archived file. To create MAmidi file, load midi file and export MAmidi file. Fixed portamento time (Almost the same as the GS module portamento time). diff --git a/src/mamidimemo/Gui/FormMain.Designer.cs b/src/mamidimemo/Gui/FormMain.Designer.cs index 95152b71dd6a6..771caa18dee24 100644 --- a/src/mamidimemo/Gui/FormMain.Designer.cs +++ b/src/mamidimemo/Gui/FormMain.Designer.cs @@ -162,6 +162,7 @@ private void InitializeComponent() this.fileSystemWatcherMidi = new System.IO.FileSystemWatcher(); this.timerReload = new System.Windows.Forms.Timer(this.components); this.saveFileDialogMAmidi = new System.Windows.Forms.SaveFileDialog(); + this.panelChDisp = new System.Windows.Forms.Panel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -934,7 +935,7 @@ private void InitializeComponent() // // tableLayoutPanel1 // - this.tableLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); + this.tableLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(249)))), ((int)(((byte)(146)))), ((int)(((byte)(0))))); resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); this.tableLayoutPanel1.Controls.Add(this.metroTrackBarVol, 4, 1); this.tableLayoutPanel1.Controls.Add(this.label1, 1, 0); @@ -946,13 +947,14 @@ private void InitializeComponent() this.tableLayoutPanel1.Controls.Add(this.label3, 3, 0); this.tableLayoutPanel1.Controls.Add(this.label4, 6, 1); this.tableLayoutPanel1.Controls.Add(this.labelCpuLoad, 7, 1); + this.tableLayoutPanel1.Controls.Add(this.panelChDisp, 5, 1); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // metroTrackBarVol // + resources.ApplyResources(this.metroTrackBarVol, "metroTrackBarVol"); this.metroTrackBarVol.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); this.metroTrackBarVol.DataBindings.Add(new System.Windows.Forms.Binding("Value", global::zanac.MAmidiMEmo.Properties.Settings.Default, "MasterVolume", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - resources.ApplyResources(this.metroTrackBarVol, "metroTrackBarVol"); this.metroTrackBarVol.Name = "metroTrackBarVol"; this.metroTrackBarVol.UseCustomBackColor = true; this.metroTrackBarVol.Value = global::zanac.MAmidiMEmo.Properties.Settings.Default.MasterVolume; @@ -967,15 +969,16 @@ private void InitializeComponent() // labelClock // resources.ApplyResources(this.labelClock, "labelClock"); + this.labelClock.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); this.labelClock.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(115)))), ((int)(((byte)(63)))), ((int)(((byte)(0))))); this.labelClock.Name = "labelClock"; this.labelClock.UseCompatibleTextRendering = true; // // panelOsc2 // - this.panelOsc2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(249)))), ((int)(((byte)(146)))), ((int)(((byte)(0))))); - this.tableLayoutPanel1.SetColumnSpan(this.panelOsc2, 3); resources.ApplyResources(this.panelOsc2, "panelOsc2"); + this.panelOsc2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); + this.tableLayoutPanel1.SetColumnSpan(this.panelOsc2, 3); this.panelOsc2.Name = "panelOsc2"; this.panelOsc2.Paint += new System.Windows.Forms.PaintEventHandler(this.panelOsc2_Paint); // @@ -983,6 +986,7 @@ private void InitializeComponent() // this.labelTitle.AllowDrop = true; this.labelTitle.AutoEllipsis = true; + this.labelTitle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); this.tableLayoutPanel1.SetColumnSpan(this.labelTitle, 4); resources.ApplyResources(this.labelTitle, "labelTitle"); this.labelTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(115)))), ((int)(((byte)(63)))), ((int)(((byte)(0))))); @@ -1018,6 +1022,7 @@ private void InitializeComponent() // labelCpuLoad // resources.ApplyResources(this.labelCpuLoad, "labelCpuLoad"); + this.labelCpuLoad.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); this.labelCpuLoad.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(115)))), ((int)(((byte)(63)))), ((int)(((byte)(0))))); this.labelCpuLoad.Name = "labelCpuLoad"; this.labelCpuLoad.UseCompatibleTextRendering = true; @@ -1478,6 +1483,13 @@ private void InitializeComponent() resources.ApplyResources(this.saveFileDialogMAmidi, "saveFileDialogMAmidi"); this.saveFileDialogMAmidi.SupportMultiDottedExtensions = true; // + // panelChDisp + // + this.panelChDisp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(126)))), ((int)(((byte)(0))))); + resources.ApplyResources(this.panelChDisp, "panelChDisp"); + this.panelChDisp.Name = "panelChDisp"; + this.panelChDisp.Paint += new System.Windows.Forms.PaintEventHandler(this.panelChDisp_Paint); + // // FormMain // resources.ApplyResources(this, "$this"); @@ -1648,6 +1660,7 @@ private void InitializeComponent() private System.Windows.Forms.Panel panel1; private System.Windows.Forms.ToolStripMenuItem exportMAmidiToolStripMenuItem; private System.Windows.Forms.SaveFileDialog saveFileDialogMAmidi; + private System.Windows.Forms.Panel panelChDisp; } } diff --git a/src/mamidimemo/Gui/FormMain.cs b/src/mamidimemo/Gui/FormMain.cs index 785a400d6faa6..9e0f0f876c788 100644 --- a/src/mamidimemo/Gui/FormMain.cs +++ b/src/mamidimemo/Gui/FormMain.cs @@ -218,6 +218,8 @@ public FormMain() pianoControl1.NoteOff += PianoControl1_NoteOff; pianoControl1.EntryDataChanged += PianoControl1_EntryDataChanged; + MidiManager.MidiEventReceived += MidiManager_MidiEventReceived; + ImageUtility.AdjustControlImagesDpiScale(this); } @@ -825,7 +827,10 @@ private void timer1_Tick(object sender, EventArgs e) if (tabControlBottom.SelectedTab == tabPage1) tabPage1.Invalidate(); else if (tabControlBottom.SelectedTab == tabPage4) + { panelOsc2.Invalidate(); + panelChDisp.Invalidate(); + } clockCounter++; if (clockCounter > 100 / timerOsc.Interval) @@ -1397,5 +1402,53 @@ private void exportMAmidiToolStripMenuItem_Click(object sender, EventArgs e) } } } + + private void MidiManager_MidiEventReceived(object sender, MidiEvent e) + { + if (e.EventType == MidiEventType.NoteOn) + { + NoteOnEvent noe = (NoteOnEvent)e; + if (noe.Velocity != 0) + { + lock (chNoteOnData) + chNoteOnData[noe.Channel] = noe.Velocity; + } + } + } + + private int[] chNoteOnData = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + private Brush chDispBarBrush = new SolidBrush(Color.FromArgb(115, 63, 0)); + + private Brush chDispBackBrush = new SolidBrush(Color.FromArgb(229, 126, 0)); + + /// + /// + /// + /// + /// + private void panelChDisp_Paint(object sender, PaintEventArgs e) + { + int w = (panelChDisp.Width / 16); + int bw = w - (2 * 2); + int h = panelChDisp.Height; + int bh = h - (2 * 2); + var g = e.Graphics; + + for (int i = 0; i < 16; i++) + { + var vel = chNoteOnData[i]; + + int x = i * w + 2; + int y = bh * (127 - vel) / 127; + g.FillRectangle(chDispBackBrush, x, 2, bw, y); + g.FillRectangle(chDispBarBrush, x, 2 + y, bw, bh - y); + + vel -= 8; + if (vel < 0) + vel = 0; + chNoteOnData[i] = vel; + } + } } } diff --git a/src/mamidimemo/Gui/FormMain.resx b/src/mamidimemo/Gui/FormMain.resx index 40fcc26e4d957..c67f6a6b5be61 100644 --- a/src/mamidimemo/Gui/FormMain.resx +++ b/src/mamidimemo/Gui/FormMain.resx @@ -1816,14 +1816,14 @@ 8 - - Fill + + None 245, 45 - 127, 41 + 144, 41 3 @@ -1876,12 +1876,12 @@ 1 + + None + True - - Fill - MS UI Gothic, 24pt @@ -1889,10 +1889,10 @@ NoControl - 69, 3 + 93, 3 - 133, 39 + 84, 39 5 @@ -1915,6 +1915,9 @@ 2 + + None + 6, 45 @@ -2092,6 +2095,9 @@ 8 + + None + True @@ -2102,7 +2108,7 @@ NoControl - 774, 42 + 774, 46 61, 39 @@ -2128,6 +2134,30 @@ 9 + + Fill + + + 395, 45 + + + 324, 41 + + + 6 + + + panelChDisp + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 10 + Fill @@ -2159,7 +2189,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="metroTrackBarVol" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelClock" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="panelOsc2" Row="1" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="labelTitle" Row="0" RowSpan="1" Column="4" ColumnSpan="4" /><Control Name="labelStat" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label3" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label4" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="labelCpuLoad" Row="1" RowSpan="1" Column="7" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,50,AutoSize,50,AutoSize,50" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="metroTrackBarVol" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelClock" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="panelOsc2" Row="1" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="labelTitle" Row="0" RowSpan="1" Column="4" ColumnSpan="4" /><Control Name="labelStat" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label3" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label4" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="labelCpuLoad" Row="1" RowSpan="1" Column="7" ColumnSpan="1" /><Control Name="panelChDisp" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,50,AutoSize,50,AutoSize,50" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> Fill @@ -2468,7 +2498,7 @@ &FILE - 180, 22 + 125, 22 &Settings... diff --git a/src/mamidimemo/Program.cs b/src/mamidimemo/Program.cs index 1041e22e9b075..92442cf3c6fba 100644 --- a/src/mamidimemo/Program.cs +++ b/src/mamidimemo/Program.cs @@ -33,7 +33,7 @@ public static class Program /// /// /// - public const string FILE_VERSION = "2.5.0.0"; + public const string FILE_VERSION = "2.5.1.0"; public const string FILE_COPYRIGHT = @"Virtual chiptune sound MIDI module ""MAmidiMEmo"" Version {0} Copyright(C) 2019, 2020 Itoken.All rights reserved.";