Skip to content

Commit

Permalink
2.0.3.0 Improved sounds output timing accuracy.
Browse files Browse the repository at this point in the history
        Supported HOLD1 control change message.
  • Loading branch information
110-kenichi committed Aug 8, 2020
1 parent 83e11bd commit d6bcb4f
Show file tree
Hide file tree
Showing 22 changed files with 994 additions and 768 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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? ***

Expand Down Expand Up @@ -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.
Expand Down
18 changes: 13 additions & 5 deletions src/emu/machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ std::string running_machine::describe_context() const
//-------------------------------------------------
// start - initialize the emulated machine
//-------------------------------------------------
void StartMAmidiMEmoMain();

void running_machine::start()
{
Expand All @@ -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<ui_input_manager>(*this);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/emu/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/emu/mamidimemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +32,7 @@ SendMidiSysEventProc sendMidiSysEvent = 0;
CloseApplicationProc closeApplication = 0;
LoadDataProc loadData;
SaveDataProc saveData;
SoundTimerCallbackProc soundTimerCallback;

DWORD WINAPI StartMAmidiMEmoMainThread(LPVOID lpParam)
{
Expand Down Expand Up @@ -101,6 +103,9 @@ void StartMAmidiMEmoMain()
proc = GetProcAddress(hModule, "SaveData");
if (proc != NULL)
saveData = reinterpret_cast<SaveDataProc>(proc);
proc = GetProcAddress(hModule, "SoundTimerCallback");
if (proc != NULL)
soundTimerCallback = reinterpret_cast<SoundTimerCallbackProc>(proc);

// Launch MAmi
proc = GetProcAddress(hModule, "MainWarpper");
Expand Down Expand Up @@ -197,3 +202,8 @@ int SaveData(void** saveBuf)
{
return saveData(saveBuf);
}

void SoundTimerCallback()
{
return soundTimerCallback();
}
10 changes: 9 additions & 1 deletion src/mamidimemo/Gui/FormMain.Designer.cs

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

33 changes: 31 additions & 2 deletions src/mamidimemo/Gui/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public partial class FormMain : Form

private static ListView outputListView;

private static ToolStripStatusLabel statusLabel;

private static StreamWriter logStream;

/// <summary>
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

/// <summary>
///
/// </summary>
/// <param name="log"></param>
public static void SetStatusText(String text)
{
if (statusLabel.IsDisposed)
return;

statusLabel.GetCurrentParent()?.BeginInvoke(new MethodInvoker(() =>
{
if (statusLabel.IsDisposed)
return;
statusLabel.Text = text;
}), null);
}

Expand Down Expand Up @@ -140,6 +167,8 @@ public FormMain()
}
outputListView = listView1;

statusLabel = toolStripStatusLabel1;

//MIDI Event
InstrumentManager_InstrumentChanged(null, null);
InstrumentManager.InstrumentChanged += InstrumentManager_InstrumentChanged;
Expand Down Expand Up @@ -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();
}
}

Expand Down
Loading

0 comments on commit d6bcb4f

Please sign in to comment.