From 014ba0080eebc6c6d5f9d369b345b082940f295c Mon Sep 17 00:00:00 2001
From: itoken <40394569+110-kenichi@users.noreply.github.com>
Date: Sat, 7 Sep 2024 10:55:41 +0900
Subject: [PATCH] 5.7.0.0 Supported \*.mop\* file importing on TimbreManager.
---
README.md | 4 +-
src/VSIF/VGMPlayer/FormMain.cs | 7 +-
src/mamidimemo/Gui/FMEditor/FormFmEditor.cs | 122 +-------------
.../Gui/FMEditor/FormYM2151Editor.cs | 87 ----------
.../Gui/FMEditor/FormYM2413Editor.cs | 11 --
.../Gui/FMEditor/FormYM2414Editor .cs | 11 --
.../Gui/FMEditor/FormYM2608Editor.cs | 87 ----------
.../Gui/FMEditor/FormYM2610BEditor.cs | 87 ----------
.../Gui/FMEditor/FormYM2612Editor.cs | 87 ----------
.../Gui/FMEditor/FormYM3806Editor.cs | 11 --
.../Gui/FMEditor/FormYM3812Editor.cs | 11 --
.../Gui/FMEditor/FormYMF262Editor.cs | 11 --
src/mamidimemo/Gui/FormMain.cs | 7 +-
src/mamidimemo/Gui/FormTimbreManager.cs | 35 ++++
src/mamidimemo/Program.cs | 2 +-
src/mamidimemo/instruments/Chips/YM2151.cs | 142 +++++++++++++++-
src/mamidimemo/instruments/Chips/YM2413.cs | 63 +++++++
src/mamidimemo/instruments/Chips/YM2414.cs | 58 +++++++
src/mamidimemo/instruments/Chips/YM2608.cs | 134 +++++++++++++++
src/mamidimemo/instruments/Chips/YM2610B.cs | 135 +++++++++++++++
src/mamidimemo/instruments/Chips/YM2612.cs | 133 +++++++++++++++
src/mamidimemo/instruments/Chips/YM3806.cs | 58 +++++++
src/mamidimemo/instruments/Chips/YM3812.cs | 59 +++++++
src/mamidimemo/instruments/Chips/YMF262.cs | 59 +++++++
.../instruments/CustomToneImporter.cs | 43 +++++
src/mamidimemo/instruments/FmToneImporter.cs | 159 ++++++++++++++++++
src/mamidimemo/instruments/InstrumentBase.cs | 18 +-
src/mamidimemo/mamidimemo.csproj | 2 +
28 files changed, 1115 insertions(+), 528 deletions(-)
create mode 100644 src/mamidimemo/instruments/CustomToneImporter.cs
create mode 100644 src/mamidimemo/instruments/FmToneImporter.cs
diff --git a/README.md b/README.md
index 7a6befe5df48e..3ca666f39ebc4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-MAmidiMEmo 5.6.17.0 Itoken (c)2019, 2024 / GPL-2.0
+MAmidiMEmo 5.7.0.0 Itoken (c)2019, 2024 / GPL-2.0
*** What is the MAmidiMEmo? ***
@@ -274,6 +274,8 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNQ9JE3JAQMNQ)
*** Changes
+5.7.0.0 Supported \*.mop\* file importing on TimbreManager.
+5.6.18.0 Fixed Multi-Media Keys handling.
5.6.17.0 Fixed Hold Off MIDI message handling.
5.6.16.0 Fixed ch9-18 address calculation for OPL3 for SCCI.
5.6.15.0 Showed the program number name on ProgramNumbers property.
diff --git a/src/VSIF/VGMPlayer/FormMain.cs b/src/VSIF/VGMPlayer/FormMain.cs
index 8adc097234895..35d1ddeaa5bbc 100644
--- a/src/VSIF/VGMPlayer/FormMain.cs
+++ b/src/VSIF/VGMPlayer/FormMain.cs
@@ -108,12 +108,17 @@ protected override void OnShown(EventArgs e)
listViewList.TopItem = lvi;
}
+ private static int GET_APPCOMMAND_LPARAM(IntPtr lParam)
+ {
+ return (int)(lParam.ToInt64() >> 16) & 0xFFF;
+ }
+
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case NativeConstants.WM_APPCOMMAND:
- int cmd = (int)((uint)m.LParam >> 16 & ~0xf000);
+ int cmd = GET_APPCOMMAND_LPARAM(m.LParam);
switch ((ApplicationCommand)cmd)
{
case ApplicationCommand.MediaFastForward:
diff --git a/src/mamidimemo/Gui/FMEditor/FormFmEditor.cs b/src/mamidimemo/Gui/FMEditor/FormFmEditor.cs
index 529db4abad081..e3c406ef34cb1 100644
--- a/src/mamidimemo/Gui/FMEditor/FormFmEditor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormFmEditor.cs
@@ -26,6 +26,7 @@
using zanac.MAmidiMEmo.Util;
using zanac.MAmidiMEmo.Util.FITOM;
using zanac.MAmidiMEmo.Util.Syx;
+using static System.Net.Mime.MediaTypeNames;
using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
@@ -983,84 +984,7 @@ private void updateTimbreNames()
///
public virtual IEnumerable ImportToneFile(string file)
{
- string ext = System.IO.Path.GetExtension(file);
- IEnumerable tones = null;
-
- var exts = ExtensionsFilterExt.Split(new char[] { ';' });
- string mext = System.IO.Path.GetExtension(exts[0]).ToUpper(CultureInfo.InvariantCulture);
- if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(mext))
- {
- try
- {
- string txt = System.IO.File.ReadAllText(file);
- tones = ImportTone(txt);
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- else
- {
- try
- {
- string[] importFile = { file.ToLower(CultureInfo.InvariantCulture) };
- switch (ext.ToUpper(CultureInfo.InvariantCulture))
- {
- case ".MUC":
- tones = Muc.Reader(file);
- break;
- case ".DAT":
- tones = Dat.Reader(file);
- break;
- case ".MWI":
- tones = Fmp.Reader(file);
- break;
- case ".MML":
- tones = Pmd.Reader(file);
- break;
- case ".FXB":
- tones = Vopm.Reader(file);
- break;
- case ".GWI":
- tones = Gwi.Reader(file);
- break;
- case ".BNK":
- tones = BankReader.Read(file);
- break;
- case ".SYX":
- tones = SyxReaderTX81Z.Read(file);
- break;
- case ".FF":
- tones = FF.Reader(file);
- break;
- case ".FFOPM":
- tones = FF.Reader(file);
- break;
- case ".VGI":
- tones = Vgi.Reader(file);
- break;
- default:
-
- break;
- }
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- return tones;
+ return Instrument.CustomToneImporter.ImportToneFile(file);
}
///
@@ -1365,7 +1289,7 @@ protected virtual string ExtensionsFilterExt
{
get
{
- return null;
+ return Instrument.CustomToneImporter.ExtensionsFilterExt;
}
}
@@ -1641,45 +1565,7 @@ private void metroButtonExport_Click(object sender, EventArgs e)
///
protected virtual IEnumerable ImportTone(string txt)
{
- IEnumerable tones = null;
- StringReader rs = new StringReader(txt);
-
- string ftname = rs.ReadLine().ToUpper(CultureInfo.InvariantCulture);
- var exts = ExtensionsFilterExt.Split(new char[] { ';' });
- string fullTypeName = exts[0];
-
- if (fullTypeName.ToUpper(CultureInfo.InvariantCulture).Equals(ftname))
- {
- string ver = rs.ReadLine();
- if (ver != "1.0")
- throw new InvalidDataException();
- int num = int.Parse(rs.ReadLine());
- List lines = new List();
- List ts = new List();
- int progNo = 0;
- while (true)
- {
- string line = rs.ReadLine();
- if (line == null || line == "-")
- {
- if (lines.Count == 0)
- break;
- Tone t = new Tone();
- t.MML = lines.ToArray();
- t.Name = t.MML[0];
- t.Number = progNo++;
- ts.Add(t);
- lines.Clear();
- if (line == null)
- break;
- continue;
- }
- lines.Add(line);
- }
- tones = ts;
- }
-
- return tones;
+ return Instrument.CustomToneImporter.ImportTone(txt);
}
///
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2151Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM2151Editor.cs
index 904f650300749..a38c71a2deff4 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2151Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2151Editor.cs
@@ -211,93 +211,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopm;*.mopn";
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable ImportToneFile(string file)
- {
- IEnumerable tones = base.ImportToneFile(file);
- if (tones != null)
- return tones;
-
- string ext = System.IO.Path.GetExtension(file);
-
- if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPN"))
- {
- try
- {
- string txt = System.IO.File.ReadAllText(file);
- StringReader rs = new StringReader(txt);
-
- string ftname = rs.ReadLine();
- if ("*.mopn" == ftname)
- {
- string ver = rs.ReadLine();
- if (ver != "1.0")
- throw new InvalidDataException();
- int num = int.Parse(rs.ReadLine());
- List lines = new List();
- List ts = new List();
- int progNo = 0;
- while (true)
- {
- string line = rs.ReadLine();
- if (line == null || line == "-")
- {
- if (lines.Count == 0)
- break;
- Tone t = new Tone();
- var mml = lines.ToArray();
-
- var general = mml[1].Split(',');
- mml[1] = String.Format("{0},{1},{2},0,0,,,,,,", general[0], general[1], general[2]);
- for (int i = 2; i < mml.Length; i++)
- {
- var op = mml[i].Split(',');
- mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0,0,-1",
- op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
- }
- t.MML = mml;
-
- t.Name = t.MML[0];
- t.Number = progNo++;
- ts.Add(t);
- lines.Clear();
- if (line == null)
- break;
- continue;
- }
- lines.Add(line);
- }
- tones = ts;
- }
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- return tones;
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2413Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM2413Editor.cs
index ea3c6295f235a..41e4be50854de 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2413Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2413Editor.cs
@@ -209,17 +209,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
((RegisterValue)this["Career"]["DIST"]).Value = tim.Career.DIST;
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.moll";
- }
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2414Editor .cs b/src/mamidimemo/Gui/FMEditor/FormYM2414Editor .cs
index d205d6932c149..ec91de204bb2f 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2414Editor .cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2414Editor .cs
@@ -253,17 +253,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopz";
- }
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2608Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM2608Editor.cs
index a5b90836fdb19..cc63a59673751 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2608Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2608Editor.cs
@@ -199,93 +199,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopn;*.mopm";
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable ImportToneFile(string file)
- {
- IEnumerable tones = base.ImportToneFile(file);
- if (tones != null)
- return tones;
-
- string ext = System.IO.Path.GetExtension(file);
-
- if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
- {
- try
- {
- string txt = System.IO.File.ReadAllText(file);
- StringReader rs = new StringReader(txt);
-
- string ftname = rs.ReadLine();
- if ("*.mopm" == ftname)
- {
- string ver = rs.ReadLine();
- if (ver != "1.0")
- throw new InvalidDataException();
- int num = int.Parse(rs.ReadLine());
- List lines = new List();
- List ts = new List();
- int progNo = 0;
- while (true)
- {
- string line = rs.ReadLine();
- if (line == null || line == "-")
- {
- if (lines.Count == 0)
- break;
- Tone t = new Tone();
- var mml = lines.ToArray();
-
- var general = mml[1].Split(',');
- mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
- for (int i = 2; i < mml.Length; i++)
- {
- var op = mml[i].Split(',');
- mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
- op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
- }
- t.MML = mml;
-
- t.Name = t.MML[0];
- t.Number = progNo++;
- ts.Add(t);
- lines.Clear();
- if (line == null)
- break;
- continue;
- }
- lines.Add(line);
- }
- tones = ts;
- }
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- return tones;
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2610BEditor.cs b/src/mamidimemo/Gui/FMEditor/FormYM2610BEditor.cs
index 1266d607f74b4..ce838cc82f7d3 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2610BEditor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2610BEditor.cs
@@ -199,93 +199,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopn;*.mopm";
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable ImportToneFile(string file)
- {
- IEnumerable tones = base.ImportToneFile(file);
- if (tones != null)
- return tones;
-
- string ext = System.IO.Path.GetExtension(file);
-
- if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
- {
- try
- {
- string txt = System.IO.File.ReadAllText(file);
- StringReader rs = new StringReader(txt);
-
- string ftname = rs.ReadLine();
- if ("*.mopm" == ftname)
- {
- string ver = rs.ReadLine();
- if (ver != "1.0")
- throw new InvalidDataException();
- int num = int.Parse(rs.ReadLine());
- List lines = new List();
- List ts = new List();
- int progNo = 0;
- while (true)
- {
- string line = rs.ReadLine();
- if (line == null || line == "-")
- {
- if (lines.Count == 0)
- break;
- Tone t = new Tone();
- var mml = lines.ToArray();
-
- var general = mml[1].Split(',');
- mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
- for (int i = 2; i < mml.Length; i++)
- {
- var op = mml[i].Split(',');
- mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
- op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
- }
- t.MML = mml;
-
- t.Name = t.MML[0];
- t.Number = progNo++;
- ts.Add(t);
- lines.Clear();
- if (line == null)
- break;
- continue;
- }
- lines.Add(line);
- }
- tones = ts;
- }
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- return tones;
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM2612Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM2612Editor.cs
index dd21ee65634dd..f1bcfd61dd371 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM2612Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM2612Editor.cs
@@ -196,93 +196,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopn;*.mopm";
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable ImportToneFile(string file)
- {
- IEnumerable tones = base.ImportToneFile(file);
- if (tones != null)
- return tones;
-
- string ext = System.IO.Path.GetExtension(file);
-
- if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
- {
- try
- {
- string txt = System.IO.File.ReadAllText(file);
- StringReader rs = new StringReader(txt);
-
- string ftname = rs.ReadLine();
- if ("*.mopm" == ftname)
- {
- string ver = rs.ReadLine();
- if (ver != "1.0")
- throw new InvalidDataException();
- int num = int.Parse(rs.ReadLine());
- List lines = new List();
- List ts = new List();
- int progNo = 0;
- while (true)
- {
- string line = rs.ReadLine();
- if (line == null || line == "-")
- {
- if (lines.Count == 0)
- break;
- Tone t = new Tone();
- var mml = lines.ToArray();
-
- var general = mml[1].Split(',');
- mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
- for (int i = 2; i < mml.Length; i++)
- {
- var op = mml[i].Split(',');
- mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
- op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
- }
- t.MML = mml;
-
- t.Name = t.MML[0];
- t.Number = progNo++;
- ts.Add(t);
- lines.Clear();
- if (line == null)
- break;
- continue;
- }
- lines.Add(line);
- }
- tones = ts;
- }
- }
- catch (Exception ex)
- {
- if (ex.GetType() == typeof(Exception))
- throw;
- else if (ex.GetType() == typeof(SystemException))
- throw;
-
- MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
- }
- }
- return tones;
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM3806Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM3806Editor.cs
index f3c788b84a408..cf30b8537fef4 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM3806Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM3806Editor.cs
@@ -190,17 +190,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopq";
- }
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYM3812Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYM3812Editor.cs
index c67f46aed2395..2642c5ab33435 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYM3812Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYM3812Editor.cs
@@ -369,17 +369,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopl";
- }
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1] };
diff --git a/src/mamidimemo/Gui/FMEditor/FormYMF262Editor.cs b/src/mamidimemo/Gui/FMEditor/FormYMF262Editor.cs
index a029783420be6..33444bfbf8126 100644
--- a/src/mamidimemo/Gui/FMEditor/FormYMF262Editor.cs
+++ b/src/mamidimemo/Gui/FMEditor/FormYMF262Editor.cs
@@ -647,17 +647,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}
- ///
- ///
- ///
- protected override string ExtensionsFilterExt
- {
- get
- {
- return "*.mopl3";
- }
- }
-
protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1], MmlValueOps[2], MmlValueOps[3] };
diff --git a/src/mamidimemo/Gui/FormMain.cs b/src/mamidimemo/Gui/FormMain.cs
index 7150157f8d4c6..394a1c421ce88 100644
--- a/src/mamidimemo/Gui/FormMain.cs
+++ b/src/mamidimemo/Gui/FormMain.cs
@@ -2461,6 +2461,11 @@ internal enum ApplicationCommand
MediaRewind = 50
}
+ private static int GET_APPCOMMAND_LPARAM(IntPtr lParam)
+ {
+ return (int)(lParam.ToInt64() >> 16) & 0xFFF;
+ }
+
protected override void WndProc(ref Message m)
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
@@ -2468,7 +2473,7 @@ protected override void WndProc(ref Message m)
switch (m.Msg)
{
case NativeConstants.WM_APPCOMMAND:
- switch ((ApplicationCommand)(m.LParam.ToInt32() >> 16))
+ switch ((ApplicationCommand)(GET_APPCOMMAND_LPARAM(m.LParam)))
{
case ApplicationCommand.MediaFastForward:
goto default;
diff --git a/src/mamidimemo/Gui/FormTimbreManager.cs b/src/mamidimemo/Gui/FormTimbreManager.cs
index 1ece663728012..e99f5d1977341 100644
--- a/src/mamidimemo/Gui/FormTimbreManager.cs
+++ b/src/mamidimemo/Gui/FormTimbreManager.cs
@@ -3,6 +3,7 @@
using Melanchall.DryWetMidi.Core;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
+using NAudio.SoundFont;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -20,6 +21,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Media.Animation;
+using System.Xml.Linq;
using zanac.MAmidiMEmo.ComponentModel;
using zanac.MAmidiMEmo.Instruments;
using zanac.MAmidiMEmo.Midi;
@@ -144,6 +146,13 @@ public FormTimbreManager(InstrumentBase inst)
texts[i] = texts[i].Replace("*", "");
extList.AddRange(texts);
}
+ if (inst.CustomToneImporter != null)
+ {
+ var texts = inst.CustomToneImporter.ExtensionsFilterExt.Split(';');
+ for (int i = 0; i < texts.Length; i++)
+ texts[i] = texts[i].Replace("*", "");
+ extList.AddRange(texts);
+ }
fileFolderList1.FilterExts = extList.ToArray();
fileFolderList1.FileValidator = new Func((fi) =>
@@ -759,6 +768,32 @@ private void fileFolderList1_SelectedIndexChanged(object sender, ListViewItemSel
}
}
}
+ if (Instrument.CustomToneImporter != null)
+ {
+ var texts = Instrument.CustomToneImporter.ExtensionsFilterExt.Split(';');
+ for (int ei = 0; ei < texts.Length; ei++)
+ {
+ String ext = texts[ei].Replace("*", "");
+ if (Path.GetExtension(file).ToUpper().Equals(ext.ToUpper(CultureInfo.InvariantCulture)))
+ {
+ var tims = Instrument.CustomToneImporter.ImportToneFileAsTimbre(file);
+ if (tims != null)
+ {
+ foreach (var t in tims)
+ {
+ var tim = new TimbreItem(t, no);
+
+ var lvi = new ListViewItem(new string[] { no.ToString(), t.TimbreName, t.Memo });
+ no++;
+ lvi.Tag = tim;
+ listViewFilesTimbres.Items.Add(lvi);
+ }
+ }
+
+ break;
+ }
+ }
+ }
break;
}
}
diff --git a/src/mamidimemo/Program.cs b/src/mamidimemo/Program.cs
index fa5f39b71150a..a2ec97ec01201 100644
--- a/src/mamidimemo/Program.cs
+++ b/src/mamidimemo/Program.cs
@@ -41,7 +41,7 @@ public static class Program
///
///
///
- public const string FILE_VERSION = "5.6.17.0";
+ public const string FILE_VERSION = "5.7.0.0";
public const string FILE_COPYRIGHT = @"Virtual chiptune sound MIDI module ""MAmidiMEmo"" Version {0}
Copyright(C) 2019, 2024 Itoken.All rights reserved.";
diff --git a/src/mamidimemo/instruments/Chips/YM2151.cs b/src/mamidimemo/instruments/Chips/YM2151.cs
index 06594a502d966..bbe72cb98cfaf 100644
--- a/src/mamidimemo/instruments/Chips/YM2151.cs
+++ b/src/mamidimemo/instruments/Chips/YM2151.cs
@@ -3,14 +3,18 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
+using System.Globalization;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
+using System.Windows.Forms;
using FM_SoundConvertor;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.MusicTheory;
+using NAudio.Wave;
using Newtonsoft.Json;
using Omu.ValueInjecter;
using Omu.ValueInjecter.Injections;
@@ -27,6 +31,7 @@
using zanac.MAmidiMEmo.VSIF;
using static zanac.MAmidiMEmo.Instruments.Chips.TMS5220;
using static zanac.MAmidiMEmo.Instruments.Chips.YM2413;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM2612;
//https://www16.atwiki.jp/mxdrv/pages/24.html
//http://map.grauw.nl/resources/sound/yamaha_ym2151_synthesis.pdf
@@ -2895,7 +2900,142 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
}
timbre.TimbreName = tone.Name;
}
- }
+ private YM2151CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2151CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2151CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.mopm;*.mopn";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFile(string file)
+ {
+ IEnumerable tones = base.ImportToneFile(file);
+ if (tones != null)
+ return tones;
+
+ string ext = System.IO.Path.GetExtension(file);
+
+ if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPN"))
+ {
+ try
+ {
+ string txt = System.IO.File.ReadAllText(file);
+ StringReader rs = new StringReader(txt);
+
+ string ftname = rs.ReadLine();
+ if ("*.mopn" == ftname)
+ {
+ string ver = rs.ReadLine();
+ if (ver != "1.0")
+ throw new InvalidDataException();
+ int num = int.Parse(rs.ReadLine());
+ List lines = new List();
+ List ts = new List();
+ int progNo = 0;
+ while (true)
+ {
+ string line = rs.ReadLine();
+ if (line == null || line == "-")
+ {
+ if (lines.Count == 0)
+ break;
+ Tone t = new Tone();
+ var mml = lines.ToArray();
+
+ var general = mml[1].Split(',');
+ mml[1] = String.Format("{0},{1},{2},0,0,,,,,,", general[0], general[1], general[2]);
+ for (int i = 2; i < mml.Length; i++)
+ {
+ var op = mml[i].Split(',');
+ mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0,0,-1",
+ op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
+ }
+ t.MML = mml;
+
+ t.Name = t.MML[0];
+ t.Number = progNo++;
+ ts.Add(t);
+ lines.Clear();
+ if (line == null)
+ break;
+ continue;
+ }
+ lines.Add(line);
+ }
+ tones = ts;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ return tones;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2151Timbre tim = new YM2151Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/mamidimemo/instruments/Chips/YM2413.cs b/src/mamidimemo/instruments/Chips/YM2413.cs
index d071b7e880b68..0d7869cad2c14 100644
--- a/src/mamidimemo/instruments/Chips/YM2413.cs
+++ b/src/mamidimemo/instruments/Chips/YM2413.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
+using System.Globalization;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -30,6 +32,7 @@
using zanac.MAmidiMEmo.VSIF;
using static zanac.MAmidiMEmo.Instruments.Chips.SCC1;
using static zanac.MAmidiMEmo.Instruments.Chips.SPC700;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM2151;
using static zanac.MAmidiMEmo.Instruments.Chips.YM2612;
//http://d4.princess.ne.jp/msx/datas/OPLL/YM2413AP.html#31
@@ -3801,6 +3804,66 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
timbre.TimbreName = tone.Name;
}
+
+
+ private YM2413CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2413CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2413CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.moll";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2413Timbre tim = new YM2413Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
+
}
diff --git a/src/mamidimemo/instruments/Chips/YM2414.cs b/src/mamidimemo/instruments/Chips/YM2414.cs
index 7801b2eb114f9..5a38280f6eeeb 100644
--- a/src/mamidimemo/instruments/Chips/YM2414.cs
+++ b/src/mamidimemo/instruments/Chips/YM2414.cs
@@ -4117,6 +4117,64 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
}
timbre.TimbreName = tone.Name;
}
+
+ private YM2414CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2414CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2414CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.mopz";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2151Timbre tim = new YM2151Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/mamidimemo/instruments/Chips/YM2608.cs b/src/mamidimemo/instruments/Chips/YM2608.cs
index 8e71b8b4e877e..bcd0db9fc7c9b 100644
--- a/src/mamidimemo/instruments/Chips/YM2608.cs
+++ b/src/mamidimemo/instruments/Chips/YM2608.cs
@@ -34,6 +34,8 @@
using Path = System.IO.Path;
using System.Diagnostics;
using static zanac.MAmidiMEmo.Instruments.Chips.RP2A03;
+using System.Globalization;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM2612;
//https://www.quarter-dev.info/archives/yamaha/YM2608_Applicatin_Manual.pdf
@@ -4578,6 +4580,138 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
timbre.TimbreName = tone.Name;
}
+
+ private YM2608CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2608CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2608CustomToneImporter : FmToneImporter
+ {
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get => "*.mopn;*.mopm";
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFile(string file)
+ {
+ IEnumerable tones = base.ImportToneFile(file);
+ if (tones != null)
+ return tones;
+
+ string ext = System.IO.Path.GetExtension(file);
+
+ if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
+ {
+ try
+ {
+ string txt = System.IO.File.ReadAllText(file);
+ StringReader rs = new StringReader(txt);
+
+ string ftname = rs.ReadLine();
+ if ("*.mopm" == ftname)
+ {
+ string ver = rs.ReadLine();
+ if (ver != "1.0")
+ throw new InvalidDataException();
+ int num = int.Parse(rs.ReadLine());
+ List lines = new List();
+ List ts = new List();
+ int progNo = 0;
+ while (true)
+ {
+ string line = rs.ReadLine();
+ if (line == null || line == "-")
+ {
+ if (lines.Count == 0)
+ break;
+ Tone t = new Tone();
+ var mml = lines.ToArray();
+
+ var general = mml[1].Split(',');
+ mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
+ for (int i = 2; i < mml.Length; i++)
+ {
+ var op = mml[i].Split(',');
+ mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
+ op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
+ }
+ t.MML = mml;
+
+ t.Name = t.MML[0];
+ t.Number = progNo++;
+ ts.Add(t);
+ lines.Clear();
+ if (line == null)
+ break;
+ continue;
+ }
+ lines.Add(line);
+ }
+ tones = ts;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ return tones;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2608Timbre tim = new YM2608Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
+
+
///
///
///
diff --git a/src/mamidimemo/instruments/Chips/YM2610B.cs b/src/mamidimemo/instruments/Chips/YM2610B.cs
index 97dc69cbc3dab..e1f9d91cda491 100644
--- a/src/mamidimemo/instruments/Chips/YM2610B.cs
+++ b/src/mamidimemo/instruments/Chips/YM2610B.cs
@@ -4,12 +4,15 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
+using System.Globalization;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Forms;
using FM_SoundConvertor;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
@@ -25,6 +28,7 @@
using zanac.MAmidiMEmo.Midi;
using zanac.MAmidiMEmo.Properties;
using static zanac.MAmidiMEmo.Instruments.Chips.YM2414;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM2608;
//http://www.ajworld.net/neogeodev/ym2610am2.html
//https://wiki.neogeodev.org/index.php?title=YM2610_registers
@@ -3113,5 +3117,136 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
}
timbre.TimbreName = tone.Name;
}
+
+
+ private YM2610BCustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2610BCustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2610BCustomToneImporter : FmToneImporter
+ {
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get => "*.mopn;*.mopm";
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFile(string file)
+ {
+ IEnumerable tones = base.ImportToneFile(file);
+ if (tones != null)
+ return tones;
+
+ string ext = System.IO.Path.GetExtension(file);
+
+ if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
+ {
+ try
+ {
+ string txt = System.IO.File.ReadAllText(file);
+ StringReader rs = new StringReader(txt);
+
+ string ftname = rs.ReadLine();
+ if ("*.mopm" == ftname)
+ {
+ string ver = rs.ReadLine();
+ if (ver != "1.0")
+ throw new InvalidDataException();
+ int num = int.Parse(rs.ReadLine());
+ List lines = new List();
+ List ts = new List();
+ int progNo = 0;
+ while (true)
+ {
+ string line = rs.ReadLine();
+ if (line == null || line == "-")
+ {
+ if (lines.Count == 0)
+ break;
+ Tone t = new Tone();
+ var mml = lines.ToArray();
+
+ var general = mml[1].Split(',');
+ mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
+ for (int i = 2; i < mml.Length; i++)
+ {
+ var op = mml[i].Split(',');
+ mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
+ op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
+ }
+ t.MML = mml;
+
+ t.Name = t.MML[0];
+ t.Number = progNo++;
+ ts.Add(t);
+ lines.Clear();
+ if (line == null)
+ break;
+ continue;
+ }
+ lines.Add(line);
+ }
+ tones = ts;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ return tones;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2610BTimbre tim = new YM2610BTimbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/mamidimemo/instruments/Chips/YM2612.cs b/src/mamidimemo/instruments/Chips/YM2612.cs
index 7311d5c90e0d4..1fd666e6bdcf2 100644
--- a/src/mamidimemo/instruments/Chips/YM2612.cs
+++ b/src/mamidimemo/instruments/Chips/YM2612.cs
@@ -45,6 +45,7 @@
using zanac.MAmidiMEmo.Scci;
using zanac.MAmidiMEmo.Util;
using zanac.MAmidiMEmo.VSIF;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using static zanac.MAmidiMEmo.Instruments.Chips.RP2A03;
using static zanac.MAmidiMEmo.Instruments.Chips.SAM;
@@ -3969,6 +3970,138 @@ public override String SupportedBinExts
}
}
+ private YM2612CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM2612CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM2612CustomToneImporter : FmToneImporter
+ {
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get => "*.mopn;*.mopm";
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFile(string file)
+ {
+ IEnumerable tones = base.ImportToneFile(file);
+ if (tones != null)
+ return tones;
+
+ string ext = System.IO.Path.GetExtension(file);
+
+ if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(".MOPM"))
+ {
+ try
+ {
+ string txt = System.IO.File.ReadAllText(file);
+ StringReader rs = new StringReader(txt);
+
+ string ftname = rs.ReadLine();
+ if ("*.mopm" == ftname)
+ {
+ string ver = rs.ReadLine();
+ if (ver != "1.0")
+ throw new InvalidDataException();
+ int num = int.Parse(rs.ReadLine());
+ List lines = new List();
+ List ts = new List();
+ int progNo = 0;
+ while (true)
+ {
+ string line = rs.ReadLine();
+ if (line == null || line == "-")
+ {
+ if (lines.Count == 0)
+ break;
+ Tone t = new Tone();
+ var mml = lines.ToArray();
+
+ var general = mml[1].Split(',');
+ mml[1] = String.Format("{0},{1},{2},0,0,,", general[0], general[1], general[2]);
+ for (int i = 2; i < mml.Length; i++)
+ {
+ var op = mml[i].Split(',');
+ mml[i] = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},0",
+ op[0], op[1], op[2], op[3], op[4], op[5], op[6], op[7], op[8], op[9], op[10]);
+ }
+ t.MML = mml;
+
+ t.Name = t.MML[0];
+ t.Number = progNo++;
+ ts.Add(t);
+ lines.Clear();
+ if (line == null)
+ break;
+ continue;
+ }
+ lines.Add(line);
+ }
+ tones = ts;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ return tones;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM2612Timbre tim = new YM2612Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+
+ }
+
+
private static DialogResult? previousSampleRateAns;
///
diff --git a/src/mamidimemo/instruments/Chips/YM3806.cs b/src/mamidimemo/instruments/Chips/YM3806.cs
index 5a17578c65e58..fa7a287d95203 100644
--- a/src/mamidimemo/instruments/Chips/YM3806.cs
+++ b/src/mamidimemo/instruments/Chips/YM3806.cs
@@ -2791,6 +2791,64 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
}
timbre.TimbreName = tone.Name;
}
+
+ private YM3806CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM3806CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM3806CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.mopq";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM3806Timbre tim = new YM3806Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3] + "," + t.MML[4] + "," + t.MML[5];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
}
diff --git a/src/mamidimemo/instruments/Chips/YM3812.cs b/src/mamidimemo/instruments/Chips/YM3812.cs
index b98f125f681f7..35d600e53fb9d 100644
--- a/src/mamidimemo/instruments/Chips/YM3812.cs
+++ b/src/mamidimemo/instruments/Chips/YM3812.cs
@@ -27,6 +27,7 @@
using zanac.MAmidiMEmo.Properties;
using zanac.MAmidiMEmo.Scci;
using zanac.MAmidiMEmo.VSIF;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM3806;
//http://www.oplx.com/opl2/docs/adlib_sb.txt
//ftp://ftp.oldskool.org/pub/drivers/Yamaha/yamaha_ym3812.pdf
@@ -1864,5 +1865,63 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
}
timbre.TimbreName = tone.Name;
}
+
+ private YM3812CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YM3812CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YM3812CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.mopl";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM3812Timbre tim = new YM3812Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/mamidimemo/instruments/Chips/YMF262.cs b/src/mamidimemo/instruments/Chips/YMF262.cs
index abac038fa0549..7d9e581bf173f 100644
--- a/src/mamidimemo/instruments/Chips/YMF262.cs
+++ b/src/mamidimemo/instruments/Chips/YMF262.cs
@@ -30,6 +30,7 @@
using FM_SoundConvertor;
using static zanac.MAmidiMEmo.Instruments.Chips.YM3806;
using zanac.MAmidiMEmo.Properties;
+using static zanac.MAmidiMEmo.Instruments.Chips.YM3812;
//http://map.grauw.nl/resources/sound/yamaha_ymf262.pdf
//http://guu.fmp.jp/archives/93#gallery-6
@@ -2623,6 +2624,64 @@ public override void ImportToneFile(TimbreBase timbre, Tone tone)
tim.MDS.PitchShift = tone.PitchShift;
timbre.TimbreName = tone.Name;
}
+
+ private YMF262CustomToneImporter importer;
+
+ ///
+ ///
+ ///
+ public override CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ if (importer == null)
+ {
+ importer = new YMF262CustomToneImporter();
+ }
+ return importer;
+ }
+ }
+
+ ///
+ ///
+ ///
+ private class YMF262CustomToneImporter : FmToneImporter
+ {
+
+ ///
+ ///
+ ///
+ public override string ExtensionsFilterExt
+ {
+ get
+ {
+ return "*.mopl3";
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFileAsTimbre(string file)
+ {
+ IEnumerable tones = ImportToneFile(file);
+ if (tones != null)
+ {
+ List rv = new List();
+ foreach (var t in tones)
+ {
+ YM3812Timbre tim = new YM3812Timbre();
+ tim.TimbreName = t.MML[0];
+ tim.Detailed = t.MML[1] + "," + t.MML[2] + "," + t.MML[3];
+ rv.Add(tim);
+ }
+ return rv;
+ }
+ return null;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/mamidimemo/instruments/CustomToneImporter.cs b/src/mamidimemo/instruments/CustomToneImporter.cs
new file mode 100644
index 0000000000000..607292130f71d
--- /dev/null
+++ b/src/mamidimemo/instruments/CustomToneImporter.cs
@@ -0,0 +1,43 @@
+using FM_SoundConvertor;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace zanac.MAmidiMEmo.Instruments
+{
+ public abstract class CustomToneImporter
+ {
+ ///
+ ///
+ ///
+ public abstract string ExtensionsFilterExt
+ {
+ get;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract IEnumerable ImportTone(string text);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract IEnumerable ImportToneFile(string file);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract IEnumerable ImportToneFileAsTimbre(string file);
+ }
+}
diff --git a/src/mamidimemo/instruments/FmToneImporter.cs b/src/mamidimemo/instruments/FmToneImporter.cs
new file mode 100644
index 0000000000000..29652d1fab80f
--- /dev/null
+++ b/src/mamidimemo/instruments/FmToneImporter.cs
@@ -0,0 +1,159 @@
+using FM_SoundConvertor;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using zanac.MAmidiMEmo.Properties;
+using zanac.MAmidiMEmo.Util.FITOM;
+using zanac.MAmidiMEmo.Util.Syx;
+using static System.Net.Mime.MediaTypeNames;
+
+namespace zanac.MAmidiMEmo.Instruments
+{
+ public abstract class FmToneImporter : CustomToneImporter
+ {
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportToneFile(string file)
+ {
+ string ext = System.IO.Path.GetExtension(file);
+ IEnumerable tones = null;
+
+ var exts = ExtensionsFilterExt.Split(new char[] { ';' });
+ string mext = System.IO.Path.GetExtension(exts[0]).ToUpper(CultureInfo.InvariantCulture);
+ if (ext.ToUpper(CultureInfo.InvariantCulture).Equals(mext))
+ {
+ try
+ {
+ string txt = System.IO.File.ReadAllText(file);
+ tones = ImportTone(txt);
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ else
+ {
+ try
+ {
+ string[] importFile = { file.ToLower(CultureInfo.InvariantCulture) };
+ switch (ext.ToUpper(CultureInfo.InvariantCulture))
+ {
+ case ".MUC":
+ tones = Muc.Reader(file);
+ break;
+ case ".DAT":
+ tones = Dat.Reader(file);
+ break;
+ case ".MWI":
+ tones = Fmp.Reader(file);
+ break;
+ case ".MML":
+ tones = Pmd.Reader(file);
+ break;
+ case ".FXB":
+ tones = Vopm.Reader(file);
+ break;
+ case ".GWI":
+ tones = Gwi.Reader(file);
+ break;
+ case ".BNK":
+ tones = BankReader.Read(file);
+ break;
+ case ".SYX":
+ tones = SyxReaderTX81Z.Read(file);
+ break;
+ case ".FF":
+ tones = FF.Reader(file);
+ break;
+ case ".FFOPM":
+ tones = FF.Reader(file);
+ break;
+ case ".VGI":
+ tones = Vgi.Reader(file);
+ break;
+ default:
+
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.GetType() == typeof(Exception))
+ throw;
+ else if (ex.GetType() == typeof(SystemException))
+ throw;
+
+ MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message);
+ }
+ }
+ return tones;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override IEnumerable ImportTone(String txt)
+ {
+ IEnumerable tones = null;
+ StringReader rs = new StringReader(txt);
+
+ string ftname = rs.ReadLine().ToUpper(CultureInfo.InvariantCulture);
+ var exts = ExtensionsFilterExt.Split(new char[] { ';' });
+ string fullTypeName = exts[0];
+
+ if (fullTypeName.ToUpper(CultureInfo.InvariantCulture).Equals(ftname))
+ {
+ string ver = rs.ReadLine();
+ if (ver != "1.0")
+ throw new InvalidDataException();
+ int num = int.Parse(rs.ReadLine());
+ List lines = new List();
+ List ts = new List();
+ int progNo = 0;
+ while (true)
+ {
+ string line = rs.ReadLine();
+ if (line == null || line == "-")
+ {
+ if (lines.Count == 0)
+ break;
+ Tone t = new Tone();
+ t.MML = lines.ToArray();
+ t.Name = t.MML[0];
+ t.Number = progNo++;
+ ts.Add(t);
+ lines.Clear();
+ if (line == null)
+ break;
+ continue;
+ }
+ lines.Add(line);
+ }
+ tones = ts;
+ }
+
+ return tones;
+ }
+
+
+ }
+}
diff --git a/src/mamidimemo/instruments/InstrumentBase.cs b/src/mamidimemo/instruments/InstrumentBase.cs
index 9468bb65d129f..0aedaae6f4718 100644
--- a/src/mamidimemo/instruments/InstrumentBase.cs
+++ b/src/mamidimemo/instruments/InstrumentBase.cs
@@ -1586,7 +1586,7 @@ public virtual double GetModulationDelaySec(int channel, int offset)
int val = ModulationDelays[channel] + offset;
if (val < 0)
val = 0;
- else if(val > 127)
+ else if (val > 127)
val = 127;
double rate = Math.Pow(((double)val / 64d), 3.25) - 1;
@@ -3204,7 +3204,6 @@ public virtual void ImportToneFile(TimbreBase timbre, Tone tone)
}
-
///
///
///
@@ -3239,6 +3238,21 @@ public virtual void ImportBinFile(TimbreBase timbre, FileInfo binFile)
{
}
+
+ ///
+ ///
+ ///
+ [Browsable(false)]
+ [IgnoreDataMember]
+ [JsonIgnore]
+ public virtual CustomToneImporter CustomToneImporter
+ {
+ get
+ {
+ return null;
+ }
+ }
+
///
/// Helper function to go from IWaveProvider to a SampleProvider
/// Must already be PCM or IEEE float
diff --git a/src/mamidimemo/mamidimemo.csproj b/src/mamidimemo/mamidimemo.csproj
index 105fa8a7a1955..ae5057439c645 100644
--- a/src/mamidimemo/mamidimemo.csproj
+++ b/src/mamidimemo/mamidimemo.csproj
@@ -212,6 +212,8 @@
+
+
Form