Skip to content

Commit

Permalink
Asynchronous preset loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeoliphant committed Sep 23, 2024
1 parent 7c697ac commit 52aafff
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dependencies/stompbox
1 change: 1 addition & 0 deletions StompboxShared/Interface/DAWInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration.Internal;
using System.Threading;
using System.Threading.Tasks;
using UILayout;
Expand Down
41 changes: 38 additions & 3 deletions StompboxShared/StompboxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;

#if !STOMPBOXREMOTE
using UnmanagedPlugins;
#endif
Expand Down Expand Up @@ -31,7 +32,6 @@ public unsafe class StompboxClient
public double BPM { get; set; }
public bool SuppressCommandUpdates { get; set; }
public bool InClientMode { get; }
public bool NeedUIReload { get; set; }
public bool AllowMidiMapping { get; set; }
public PluginFactory PluginFactory { get; set; }
public string PluginPath { get; set; }
Expand Down Expand Up @@ -110,17 +110,51 @@ public int CurrentPresetIndex
{
SendCommand("LoadPreset " + PresetNames[currentPresetIndex]);

UpdateProgram();
if (!InClientMode)
{
needPresetLoad = true;
}
}
}
}
}

public bool NeedUIReload
{
get
{
if (needUIReload)
{
return true;
}

#if !STOMPBOXREMOTE
if (needPresetLoad && !processorWrapper.IsPresetLoading())
{
UpdateProgram();

needPresetLoad = false;

return true;
}
#endif

return false;
}

set
{
needUIReload = value;
}
}

Dictionary<string, string> slotPlugins = new Dictionary<string, string>();

int currentPresetIndex;
NetworkClient networkClient;
ProtocolClient protocolClient;
bool needUIReload = false;
bool needPresetLoad = false;

#if !STOMPBOXREMOTE
PluginProcessorWrapper processorWrapper;
Expand Down Expand Up @@ -226,7 +260,6 @@ void ConnectCallback(bool result)
}
}


public void UpdatePresets()
{
#if STOMPBOXREMOTE
Expand All @@ -242,6 +275,8 @@ public void UpdatePresets()

public void UpdateProgram()
{
needPresetLoad = false;

UpdatePresets();

if (!InClientMode)
Expand Down
5 changes: 5 additions & 0 deletions UnmanagedBridge/PluginWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ namespace UnmanagedPlugins
processor->SetBPM(bpm);
}

bool IsPresetLoading()
{
return processor->IsPresetLoading();
}

System::String^ GetDataPath()
{
return gcnew System::String(processor->GetDataPath().c_str());
Expand Down

0 comments on commit 52aafff

Please sign in to comment.