Skip to content

Commit

Permalink
Improved MIDI file Player UI.
Browse files Browse the repository at this point in the history
Fixed MML Serializer can not deserialize "," separator.
  • Loading branch information
110-kenichi committed Nov 7, 2020
1 parent e79105f commit 6ebf3f5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
7 changes: 6 additions & 1 deletion src/mamidimemo/Gui/FMEditor/RegisterContainerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using zanac.MAmidiMEmo.Instruments;
using zanac.MAmidiMEmo.ComponentModel;
using System.Reflection;
using System.Collections;

namespace zanac.MAmidiMEmo.Gui.FMEditor
{
Expand Down Expand Up @@ -206,7 +207,11 @@ public static void DeserializeProps<T>(T obj, string serializeData, params strin
try
{
serializeData = serializeData.Replace("\r", "").Replace("\n", "");
var vals = serializeData.Split(new char[] { ',', ' ', '\t' }).GetEnumerator();
IEnumerator vals = null;
if (serializeData.Contains(','))
vals = serializeData.Split(new char[] { ',' }).GetEnumerator();
else
vals = serializeData.Split(new char[] { ' ', '\t' }).GetEnumerator();
foreach (string m in props)
{
if (!vals.MoveNext())
Expand Down
17 changes: 9 additions & 8 deletions src/mamidimemo/Gui/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/mamidimemo/Gui/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,12 +1407,18 @@ private void MidiManager_MidiEventReceived(object sender, MidiEvent e)
{
if (e.EventType == MidiEventType.NoteOn)
{
NoteOnEvent noe = (NoteOnEvent)e;
if (noe.Velocity != 0)
NoteOnEvent noe = e as NoteOnEvent;
if (noe != null && noe.Velocity != 0)
{
lock (chNoteOnData)
chNoteOnData[noe.Channel] = noe.Velocity;
}
TaggedNoteOnEvent tnoe = e as TaggedNoteOnEvent;
if (tnoe != null && tnoe.Velocity != 0)
{
lock (chNoteOnData)
chNoteOnData[tnoe.Channel] = tnoe.Velocity;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/mamidimemo/instruments/Chips/YM2612.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ public string MmlSerializeData
set
{
SimpleSerializer.DeserializeProps(this, value,
nameof(ALG),

nameof(ALG),
nameof(FB),

"Ops[0].AR",
Expand Down
9 changes: 7 additions & 2 deletions src/mamidimemo/instruments/SimpleSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// copyright-holders:K.Ito
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -29,7 +30,7 @@ public static string SerializeProps<T>(T obj, params string[] props)
sb.Append(",");
var f = getPropertyInfo(obj, m);
var val = f.Property.GetValue(f.Owner);
if(val != null)
if (val != null)
sb.Append(val.ToString());
}
}
Expand Down Expand Up @@ -58,7 +59,11 @@ public static void DeserializeProps<T>(T obj, string serializeData, params strin
try
{
serializeData = serializeData.Replace("\r", "").Replace("\n", "");
var vals = serializeData.Split(new char[] { ',', ' ', '\t' }).GetEnumerator();
IEnumerator vals = null;
if (serializeData.Contains(','))
vals = serializeData.Split(new char[] { ',' }).GetEnumerator();
else
vals = serializeData.Split(new char[] { ' ', '\t' }).GetEnumerator();
foreach (string m in props)
{
if (!vals.MoveNext())
Expand Down

0 comments on commit 6ebf3f5

Please sign in to comment.