Skip to content

Commit

Permalink
5.7.0.0 Supported \*.mop\* file importing on TimbreManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
110-kenichi committed Sep 7, 2024
1 parent cb0774a commit 014ba00
Show file tree
Hide file tree
Showing 28 changed files with 1,115 additions and 528 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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? ***

Expand Down Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion src/VSIF/VGMPlayer/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
122 changes: 4 additions & 118 deletions src/mamidimemo/Gui/FMEditor/FormFmEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -983,84 +984,7 @@ private void updateTimbreNames()
/// <returns></returns>
public virtual IEnumerable<Tone> ImportToneFile(string file)
{
string ext = System.IO.Path.GetExtension(file);
IEnumerable<Tone> 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);
}

/// <summary>
Expand Down Expand Up @@ -1365,7 +1289,7 @@ protected virtual string ExtensionsFilterExt
{
get
{
return null;
return Instrument.CustomToneImporter.ExtensionsFilterExt;
}
}

Expand Down Expand Up @@ -1641,45 +1565,7 @@ private void metroButtonExport_Click(object sender, EventArgs e)
/// <exception cref="InvalidDataException"></exception>
protected virtual IEnumerable<Tone> ImportTone(string txt)
{
IEnumerable<Tone> 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<string> lines = new List<string>();
List<Tone> ts = new List<Tone>();
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);
}

/// <summary>
Expand Down
87 changes: 0 additions & 87 deletions src/mamidimemo/Gui/FMEditor/FormYM2151Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,93 +211,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}

/// <summary>
///
/// </summary>
protected override string ExtensionsFilterExt
{
get
{
return "*.mopm;*.mopn";
}
}

/// <summary>
///
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public override IEnumerable<Tone> ImportToneFile(string file)
{
IEnumerable<Tone> 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<string> lines = new List<string>();
List<Tone> ts = new List<Tone>();
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] };
Expand Down
11 changes: 0 additions & 11 deletions src/mamidimemo/Gui/FMEditor/FormYM2413Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
((RegisterValue)this["Career"]["DIST"]).Value = tim.Career.DIST;
}

/// <summary>
///
/// </summary>
protected override string ExtensionsFilterExt
{
get
{
return "*.moll";
}
}

protected override string[] GetMMlValues()
{
return new string[] { Timbre.TimbreName, MmlValueGeneral, MmlValueOps[0], MmlValueOps[1] };
Expand Down
11 changes: 0 additions & 11 deletions src/mamidimemo/Gui/FMEditor/FormYM2414Editor .cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,6 @@ protected override void ApplyTimbre(TimbreBase timbre)
}
}

/// <summary>
///
/// </summary>
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] };
Expand Down
Loading

0 comments on commit 014ba00

Please sign in to comment.