From d6bcb4f743d123c124a8607bb4d9be62fcbead12 Mon Sep 17 00:00:00 2001 From: 110-kenichi <110.kenichi@gmail.com> Date: Sun, 9 Aug 2020 02:04:28 +0900 Subject: [PATCH] 2.0.3.0 Improved sounds output timing accuracy. Supported HOLD1 control change message. --- README.md | 4 +- src/emu/machine.cpp | 18 +- src/emu/machine.h | 1 + src/emu/mamidimemo.cpp | 10 + src/mamidimemo/Gui/FormMain.Designer.cs | 10 +- src/mamidimemo/Gui/FormMain.cs | 33 +- src/mamidimemo/Gui/FormMain.resx | 640 ++++++++++-------- src/mamidimemo/Program.cs | 2 +- src/mamidimemo/instruments/Chips/CM32P.cs | 9 + src/mamidimemo/instruments/Chips/MT32.cs | 9 + src/mamidimemo/instruments/Chips/SN76496.cs | 1 + src/mamidimemo/instruments/Chips/YM2151.cs | 145 ++-- src/mamidimemo/instruments/Chips/YM2413.cs | 163 +++-- src/mamidimemo/instruments/Chips/YM2610B.cs | 145 ++-- src/mamidimemo/instruments/Chips/YM2612.cs | 169 ++--- src/mamidimemo/instruments/Chips/YM3812.cs | 146 ++-- .../instruments/HighPrecisionTimer.cs | 152 ++--- src/mamidimemo/instruments/InstrumentBase.cs | 80 ++- src/mamidimemo/instruments/SoundBase.cs | 10 +- .../instruments/SoundManagerBase.cs | 14 +- src/wrapper/wrapper.cpp | Bin 5630 -> 5920 bytes src/wrapper/wrapper.def | 1 + 22 files changed, 994 insertions(+), 768 deletions(-) diff --git a/README.md b/README.md index 77dfb58005e6d..3c4685a89619c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -MAmidiMEmo V2.0.2.0 / Itoken (c)2019, 2020 / GPL-2.0 +MAmidiMEmo V2.0.3.0 / Itoken (c)2019, 2020 / GPL-2.0 *** What is the MAmidiMEmo? *** @@ -224,6 +224,8 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing *** Changes *** +2.0.3.0 Improved sounds output timing accuracy. + Supported HOLD1 control change message. 2.0.2.0 Improved MT-32 sounds output timing & latency. 2.0.1.0 Fixed crashing on some chip... 2.0.0.0 Fixed some minor bugs. diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 0e2f468439ce4..e7284bad33d9d 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -185,6 +185,7 @@ std::string running_machine::describe_context() const //------------------------------------------------- // start - initialize the emulated machine //------------------------------------------------- +void StartMAmidiMEmoMain(); void running_machine::start() { @@ -198,6 +199,11 @@ void running_machine::start() // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); + StartMAmidiMEmoMain(); + + emu_timer* mami_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::mami_timer_callback), this)); + mami_timer->adjust(attotime::from_msec(1), 0, attotime::from_msec(1)); + // initialize UI input m_ui_input = make_unique_clear(*this); @@ -298,10 +304,15 @@ void running_machine::start() //mamidimemo -void StartMAmidiMEmoMain(); - int HasExited(); +void SoundTimerCallback(); + +void running_machine::mami_timer_callback(void *ptr, s32 param) +{ + SoundTimerCallback(); +} + int running_machine::run(bool quiet) { int error = EMU_ERR_NONE; @@ -367,9 +378,6 @@ int running_machine::run(bool quiet) // break out to our async javascript loop and halt emscripten_set_running_machine(this); #endif - - StartMAmidiMEmoMain(); - // run the CPUs until a reset or exit while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != saveload_schedule::NONE) { diff --git a/src/emu/machine.h b/src/emu/machine.h index 205988fbbe6b1..eaeb52437e596 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -295,6 +295,7 @@ class running_machine void set_saveload_filename(std::string &&filename); void handle_saveload(); void soft_reset(void *ptr = nullptr, s32 param = 0); + void mami_timer_callback(void *ptr = nullptr, s32 param = 0); std::string nvram_filename(device_t &device) const; void nvram_load(); void nvram_save(); diff --git a/src/emu/mamidimemo.cpp b/src/emu/mamidimemo.cpp index 1c3fc0946d8ab..049b18631e5bc 100644 --- a/src/emu/mamidimemo.cpp +++ b/src/emu/mamidimemo.cpp @@ -18,6 +18,7 @@ typedef void(CALLBACK* SendMidiSysEventProc)(unsigned char *data, int length); typedef int(CALLBACK* CloseApplicationProc)(); typedef void(CALLBACK* LoadDataProc)(byte* data, int length); typedef int(CALLBACK* SaveDataProc)(void** saveBuf); +typedef void(CALLBACK* SoundTimerCallbackProc)(); InitializeDotNetProc initializeDotNet = 0; HasExitedProc hasExited = 0; @@ -31,6 +32,7 @@ SendMidiSysEventProc sendMidiSysEvent = 0; CloseApplicationProc closeApplication = 0; LoadDataProc loadData; SaveDataProc saveData; +SoundTimerCallbackProc soundTimerCallback; DWORD WINAPI StartMAmidiMEmoMainThread(LPVOID lpParam) { @@ -101,6 +103,9 @@ void StartMAmidiMEmoMain() proc = GetProcAddress(hModule, "SaveData"); if (proc != NULL) saveData = reinterpret_cast(proc); + proc = GetProcAddress(hModule, "SoundTimerCallback"); + if (proc != NULL) + soundTimerCallback = reinterpret_cast(proc); // Launch MAmi proc = GetProcAddress(hModule, "MainWarpper"); @@ -197,3 +202,8 @@ int SaveData(void** saveBuf) { return saveData(saveBuf); } + +void SoundTimerCallback() +{ + return soundTimerCallback(); +} \ No newline at end of file diff --git a/src/mamidimemo/Gui/FormMain.Designer.cs b/src/mamidimemo/Gui/FormMain.Designer.cs index 5a1d9b82ce800..5b4ba89531e5f 100644 --- a/src/mamidimemo/Gui/FormMain.Designer.cs +++ b/src/mamidimemo/Gui/FormMain.Designer.cs @@ -132,6 +132,7 @@ private void InitializeComponent() this.toolStripButton20 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton21 = new System.Windows.Forms.ToolStripButton(); this.multiMediaTimerComponent1 = new zanac.MAmidiMEmo.ComponentModel.MultiMediaTimerComponent(this.components); + this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -724,7 +725,8 @@ private void InitializeComponent() // this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1}); + this.toolStripStatusLabel1, + this.toolStripStatusLabel2}); resources.ApplyResources(this.statusStrip1, "statusStrip1"); this.statusStrip1.Name = "statusStrip1"; // @@ -1080,6 +1082,11 @@ private void InitializeComponent() this.multiMediaTimerComponent1.Interval = ((uint)(1000u)); this.multiMediaTimerComponent1.Resolution = ((uint)(1000u)); // + // toolStripStatusLabel2 + // + this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; + resources.ApplyResources(this.toolStripStatusLabel2, "toolStripStatusLabel2"); + // // FormMain // resources.ApplyResources(this, "$this"); @@ -1214,6 +1221,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton toolStripButton20; private System.Windows.Forms.ToolStripButton toolStripButton21; private System.Windows.Forms.ToolStripMenuItem cloneSelectedChipToolStripMenuItem; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; } } diff --git a/src/mamidimemo/Gui/FormMain.cs b/src/mamidimemo/Gui/FormMain.cs index fefaa7442759d..513b80fa24f85 100644 --- a/src/mamidimemo/Gui/FormMain.cs +++ b/src/mamidimemo/Gui/FormMain.cs @@ -29,6 +29,8 @@ public partial class FormMain : Form private static ListView outputListView; + private static ToolStripStatusLabel statusLabel; + private static StreamWriter logStream; /// @@ -61,6 +63,8 @@ public static void OutputDebugLog(String log) var item = outputListView.Items.Add(log); outputListView.EnsureVisible(item.Index); + if (outputListView.Items.Count > 10000) + outputListView.Items.RemoveAt(0); }), null); } @@ -75,8 +79,31 @@ public static void OutputLog(String log) outputListView?.BeginInvoke(new MethodInvoker(() => { + if (outputListView.IsDisposed) + return; + var item = outputListView.Items.Add(log); outputListView.EnsureVisible(item.Index); + if (outputListView.Items.Count > 10000) + outputListView.Items.RemoveAt(0); + }), null); + } + + /// + /// + /// + /// + public static void SetStatusText(String text) + { + if (statusLabel.IsDisposed) + return; + + statusLabel.GetCurrentParent()?.BeginInvoke(new MethodInvoker(() => + { + if (statusLabel.IsDisposed) + return; + + statusLabel.Text = text; }), null); } @@ -140,6 +167,8 @@ public FormMain() } outputListView = listView1; + statusLabel = toolStripStatusLabel1; + //MIDI Event InstrumentManager_InstrumentChanged(null, null); InstrumentManager.InstrumentChanged += InstrumentManager_InstrumentChanged; @@ -588,14 +617,14 @@ private void toolStripButton1_Click(object sender, EventArgs e) try { - InstrumentManager.ExclusiveLockObject.EnterReadLock(); + InstrumentManager.ExclusiveLockObject.EnterWriteLock(); foreach (var inst in InstrumentManager.GetAllInstruments()) inst.AllSoundOff(); } finally { - InstrumentManager.ExclusiveLockObject.ExitReadLock(); + InstrumentManager.ExclusiveLockObject.ExitWriteLock(); } } diff --git a/src/mamidimemo/Gui/FormMain.resx b/src/mamidimemo/Gui/FormMain.resx index a1491ad45ad64..d7e105a8afcac 100644 --- a/src/mamidimemo/Gui/FormMain.resx +++ b/src/mamidimemo/Gui/FormMain.resx @@ -137,18 +137,6 @@ 463, 17 - - 224, 22 - - - &Reduce selected chip type(s) - - - 224, 22 - - - &Clone selected chip - 225, 48 @@ -244,12 +232,6 @@ 981, 17 - - 226, 22 - - - &Reset to default this property - 227, 26 @@ -289,42 +271,6 @@ False - - None - - - Magenta - - - 23, 17 - - - Categorized sort - - - None - - - Magenta - - - 23, 17 - - - Alphabetical sort - - - None - - - Magenta - - - 23, 17 - - - Popup the selected instruments property - 0, 0 @@ -397,6 +343,156 @@ 0 + + tabPage1 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 0 + + + tabPage3 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 1 + + + tabPage2 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 2 + + + Fill + + + 3, 3 + + + 778, 151 + + + 1 + + + tabControl1 + + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + splitContainer1.Panel2 + + + 0 + + + 3, 3, 3, 3 + + + splitContainer1.Panel2 + + + System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + splitContainer1 + + + 1 + + + 784, 490 + + + 329 + + + 2 + + + splitContainer1 + + + System.Windows.Forms.SplitContainer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 224, 22 + + + &Reduce selected chip type(s) + + + 224, 22 + + + &Clone selected chip + + + 226, 22 + + + &Reset to default this property + + + None + + + Magenta + + + 23, 17 + + + Categorized sort + + + None + + + Magenta + + + 23, 17 + + + Alphabetical sort + + + None + + + Magenta + + + 23, 17 + + + Popup the selected instruments property + 4, 22 @@ -424,6 +520,57 @@ 0 + + 1156, 17 + + + pianoControl1 + + + zanac.MAmidiMEmo.Gui.PianoControl, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + tabPage3 + + + 0 + + + toolStrip2 + + + zanac.MAmidiMEmo.ComponentModel.ToolStripBase, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + tabPage3 + + + 1 + + + 4, 22 + + + 776, 131 + + + 2 + + + Piano + + + tabPage3 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 1 + Fill @@ -457,6 +604,30 @@ False + + 0, 0 + + + 776, 25 + + + 1 + + + toolStrip2 + + + toolStrip2 + + + zanac.MAmidiMEmo.ComponentModel.ToolStripBase, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + tabPage3 + + + 1 + 43, 22 @@ -1321,72 +1492,6 @@ Key Ch - - 0, 0 - - - 776, 25 - - - 1 - - - toolStrip2 - - - toolStrip2 - - - zanac.MAmidiMEmo.ComponentModel.ToolStripBase, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - tabPage3 - - - 1 - - - 4, 22 - - - 776, 131 - - - 2 - - - Piano - - - tabPage3 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl1 - - - 1 - - - Log - - - 522 - - - Fill - - - 3, 3 - - - 770, 125 - - - 0 - listView1 @@ -1414,77 +1519,47 @@ Log - - tabPage2 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl1 - - - 2 - - - Fill - - - 3, 3 - - - 778, 151 - - - 1 - - - tabControl1 - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 0 + + tabPage2 - - 3, 3, 3, 3 + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - splitContainer1.Panel2 + + tabControl1 - - System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 2 - - splitContainer1 + + Fill - - 1 + + 3, 3 - - 784, 490 + + 770, 125 - - 329 + + 0 - - 2 + + listView1 - - splitContainer1 + + System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.SplitContainer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tabPage2 - - $this + + 0 - - 2 + + Log + + + 522 17, 17 @@ -1492,6 +1567,9 @@ 0, 17 + + 0, 17 + 0, 539 @@ -1519,6 +1597,36 @@ 133, 17 + + 0, 0 + + + 784, 24 + + + 0 + + + menuStrip1 + + + menuStrip1 + + + System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + 37, 20 + + + &File + Ctrl+L @@ -1555,29 +1663,17 @@ E&xit - - 37, 20 - - - &File - - - 180, 22 - - - &Settings... - 41, 20 &Tool - - 107, 22 + + 125, 22 - - &About + + &Settings... 44, 20 @@ -1585,29 +1681,11 @@ &Help - - 0, 0 - - - 784, 24 - - - 0 - - - menuStrip1 - - - menuStrip1 - - - System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this + + 107, 22 - - 5 + + &About 618, 17 @@ -1633,6 +1711,30 @@ 248, 17 + + 0, 24 + + + 784, 25 + + + 1 + + + toolStrip1 + + + toolStrip1 + + + zanac.MAmidiMEmo.ComponentModel.ToolStripBase, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + 49, 22 @@ -1642,6 +1744,31 @@ 121, 25 + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABBSURBVDhP3Y1BCgAgEAL9/6eLhYQID65BhwbmOIoXjGUM + B+KRfSAaYfTJQJur11MbFZcWKqQWKqQWKixbxGEAMAHGoDfJT99b8wAAAABJRU5ErkJggg== + + + + None + + + Magenta + + + 137, 22 + + + Extend Instruments + + + 143, 22 + + + &MIDI + 219, 22 @@ -1654,11 +1781,11 @@ Extend CM-32&P(Simulation) - + 143, 22 - - &MIDI + + &PCM 151, 22 @@ -1672,11 +1799,11 @@ Extend &SPC700 - + 143, 22 - - &PCM + + &FM Synthesis 162, 22 @@ -1708,11 +1835,11 @@ Extend YM2&413 - + 143, 22 - - &FM Synthesis + + &WSG 226, 22 @@ -1732,11 +1859,11 @@ Extend &HuC6280 - + 143, 22 - - &WSG + + PS&G 211, 22 @@ -1795,31 +1922,6 @@ False - - 143, 22 - - - PS&G - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABBSURBVDhP3Y1BCgAgEAL9/6eLhYQID65BhwbmOIoXjGUM - B+KRfSAaYfTJQJur11MbFZcWKqQWKqQWKixbxGEAMAHGoDfJT99b8wAAAABJRU5ErkJggg== - - - - None - - - Magenta - - - 137, 22 - - - Extend Instruments - None @@ -1893,30 +1995,6 @@ Start VGM Recording for specific chip - - 0, 24 - - - 784, 25 - - - 1 - - - toolStrip1 - - - toolStrip1 - - - zanac.MAmidiMEmo.ComponentModel.ToolStripBase, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 3 - 17, 56 @@ -4278,6 +4356,12 @@ zanac.MAmidiMEmo.ComponentModel.MultiMediaTimerComponent, MAmidiMEmoUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + toolStripStatusLabel2 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + FormMain diff --git a/src/mamidimemo/Program.cs b/src/mamidimemo/Program.cs index c267438ab12b5..3a0226aa52084 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.0.2.0"; + public const string FILE_VERSION = "2.0.3.0"; public const string FILE_COPYRIGHT = @"Virtual chiptune sound MIDI module ""MAmidiMEmo"" Version {0} Copyright(C) 2019, 2020 Itoken.All rights reserved."; diff --git a/src/mamidimemo/instruments/Chips/CM32P.cs b/src/mamidimemo/instruments/Chips/CM32P.cs index c0b46de1e14e3..3ebf0d1e5350e 100644 --- a/src/mamidimemo/instruments/Chips/CM32P.cs +++ b/src/mamidimemo/instruments/Chips/CM32P.cs @@ -348,6 +348,15 @@ public override byte[] ModulationDepthRangesCent } } + [Browsable(false)] + public override byte[] Holds + { + get + { + return base.Holds; + } + } + [Browsable(false)] public override byte[] Portamentos { diff --git a/src/mamidimemo/instruments/Chips/MT32.cs b/src/mamidimemo/instruments/Chips/MT32.cs index 8a629781bd22e..49f197edf34ac 100644 --- a/src/mamidimemo/instruments/Chips/MT32.cs +++ b/src/mamidimemo/instruments/Chips/MT32.cs @@ -256,6 +256,15 @@ public override byte[] ModulationDepthRangesCent } } + [Browsable(false)] + public override byte[] Holds + { + get + { + return base.Holds; + } + } + [Browsable(false)] public override byte[] Portamentos { diff --git a/src/mamidimemo/instruments/Chips/SN76496.cs b/src/mamidimemo/instruments/Chips/SN76496.cs index b8c6ff921cfe8..84f30206dac6d 100644 --- a/src/mamidimemo/instruments/Chips/SN76496.cs +++ b/src/mamidimemo/instruments/Chips/SN76496.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Drawing.Design; using System.Linq; using System.Reflection; diff --git a/src/mamidimemo/instruments/Chips/YM2151.cs b/src/mamidimemo/instruments/Chips/YM2151.cs index 5fb06d76b0dd5..5e2468efb7d7c 100644 --- a/src/mamidimemo/instruments/Chips/YM2151.cs +++ b/src/mamidimemo/instruments/Chips/YM2151.cs @@ -1075,236 +1075,237 @@ public byte Enable } } - private byte f_DT1 = 4; + private byte f_AR; /// - /// Detune1(0-7) + /// Attack Rate(0-31) /// [DataMember] [Category("Sound")] - [Description("DeTune 1 (1-4-7)")] - [DefaultValue((byte)4)] - [SlideParametersAttribute(1, 7)] + [Description("Attack Rate (0-31)")] + [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DT1 + public byte AR { get { - return f_DT1; + return f_AR; } set { - f_DT1 = (byte)(value & 7); + f_AR = (byte)(value & 31); } } - private byte f_MUL; + private byte f_D1R; /// - /// Multiply(0-15) + /// 1st decay rate(0-31) /// [DataMember] [Category("Sound")] - [Description("Multiply (0-15)")] + [Description("1st Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte MUL + public byte D1R { get { - return f_MUL; + return f_D1R; } set { - f_MUL = (byte)(value & 15); + f_D1R = (byte)(value & 31); } } - private byte f_TL; + private byte f_D2R; /// - /// Total Level(0-127) + /// 2nd decay rate(0-31) /// [DataMember] [Category("Sound")] - [Description("Total Level (0-127)")] + [Description("2nd Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 127)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte TL + public byte D2R { get { - return f_TL; + return f_D2R; } set { - f_TL = (byte)(value & 127); + f_D2R = (byte)(value & 31); } } - private byte f_RS; + private byte f_RR; /// - /// Rate Scaling(0-3) + /// release rate(0-15) /// [DataMember] [Category("Sound")] - [Description("Rate Scaling (0-3)")] + [Description("Release Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 3)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RS + public byte RR { get { - return f_RS; + return f_RR; } set { - f_RS = (byte)(value & 3); + f_RR = (byte)(value & 15); } } - private byte f_AR; + private byte f_SL; /// - /// Attack Rate(0-31) + /// sustain level(0-15) /// [DataMember] [Category("Sound")] - [Description("Attack Rate (0-31)")] + [Description("Sustain Level(0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AR + public byte SL { get { - return f_AR; + return f_SL; } set { - f_AR = (byte)(value & 31); + f_SL = (byte)(value & 15); } } - private byte f_AM; + private byte f_TL; /// - /// AMS Enable (0:Disable 1:Enable) + /// Total Level(0-127) /// [DataMember] [Category("Sound")] - [Description("Amplitude Modulation Sensivity (0-1)")] + [Description("Total Level (0-127)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 127)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AM + public byte TL { get { - return f_AM; + return f_TL; } set { - f_AM = (byte)(value & 1); + f_TL = (byte)(value & 127); } } - private byte f_D1R; + private byte f_RS; /// - /// 1st decay rate(0-31) + /// Rate Scaling(0-3) /// [DataMember] [Category("Sound")] - [Description("1st Decay Rate (0-31)")] + [Description("Rate Scaling (0-3)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 3)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D1R + public byte RS { get { - return f_D1R; + return f_RS; } set { - f_D1R = (byte)(value & 31); + f_RS = (byte)(value & 3); } } - private byte f_D2R; + private byte f_MUL; /// - /// 2nd decay rate(0-31) + /// Multiply(0-15) /// [DataMember] [Category("Sound")] - [Description("2nd Decay Rate (0-31)")] + [Description("Multiply (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D2R + public byte MUL { get { - return f_D2R; + return f_MUL; } set { - f_D2R = (byte)(value & 31); + f_MUL = (byte)(value & 15); } } - private byte f_SL; + private byte f_DT1 = 4; /// - /// sustain level(0-15) + /// Detune1(0-7) /// [DataMember] [Category("Sound")] - [Description("Sustain Level(0-15)")] - [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [Description("DeTune 1 (1-4-7)")] + [DefaultValue((byte)4)] + [SlideParametersAttribute(1, 7)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte SL + public byte DT1 { get { - return f_SL; + return f_DT1; } set { - f_SL = (byte)(value & 15); + f_DT1 = (byte)(value & 7); } } - private byte f_RR; + private byte f_AM; /// - /// release rate(0-15) + /// AMS Enable (0:Disable 1:Enable) /// [DataMember] [Category("Sound")] - [Description("Release Rate (0-15)")] + [Description("Amplitude Modulation Sensivity (0-1)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RR + public byte AM { get { - return f_RR; + return f_AM; } set { - f_RR = (byte)(value & 15); + f_AM = (byte)(value & 1); } } + private byte f_DT2; /// diff --git a/src/mamidimemo/instruments/Chips/YM2413.cs b/src/mamidimemo/instruments/Chips/YM2413.cs index db9afc6f7709e..947c27f019378 100644 --- a/src/mamidimemo/instruments/Chips/YM2413.cs +++ b/src/mamidimemo/instruments/Chips/YM2413.cs @@ -778,7 +778,6 @@ public class YM2413Timbre : TimbreBase { #region FM Symth - private ToneType f_ToneType; [DataMember] @@ -932,119 +931,122 @@ public enum ToneType public class YM2413Operator : ContextBoundObject { - private byte f_AM; + private byte f_AR; /// - /// Apply amplitude modulation(0-1) + /// Attack Rate (0-15) /// [DataMember] [Category("Sound")] - [Description("Apply amplitude modulation (0:Off 1:On)")] - [SlideParametersAttribute(0, 1)] + [Description("Attack Rate (0-15)")] [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AM + public byte AR { get { - return f_AM; + return f_AR; } set { - f_AM = (byte)(value & 1); + f_AR = (byte)(value & 15); } } - private byte f_VIB; + private byte f_DR; /// - /// Apply vibrato(0-1) + /// Decay Rate (0-15) /// [DataMember] [Category("Sound")] - [Description("Vibrato (0:Off 1:On)")] + [Description("Decay Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte VIB + public byte DR { get { - return f_VIB; + return f_DR; } set { - f_VIB = (byte)(value & 1); + f_DR = (byte)(value & 15); } } - private byte f_EG; + private byte f_RR; /// - /// EG Type (0-1) + /// release rate(0-15) /// [DataMember] [Category("Sound")] - [Description("EG Type (0:the sound begins to decay immediately after hitting the SUSTAIN phase 1:the sustain level of the voice is maintained until released")] + [Description("Release Rate (0-15)\r\n" + + "When EG = 0, Used both Sustain Rate & Release Rate")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte EG + public byte RR { get { - return f_EG; + return f_RR; } set { - f_EG = (byte)(value & 1); + f_RR = (byte)(value & 15); } } - private byte f_KSR; + private byte f_SL; /// - /// Keyboard scaling rate (0-1) + /// Sustain Rate (0-15) /// [DataMember] [Category("Sound")] - [Description("Keyboard scaling rate (1: the sound's envelope is foreshortened as it rises in pitch.")] + [Description("Sustain Level (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte KSR + public byte SL { get { - return f_KSR; + return f_SL; } set { - f_KSR = (byte)(value & 1); + f_SL = (byte)(value & 15); } } - - private byte f_MUL; + private byte? f_SR; /// - /// Multiply (0-15) + /// release rate(0-15) /// [DataMember] [Category("Sound")] - [Description("Multiply (0-15)")] - [DefaultValue((byte)0)] + [Description("When EG = 0 and value is set, Used as Sustain Rate (0-15) when KOFF")] + [DefaultValue(null)] [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte MUL + public byte? SR { get { - return f_MUL; + return f_SR; } set { - f_MUL = (byte)(value & 15); + if (value.HasValue) + f_SR = (byte)(value & 15); + else + f_SR = value; } } @@ -1071,146 +1073,141 @@ public byte KSL } } - - private byte f_DIST; + private byte f_KSR; /// - /// Distortion (0:Off 1:On) + /// Keyboard scaling rate (0-1) /// [DataMember] [Category("Sound")] - [Description("Distortion (0:Off 1:On)")] + [Description("Keyboard scaling rate (1: the sound's envelope is foreshortened as it rises in pitch.")] [DefaultValue((byte)0)] [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DIST + public byte KSR { get { - return f_DIST; + return f_KSR; } set { - f_DIST = (byte)(value & 1); + f_KSR = (byte)(value & 1); } } - private byte f_AR; + private byte f_MUL; /// - /// Attack Rate (0-15) + /// Multiply (0-15) /// [DataMember] [Category("Sound")] - [Description("Attack Rate (0-15)")] + [Description("Multiply (0-15)")] [DefaultValue((byte)0)] [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AR + public byte MUL { get { - return f_AR; + return f_MUL; } set { - f_AR = (byte)(value & 15); + f_MUL = (byte)(value & 15); } } - private byte f_DR; + private byte f_AM; /// - /// Decay Rate (0-15) + /// Apply amplitude modulation(0-1) /// [DataMember] [Category("Sound")] - [Description("Decay Rate (0-15)")] + [Description("Apply amplitude modulation (0:Off 1:On)")] + [SlideParametersAttribute(0, 1)] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DR + public byte AM { get { - return f_DR; + return f_AM; } set { - f_DR = (byte)(value & 15); + f_AM = (byte)(value & 1); } } - private byte f_SL; + private byte f_VIB; /// - /// Sustain Rate (0-15) + /// Apply vibrato(0-1) /// [DataMember] [Category("Sound")] - [Description("Sustain Level (0-15)")] + [Description("Vibrato (0:Off 1:On)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte SL + public byte VIB { get { - return f_SL; + return f_VIB; } set { - f_SL = (byte)(value & 15); + f_VIB = (byte)(value & 1); } } - private byte f_RR; + private byte f_EG; /// - /// release rate(0-15) + /// EG Type (0-1) /// [DataMember] [Category("Sound")] - [Description("Release Rate (0-15)\r\n" + - "When EG = 0, Used both Sustain Rate & Release Rate")] + [Description("EG Type (0:the sound begins to decay immediately after hitting the SUSTAIN phase 1:the sustain level of the voice is maintained until released")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RR + public byte EG { get { - return f_RR; + return f_EG; } set { - f_RR = (byte)(value & 15); + f_EG = (byte)(value & 1); } } - private byte? f_SR; + private byte f_DIST; /// - /// release rate(0-15) + /// Distortion (0:Off 1:On) /// [DataMember] [Category("Sound")] - [Description("When EG = 0 and value is set, Used as Sustain Rate (0-15) when KOFF")] - [DefaultValue(null)] - [SlideParametersAttribute(0, 15)] + [Description("Distortion (0:Off 1:On)")] + [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte? SR + public byte DIST { get { - return f_SR; + return f_DIST; } set { - if (value.HasValue) - f_SR = (byte)(value & 15); - else - f_SR = value; + f_DIST = (byte)(value & 1); } } diff --git a/src/mamidimemo/instruments/Chips/YM2610B.cs b/src/mamidimemo/instruments/Chips/YM2610B.cs index a09cc9769bf3f..113f4b71fb865 100644 --- a/src/mamidimemo/instruments/Chips/YM2610B.cs +++ b/src/mamidimemo/instruments/Chips/YM2610B.cs @@ -1813,233 +1813,234 @@ public byte Enable } } - private byte f_DT1 = 4; + private byte f_AR; /// - /// Detune1(0-7) + /// Attack Rate(0-31) /// [DataMember] [Category("Sound(FM)")] - [Description("DeTune 1 (1-4-7)")] - [DefaultValue((byte)4)] - [SlideParametersAttribute(1, 7)] + [Description("Attack Rate (0-31)")] + [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DT1 + public byte AR { get { - return f_DT1; + return f_AR; } set { - f_DT1 = (byte)(value & 7); + f_AR = (byte)(value & 31); } } - private byte f_MUL; + private byte f_D1R; /// - /// Multiply(0-15) + /// 1st decay rate(0-31) /// [DataMember] [Category("Sound(FM)")] - [Description("Multiply (0-15)")] + [Description("1st Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte MUL + public byte D1R { get { - return f_MUL; + return f_D1R; } set { - f_MUL = (byte)(value & 15); + f_D1R = (byte)(value & 31); } } - private byte f_TL; + private byte f_D2R; /// - /// Total Level(0-127) + /// 2nd decay rate(0-31) /// [DataMember] [Category("Sound(FM)")] - [Description("Total Level (0-127)")] + [Description("2nd Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 127)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte TL + public byte D2R { get { - return f_TL; + return f_D2R; } set { - f_TL = (byte)(value & 127); + f_D2R = (byte)(value & 31); } } - private byte f_RS; + private byte f_RR; /// - /// Rate Scaling(0-3) + /// release rate(0-15) /// [DataMember] [Category("Sound(FM)")] - [Description("Rate Scaling (0-3)")] + [Description("Release Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 3)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RS + public byte RR { get { - return f_RS; + return f_RR; } set { - f_RS = (byte)(value & 3); + f_RR = (byte)(value & 15); } } - private byte f_AR; + private byte f_SL; /// - /// Attack Rate(0-31) + /// sustain level(0-15) /// [DataMember] [Category("Sound(FM)")] - [Description("Attack Rate (0-31)")] + [Description("Sustain Level(0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AR + public byte SL { get { - return f_AR; + return f_SL; } set { - f_AR = (byte)(value & 31); + f_SL = (byte)(value & 15); } } - private byte f_AM; + private byte f_TL; /// - /// amplitude modulation sensivity(0-1) + /// Total Level(0-127) /// [DataMember] [Category("Sound(FM)")] - [Description("Amplitude Modulation Sensivity (0-1)")] + [Description("Total Level (0-127)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 127)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AM + public byte TL { get { - return f_AM; + return f_TL; } set { - f_AM = (byte)(value & 1); + f_TL = (byte)(value & 127); } } - private byte f_D1R; + private byte f_RS; /// - /// 1st decay rate(0-31) + /// Rate Scaling(0-3) /// [DataMember] [Category("Sound(FM)")] - [Description("1st Decay Rate (0-31)")] + [Description("Rate Scaling (0-3)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 3)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D1R + public byte RS { get { - return f_D1R; + return f_RS; } set { - f_D1R = (byte)(value & 31); + f_RS = (byte)(value & 3); } } - private byte f_D2R; + private byte f_MUL; /// - /// 2nd decay rate(0-31) + /// Multiply(0-15) /// [DataMember] [Category("Sound(FM)")] - [Description("2nd Decay Rate (0-31)")] + [Description("Multiply (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D2R + public byte MUL { get { - return f_D2R; + return f_MUL; } set { - f_D2R = (byte)(value & 31); + f_MUL = (byte)(value & 15); } } - private byte f_SL; + private byte f_DT1 = 4; /// - /// sustain level(0-15) + /// Detune1(0-7) /// [DataMember] [Category("Sound(FM)")] - [Description("Sustain Level(0-15)")] - [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [Description("DeTune 1 (1-4-7)")] + [DefaultValue((byte)4)] + [SlideParametersAttribute(1, 7)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte SL + public byte DT1 { get { - return f_SL; + return f_DT1; } set { - f_SL = (byte)(value & 15); + f_DT1 = (byte)(value & 7); } } - private byte f_RR; + + private byte f_AM; /// - /// release rate(0-15) + /// amplitude modulation sensivity(0-1) /// [DataMember] [Category("Sound(FM)")] - [Description("Release Rate (0-15)")] + [Description("Amplitude Modulation Sensivity (0-1)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RR + public byte AM { get { - return f_RR; + return f_AM; } set { - f_RR = (byte)(value & 15); + f_AM = (byte)(value & 1); } } diff --git a/src/mamidimemo/instruments/Chips/YM2612.cs b/src/mamidimemo/instruments/Chips/YM2612.cs index c3244a48951c8..8d7eae0ea3f27 100644 --- a/src/mamidimemo/instruments/Chips/YM2612.cs +++ b/src/mamidimemo/instruments/Chips/YM2612.cs @@ -1055,233 +1055,235 @@ public byte Enable } } - private byte f_DT1 = 4; + + private byte f_AR; /// - /// Detune1(0-7) + /// Attack Rate(0-31) /// [DataMember] - [Category("Sound")] - [Description("DeTune 1 (1-4-7)")] - [DefaultValue((byte)4)] - [SlideParametersAttribute(1, 7)] + [Category("Sound(FM)")] + [Description("Attack Rate (0-31)")] + [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DT1 + public byte AR { get { - return f_DT1; + return f_AR; } set { - f_DT1 = (byte)(value & 7); + f_AR = (byte)(value & 31); } } - private byte f_MUL; + private byte f_D1R; /// - /// Multiply(0-15) + /// 1st decay rate(0-31) /// [DataMember] - [Category("Sound")] - [Description("Multiply (0-15)")] + [Category("Sound(FM)")] + [Description("1st Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte MUL + public byte D1R { get { - return f_MUL; + return f_D1R; } set { - f_MUL = (byte)(value & 15); + f_D1R = (byte)(value & 31); } } - private byte f_TL; + private byte f_D2R; /// - /// Total Level(0-127) + /// 2nd decay rate(0-31) /// [DataMember] - [Category("Sound")] - [Description("Total Level (0-127)")] + [Category("Sound(FM)")] + [Description("2nd Decay Rate (0-31)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 127)] + [SlideParametersAttribute(0, 31)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte TL + public byte D2R { get { - return f_TL; + return f_D2R; } set { - f_TL = (byte)(value & 127); + f_D2R = (byte)(value & 31); } } - private byte f_RS; + private byte f_RR; /// - /// Rate Scaling(0-3) + /// release rate(0-15) /// [DataMember] - [Category("Sound")] - [Description("Rate Scaling (0-3)")] + [Category("Sound(FM)")] + [Description("Release Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 3)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RS + public byte RR { get { - return f_RS; + return f_RR; } set { - f_RS = (byte)(value & 3); + f_RR = (byte)(value & 15); } } - private byte f_AR; + private byte f_SL; /// - /// Attack Rate(0-31) + /// sustain level(0-15) /// [DataMember] - [Category("Sound")] - [Description("Attack Rate (0-31)")] + [Category("Sound(FM)")] + [Description("Sustain Level(0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AR + public byte SL { get { - return f_AR; + return f_SL; } set { - f_AR = (byte)(value & 31); + f_SL = (byte)(value & 15); } } - private byte f_AM; + private byte f_TL; /// - /// amplitude modulation sensivity(0-1) + /// Total Level(0-127) /// [DataMember] - [Category("Sound")] - [Description("Amplitude Modulation Sensivity (0-1)")] + [Category("Sound(FM)")] + [Description("Total Level (0-127)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 127)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AM + public byte TL { get { - return f_AM; + return f_TL; } set { - f_AM = (byte)(value & 1); + f_TL = (byte)(value & 127); } } - private byte f_D1R; + private byte f_RS; /// - /// 1st decay rate(0-31) + /// Rate Scaling(0-3) /// [DataMember] - [Category("Sound")] - [Description("1st Decay Rate (0-31)")] + [Category("Sound(FM)")] + [Description("Rate Scaling (0-3)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 3)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D1R + public byte RS { get { - return f_D1R; + return f_RS; } set { - f_D1R = (byte)(value & 31); + f_RS = (byte)(value & 3); } } - private byte f_D2R; + private byte f_MUL; /// - /// 2nd decay rate(0-31) + /// Multiply(0-15) /// [DataMember] - [Category("Sound")] - [Description("2nd Decay Rate (0-31)")] + [Category("Sound(FM)")] + [Description("Multiply (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 31)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte D2R + public byte MUL { get { - return f_D2R; + return f_MUL; } set { - f_D2R = (byte)(value & 31); + f_MUL = (byte)(value & 15); } } - private byte f_SL; + private byte f_DT1 = 4; /// - /// sustain level(0-15) + /// Detune1(0-7) /// [DataMember] - [Category("Sound")] - [Description("Sustain Level(0-15)")] - [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [Category("Sound(FM)")] + [Description("DeTune 1 (1-4-7)")] + [DefaultValue((byte)4)] + [SlideParametersAttribute(1, 7)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte SL + public byte DT1 { get { - return f_SL; + return f_DT1; } set { - f_SL = (byte)(value & 15); + f_DT1 = (byte)(value & 7); } } - private byte f_RR; + + private byte f_AM; /// - /// release rate(0-15) + /// amplitude modulation sensivity(0-1) /// [DataMember] - [Category("Sound")] - [Description("Release Rate (0-15)")] + [Category("Sound(FM)")] + [Description("Amplitude Modulation Sensivity (0-1)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RR + public byte AM { get { - return f_RR; + return f_AM; } set { - f_RR = (byte)(value & 15); + f_AM = (byte)(value & 1); } } @@ -1291,7 +1293,7 @@ public byte RR /// SSG-EG(0-15) /// [DataMember] - [Category("Sound")] + [Category("Sound(FM)")] [Description("SSG-EG (0-15)")] [DefaultValue((byte)0)] [SlideParametersAttribute(0, 15)] @@ -1308,7 +1310,6 @@ public byte SSG_EG } } - #region Etc [DataMember] diff --git a/src/mamidimemo/instruments/Chips/YM3812.cs b/src/mamidimemo/instruments/Chips/YM3812.cs index 5587f9878c859..aaa6992a9b33a 100644 --- a/src/mamidimemo/instruments/Chips/YM3812.cs +++ b/src/mamidimemo/instruments/Chips/YM3812.cs @@ -760,118 +760,118 @@ public override void RestoreFrom(string serializeData) public class YM3812Operator : ContextBoundObject { - private byte f_AM; + private byte f_AR; /// - /// Apply amplitude modulation(0-1) + /// Attack Rate (0-15) /// [DataMember] [Category("Sound")] - [Description("Apply amplitude modulation (0:Off 1:On)")] + [Description("Attack Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AM + public byte AR { get { - return f_AM; + return f_AR; } set { - f_AM = (byte)(value & 1); + f_AR = (byte)(value & 15); } } - private byte f_VR; + private byte f_DR; /// - /// Apply vibrato(0-1) + /// Decay Rate (0-15) /// [DataMember] [Category("Sound")] - [Description("Vibrato (0:Off 1:On)")] + [Description("Decay Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte VR + public byte DR { get { - return f_VR; + return f_DR; } set { - f_VR = (byte)(value & 1); + f_DR = (byte)(value & 15); } } - private byte f_EG; + private byte f_RR; /// - /// EG Type (0-1) + /// release rate(0-15) /// [DataMember] [Category("Sound")] - [Description("EG Type (0:the sound begins to decay immediately after hitting the SUSTAIN phase 1:the sustain level of the voice is maintained until released")] + [Description("Release Rate (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte EG + public byte RR { get { - return f_EG; + return f_RR; } set { - f_EG = (byte)(value & 1); + f_RR = (byte)(value & 15); } } - private byte f_KSR; + private byte f_SL; /// - /// Keyboard scaling rate (0-1) + /// Sustain Level (0-15) /// [DataMember] [Category("Sound")] - [Description("Keyboard scaling rate (1: the sound's envelope is foreshortened as it rises in pitch.")] + [Description("Sustain Level (0-15)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 1)] + [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte KSR + public byte SL { get { - return f_KSR; + return f_SL; } set { - f_KSR = (byte)(value & 1); + f_SL = (byte)(value & 15); } } - private byte f_MFM = 1; + private byte f_TL; /// - /// Modulator Frequency Multiple (0-15) + /// Total Level(0-127) /// [DataMember] [Category("Sound")] - [Description("Modulator Frequency Multiple (0-1-15)")] - [DefaultValue((byte)1)] - [SlideParametersAttribute(0, 15)] + [Description("Total Level (0-63)")] + [DefaultValue((byte)0)] + [SlideParametersAttribute(0, 63)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte MFM + public byte TL { get { - return f_MFM; + return f_TL; } set { - f_MFM = (byte)(value & 15); + f_TL = (byte)(value & 63); } } @@ -898,122 +898,121 @@ public byte KSL } } - private byte f_TL; + private byte f_KSR; /// - /// Total Level(0-127) + /// Keyboard scaling rate (0-1) /// [DataMember] [Category("Sound")] - [Description("Total Level (0-63)")] + [Description("Keyboard scaling rate (1: the sound's envelope is foreshortened as it rises in pitch.")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 63)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte TL + public byte KSR { get { - return f_TL; + return f_KSR; } set { - f_TL = (byte)(value & 63); + f_KSR = (byte)(value & 1); } } - private byte f_AR; + private byte f_MFM = 1; /// - /// Attack Rate (0-15) + /// Modulator Frequency Multiple (0-15) /// [DataMember] [Category("Sound")] - [Description("Attack Rate (0-15)")] - [DefaultValue((byte)0)] + [Description("Modulator Frequency Multiple (0-1-15)")] + [DefaultValue((byte)1)] [SlideParametersAttribute(0, 15)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte AR + public byte MFM { get { - return f_AR; + return f_MFM; } set { - f_AR = (byte)(value & 15); + f_MFM = (byte)(value & 15); } } - - private byte f_DR; + private byte f_AM; /// - /// Decay Rate (0-15) + /// Apply amplitude modulation(0-1) /// [DataMember] [Category("Sound")] - [Description("Decay Rate (0-15)")] + [Description("Apply amplitude modulation (0:Off 1:On)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte DR + public byte AM { get { - return f_DR; + return f_AM; } set { - f_DR = (byte)(value & 15); + f_AM = (byte)(value & 1); } } - private byte f_SL; + private byte f_VR; /// - /// Sustain Level (0-15) + /// Apply vibrato(0-1) /// [DataMember] [Category("Sound")] - [Description("Sustain Level (0-15)")] + [Description("Vibrato (0:Off 1:On)")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte SL + public byte VR { get { - return f_SL; + return f_VR; } set { - f_SL = (byte)(value & 15); + f_VR = (byte)(value & 1); } } - private byte f_RR; + private byte f_EG; /// - /// release rate(0-15) + /// EG Type (0-1) /// [DataMember] [Category("Sound")] - [Description("Release Rate (0-15)")] + [Description("EG Type (0:the sound begins to decay immediately after hitting the SUSTAIN phase 1:the sustain level of the voice is maintained until released")] [DefaultValue((byte)0)] - [SlideParametersAttribute(0, 15)] + [SlideParametersAttribute(0, 1)] [EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))] - public byte RR + public byte EG { get { - return f_RR; + return f_EG; } set { - f_RR = (byte)(value & 15); + f_EG = (byte)(value & 1); } } - + private byte f_WS; /// @@ -1037,7 +1036,6 @@ public byte WS } } - #region Etc [DataMember] diff --git a/src/mamidimemo/instruments/HighPrecisionTimer.cs b/src/mamidimemo/instruments/HighPrecisionTimer.cs index ee305bdb97ca4..8bc215da1dbe2 100644 --- a/src/mamidimemo/instruments/HighPrecisionTimer.cs +++ b/src/mamidimemo/instruments/HighPrecisionTimer.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using zanac.MAmidiMEmo.ComponentModel; +using zanac.MAmidiMEmo.Gui; namespace zanac.MAmidiMEmo.Instruments { @@ -19,26 +20,18 @@ public static class HighPrecisionTimer /// /// Periodic Action Timer Interval[ms] /// - public const uint TIMER_BASIC_INTERVAL = 5; + public const uint TIMER_BASIC_INTERVAL = 1; /// /// Periodic Action Timer Hz /// public const double TIMER_BASIC_HZ = 1000d / TIMER_BASIC_INTERVAL; - private static MultiMediaTimerComponent multiMediaTimerComponent; - - private static Dictionary, object> fixedTimerSounds = new Dictionary, object>(); + private static List periodicTimerSounds = new List(); static HighPrecisionTimer() { Program.ShuttingDown += Program_ShuttingDown; - - multiMediaTimerComponent = new MultiMediaTimerComponent(); - multiMediaTimerComponent.Interval = TIMER_BASIC_INTERVAL; - multiMediaTimerComponent.Resolution = 1; - multiMediaTimerComponent.OnTimer += MultiMediaTimerComponent_OnTimer; - multiMediaTimerComponent.Enabled = true; } /// @@ -47,46 +40,11 @@ static HighPrecisionTimer() /// /// /// - public static void SetPeriodicCallbackAsReader(Func action, double periodMs, object state) + public static void SetPeriodicCallback(Func action, double periodMs, object state) { - long lpSystemTimeAsFileTime; - periodMs = action(state); - GetSystemTimeAsFileTime(out lpSystemTimeAsFileTime); - double nextTime = lpSystemTimeAsFileTime; - //Thread th = new Thread((object obj) => - Action ta = (obj) => - { - using (SafeWaitHandle handle = CreateWaitableTimer(IntPtr.Zero, false, null)) - { - periodMs *= 1000 * 10; - while (true) - { - nextTime += periodMs; - long dueTime = (long)Math.Round(nextTime); - SetWaitableTimer(handle, ref dueTime, 0, IntPtr.Zero, IntPtr.Zero, false); - WaitForSingleObject(handle, WAIT_TIMEOUT); - try - { - InstrumentManager.ExclusiveLockObject.EnterReadLock(); - periodMs = action(obj); - } - finally - { - InstrumentManager.ExclusiveLockObject.ExitReadLock(); - } - if (periodMs < 0 || shutDown) - break; - periodMs *= 1000 * 10; - // Next time is past time? - GetSystemTimeAsFileTime(out lpSystemTimeAsFileTime); - if (lpSystemTimeAsFileTime > nextTime + periodMs) - nextTime = lpSystemTimeAsFileTime; // adjust to current time - } - } - }; - Task.Factory.StartNew(ta, state); - //}) { Priority = ThreadPriority.AboveNormal }; - //th.Start(state); + action(state); + lock (periodicTimerSounds) + periodicTimerSounds.Add(new PeriodicAction(action, periodMs, state)); } private static bool shutDown; @@ -94,7 +52,6 @@ public static void SetPeriodicCallbackAsReader(Func action, doub private static void Program_ShuttingDown(object sender, EventArgs e) { shutDown = true; - multiMediaTimerComponent?.Dispose(); } @@ -102,58 +59,91 @@ private static void Program_ShuttingDown(object sender, EventArgs e) /// /// /// - public static void SetFixedPeriodicCallbackAsReader(Func action, object state) + public static void SetFixedPeriodicCallback(Func action, object state) { action(state); - lock (fixedTimerSounds) - fixedTimerSounds.Add(action, state); + lock (periodicTimerSounds) + periodicTimerSounds.Add(new PeriodicAction(action, TIMER_BASIC_INTERVAL, state)); } - /// /// /// - /// - private static void MultiMediaTimerComponent_OnTimer(object sender) + public static void SoundTimerCallback() { - List, object>> list = null; - lock (fixedTimerSounds) - list = fixedTimerSounds.ToList(); - Parallel.ForEach(list, (snd) => + if (shutDown) + return; + + List plist = null; + lock (periodicTimerSounds) + plist = new List(periodicTimerSounds); + foreach (var snd in plist) { + snd.CurrentPeriodMs -= TIMER_BASIC_INTERVAL; + if (snd.CurrentPeriodMs > 0) + continue; + double ret = -1; try { - InstrumentManager.ExclusiveLockObject.EnterReadLock(); - - ret = snd.Key(snd.Value); + InstrumentManager.ExclusiveLockObject.EnterWriteLock(); + //process action + ret = snd.Action(snd.State); } finally { - InstrumentManager.ExclusiveLockObject.ExitReadLock(); + InstrumentManager.ExclusiveLockObject.ExitWriteLock(); } - if (ret >= 0) - return; - lock (fixedTimerSounds) - fixedTimerSounds.Remove(snd.Key); - }); + if (ret < 0) + { + //end action + lock (periodicTimerSounds) + periodicTimerSounds.Remove(snd); + } + else + { + //continue action + snd.CurrentPeriodMs = ret; + } + } } + /// + /// + /// + private class PeriodicAction + { + public Func Action + { + get; + private set; + } - [DllImport("kernel32.dll")] - public static extern SafeWaitHandle CreateWaitableTimer(IntPtr lpTimerAttributes, bool bManualReset, string lpTimerName); - - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetWaitableTimer(SafeWaitHandle hTimer, - [In] ref long pDueTime, int lPeriod, - IntPtr pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, bool fResume); + public double CurrentPeriodMs + { + get; + set; + } - [DllImport("kernel32.dll")] - internal static extern uint WaitForSingleObject(SafeWaitHandle hHandle, uint dwMilliseconds); + public object State + { + get; + private set; + } + + /// + /// + /// + /// + /// + public PeriodicAction(Func action, double periodMs, object state) + { + Action = action; + CurrentPeriodMs = periodMs; + State = state; + } + } - [DllImport("kernel32.dll")] - public static extern void GetSystemTimeAsFileTime(out long lpSystemTimeAsFileTime); } } diff --git a/src/mamidimemo/instruments/InstrumentBase.cs b/src/mamidimemo/instruments/InstrumentBase.cs index 75754c7188a11..761a756913eff 100644 --- a/src/mamidimemo/instruments/InstrumentBase.cs +++ b/src/mamidimemo/instruments/InstrumentBase.cs @@ -301,7 +301,7 @@ public string SerializeData jo["UnitNumber"] = UnitNumber; RestoreFrom(jo.ToString()); - if(!Program.IsVSTiMode()) + if (!Program.IsVSTiMode()) serializeVstFx(); set_device_enable(UnitNumber, SoundInterfaceTagNamePrefix, 1); } @@ -1078,6 +1078,44 @@ public void ResetModulationDepthRangesCent() ModulationDepthRangesCent[i] = 64; } + [DataMember] + [Category("MIDI")] + [Description("Holds (0:Off 64:On) ")] + [TypeConverter(typeof(MaskableExpandableMidiChCollectionConverter))] + [Mask(127)] + [CollectionDefaultValue((byte)0)] + public virtual byte[] Holds + { + get; + set; + } + + /// + /// + /// + [Browsable(false)] + public virtual byte[] LastHolds + { + get; + set; + } + + public bool ShouldSerializeHolds() + { + foreach (var dt in Holds) + { + if (dt != 0) + return true; + } + return false; + } + + public void ResetHolds() + { + for (int i = 0; i < Holds.Length; i++) + Holds[i] = 0; + } + [DataMember] [Category("MIDI")] @@ -1513,7 +1551,7 @@ public InstrumentBase(uint unitNumber) vstHandle = GCHandle.Alloc(this); - if(!Program.IsVSTiMode()) + if (!Program.IsVSTiMode()) initVstPlugins(); CombinedTimbres = new CombinedTimbre[MAX_TIMBRES]; @@ -1669,6 +1707,18 @@ public InstrumentBase(uint unitNumber) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + Holds = new byte[] { + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, 0}; + LastHolds = new byte[] { + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, 0}; GPCS = new GeneralPurposeControlSettings[]{ new GeneralPurposeControlSettings(), new GeneralPurposeControlSettings(), @@ -1789,8 +1839,11 @@ public virtual void Dispose() protected static void DeferredWriteData(Delegate delg, params object[] args) { lock (deferredWriteData) + { deferredWriteData.Add((delg, args)); - + if (deferredWriteData.Count != 1) + return; + } void act() { try @@ -1814,8 +1867,14 @@ void act() /// /// /// - protected static void FlushDeferredWriteData() + public static void FlushDeferredWriteData() { + lock (deferredWriteData) + { + if (deferredWriteData.Count == 0) + return; + } + try { Program.SoundUpdating(); @@ -1823,6 +1882,7 @@ protected static void FlushDeferredWriteData() { foreach (var (d, a) in deferredWriteData) d.DynamicInvoke(a); + deferredWriteData.Clear(); } } finally @@ -1878,7 +1938,7 @@ protected virtual void OnMidiEvent(MidiEvent midiEvent) { if (non.Velocity == 0) { - if (ChannelTypes[non.Channel] != ChannelType.Drum) + if (ChannelTypes[non.Channel] != ChannelType.Drum && Holds[ce.Channel] < 64) OnNoteOffEvent(new NoteOffEvent(non.NoteNumber, (SevenBitNumber)0) { Channel = non.Channel, DeltaTime = non.DeltaTime }); } else @@ -1894,7 +1954,7 @@ protected virtual void OnMidiEvent(MidiEvent midiEvent) { if (tnon.Velocity == 0) { - if (ChannelTypes[tnon.Channel] != ChannelType.Drum) + if (ChannelTypes[tnon.Channel] != ChannelType.Drum && Holds[ce.Channel] < 64) OnNoteOffEvent(new NoteOffEvent(tnon.NoteNumber, (SevenBitNumber)0) { Channel = tnon.Channel, DeltaTime = tnon.DeltaTime }); } else @@ -1910,7 +1970,7 @@ protected virtual void OnMidiEvent(MidiEvent midiEvent) } case NoteOffEvent noff: { - if (ChannelTypes[noff.Channel] != ChannelType.Drum) + if (ChannelTypes[noff.Channel] != ChannelType.Drum && Holds[ce.Channel] < 64) OnNoteOffEvent(noff); break; } @@ -2010,6 +2070,10 @@ protected virtual void OnControlChangeEvent(ControlChangeEvent midiEvent) case 11: //Expression Expressions[midiEvent.Channel] = midiEvent.ControlValue; break; + case 64: //Holds + LastHolds[midiEvent.Channel] = Holds[midiEvent.Channel]; + Holds[midiEvent.Channel] = midiEvent.ControlValue; + break; case 65: //Portamento Portamentos[midiEvent.Channel] = midiEvent.ControlValue; break; @@ -2068,6 +2132,8 @@ protected virtual void OnControlChangeEvent(ControlChangeEvent midiEvent) Expressions[i] = 127; PitchBendRanges[i] = 2; Pitchs[i] = 8192; + Holds[i] = 0; + LastHolds[i] = 0; Modulations[i] = 0; ModulationRates[i] = 64; ModulationDepthes[i] = 64; diff --git a/src/mamidimemo/instruments/SoundBase.cs b/src/mamidimemo/instruments/SoundBase.cs index a4374b1933ff0..2e15cf331e8b9 100644 --- a/src/mamidimemo/instruments/SoundBase.cs +++ b/src/mamidimemo/instruments/SoundBase.cs @@ -152,7 +152,7 @@ public virtual void KeyOn() if (ParentModule.ChannelTypes[NoteOnEvent.Channel] == ChannelType.Drum) { gateTime = ParentModule.DrumTimbres[NoteOnEvent.NoteNumber].GateTime; - HighPrecisionTimer.SetFixedPeriodicCallbackAsReader(new Func(processGateTime), null); + HighPrecisionTimer.SetFixedPeriodicCallback(new Func(processGateTime), null); } } @@ -520,7 +520,7 @@ public bool ModulationEnabled f_modulationEnabled = value; } if (f_modulationEnabled) - HighPrecisionTimer.SetFixedPeriodicCallbackAsReader(new Func(processModulation), null); + HighPrecisionTimer.SetFixedPeriodicCallback(new Func(processModulation), null); //HighPrecisionTimer.SetPeriodicCallback(new Func(processModulation), HighPrecisionTimer.TIMER_BASIC_INTERVAL, null); } } @@ -556,7 +556,7 @@ public bool PortamentoEnabled f_portamentoEnabled = value; if (f_portamentoEnabled) - HighPrecisionTimer.SetFixedPeriodicCallbackAsReader(new Func(processPortamento), null); + HighPrecisionTimer.SetFixedPeriodicCallback(new Func(processPortamento), null); //HighPrecisionTimer.SetPeriodicCallback(new Func(processPortamento), HighPrecisionTimer.TIMER_BASIC_INTERVAL, null); } } @@ -582,7 +582,7 @@ public bool EnableADSR f_AdsrEnabled = value; if (f_AdsrEnabled) - HighPrecisionTimer.SetFixedPeriodicCallbackAsReader(new Func(processAdsr), null); + HighPrecisionTimer.SetFixedPeriodicCallback(new Func(processAdsr), null); //HighPrecisionTimer.SetPeriodicCallback(new Func(processAdsr), HighPrecisionTimer.TIMER_BASIC_INTERVAL, null); } } @@ -611,7 +611,7 @@ public bool EnableFx if (efs != null) { FxEngine = efs.CreateEngine(); - HighPrecisionTimer.SetPeriodicCallbackAsReader(new Func(processFx), efs.EnvelopeInterval, null); + HighPrecisionTimer.SetPeriodicCallback(new Func(processFx), efs.EnvelopeInterval, null); } } } diff --git a/src/mamidimemo/instruments/SoundManagerBase.cs b/src/mamidimemo/instruments/SoundManagerBase.cs index 2c67e5ca6a289..1e3f33faeaced 100644 --- a/src/mamidimemo/instruments/SoundManagerBase.cs +++ b/src/mamidimemo/instruments/SoundManagerBase.cs @@ -184,6 +184,16 @@ public virtual void ControlChange(ControlChangeEvent midiEvent) ProcessGPCS(midiEvent, no); } break; + case 64: //Holds + if (parentModule.Holds[midiEvent.Channel] < 64 && parentModule.LastHolds[midiEvent.Channel] >= 64) + { + foreach (var snd in AllSounds) + { + if (snd.NoteOnEvent.Channel == midiEvent.Channel) + KeyOff(new NoteOffEvent(snd.NoteOnEvent.NoteNumber, (SevenBitNumber)0) { Channel = snd.NoteOnEvent.Channel }); + } + } + break; //GPCS case 80: case 81: @@ -706,7 +716,7 @@ private bool preProcessArrpegioForKeyOn(TaggedNoteOnEvent note) if (arp.ArpAction == null) { arp.ArpAction = new Func(processArpeggiatorsForKeyOn); - HighPrecisionTimer.SetPeriodicCallbackAsReader(arp.ArpAction, arp.Step, arp); + HighPrecisionTimer.SetPeriodicCallback(arp.ArpAction, arp.Step, arp); } return true; } @@ -765,7 +775,7 @@ private void postProcessArrpegioForKeyOn(TaggedNoteOnEvent note, SoundBase[] snd if (arp.ArpAction == null) { arp.ArpAction = new Func(processArpeggiatorsForPitch); - HighPrecisionTimer.SetPeriodicCallbackAsReader(arp.ArpAction, arp.Step, arp); + HighPrecisionTimer.SetPeriodicCallback(arp.ArpAction, arp.Step, arp); } } } diff --git a/src/wrapper/wrapper.cpp b/src/wrapper/wrapper.cpp index 1d838ee2271b007b8e99f82005ef8e471e82a1ad..6ea06b4724e1c8b46a1e23db2a33c48487168507 100644 GIT binary patch delta 173 zcmeyTy+Cin7tzTL++mU-44DkM45q@K*~JW2Kkif1z91Jxr;1gQ%Kij@LIQ;@{bY+}%0&}6V? T;AP-q;AE%;(-4xE87Kq*