Skip to content

Commit

Permalink
Close selected plugin in mobile interface on preset change if it isn'…
Browse files Browse the repository at this point in the history
…t in the new preset.
  • Loading branch information
mikeoliphant committed Jul 13, 2024
1 parent 7085da9 commit 579a0b1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions StompboxShared/Interface/DAWInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public void UpdateUI()

topUIStack.Children.Add(new GainPluginInterface(StompboxClient.Instance.MasterVolume));

tunerWrapper.Child = new TunerInterface(StompboxClient.Instance.PluginFactory.CreatePlugin("Tuner"));
audioFilePlayerWrapper.Child = new AudioFilePlayerInterface(StompboxClient.Instance.PluginFactory.CreatePlugin("AudioFilePlayer"));
tunerWrapper.Child = new TunerInterface(StompboxClient.Instance.Tuner);
audioFilePlayerWrapper.Child = new AudioFilePlayerInterface(StompboxClient.Instance.AudioPlayer);

inputChainDisplay.SetChain(StompboxClient.Instance.InputPlugins);
fxLoopDisplay.SetChain(StompboxClient.Instance.FxLoopPlugins);
Expand Down
17 changes: 13 additions & 4 deletions StompboxShared/Interface/MobileInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using UILayout;
Expand All @@ -15,6 +16,7 @@ public class MobileInterface : Dock
PluginChainDisplay outputChainDisplay;

Dock selectedPluginDock;
PluginInterface currentSelectedPlugin;
UIElementWrapper selectedPluginWrapper;

HorizontalStack topUIStack;
Expand All @@ -23,8 +25,6 @@ public class MobileInterface : Dock
EnumInterface currentProgramInterface;
TextToggleButton midiToggleButton;
StringBuilderTextBlock dspLoadText;
UIElementWrapper tunerWrapper;
UIElementWrapper audioFilePlayerWrapper;

public MobileInterface()
{
Expand Down Expand Up @@ -116,15 +116,15 @@ public MobileInterface()
{
ClickAction = delegate
{
SetSelectedPlugin(new TunerInterface(StompboxClient.Instance.PluginFactory.CreatePlugin("Tuner")));
SetSelectedPlugin(new TunerInterface(StompboxClient.Instance.Tuner));
}
});

buttonStack.Children.Add(new TextButton("Player")
{
ClickAction = delegate
{
SetSelectedPlugin(new AudioFilePlayerInterface(StompboxClient.Instance.PluginFactory.CreatePlugin("AudioFilePlayer")));
SetSelectedPlugin(new AudioFilePlayerInterface(StompboxClient.Instance.AudioPlayer));
}
});

Expand Down Expand Up @@ -264,6 +264,14 @@ public void UpdateUI()
currentProgramInterface.SetEnumValues(StompboxClient.Instance.PresetNames);
currentProgramInterface.SetSelectedIndex(StompboxClient.Instance.CurrentPresetIndex);

if (currentSelectedPlugin != null)
{
if (!StompboxClient.Instance.AllActivePlugins.Where(p => (p.ID == currentSelectedPlugin.Plugin.ID)).Any())
{
SetSelectedPlugin(null);
}
}

UpdateContentLayout();
}

Expand Down Expand Up @@ -330,6 +338,7 @@ public void SetSelectedPlugin(PluginInterface pluginInterface)
if (pluginInterface is TunerInterface)
pluginInterface.Plugin.Enabled = true;

currentSelectedPlugin = pluginInterface;
selectedPluginWrapper.Child = pluginInterface;

UpdateContentLayout();
Expand Down
1 change: 0 additions & 1 deletion StompboxShared/Interface/TunerInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public TunerInterface(IAudioPlugin plugin)

if (StompboxClient.Instance.InClientMode)
{
plugin.Enabled = true;
StompboxClient.Instance.SendCommand("SetParam " + Plugin.ID + " Enabled " + (plugin.Enabled ? "1" : "0"));
}
}
Expand Down
12 changes: 12 additions & 0 deletions StompboxShared/StompboxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public IEnumerable<IAudioPlugin> AllActivePlugins
{
get
{
yield return Tuner;

yield return InputGain;

if (Amp != null)
Expand All @@ -62,14 +64,20 @@ public IEnumerable<IAudioPlugin> AllActivePlugins
foreach (IAudioPlugin plugin in OutputPlugins)
yield return plugin;

yield return AudioPlayer;

yield return AudioRecorder;

yield return MasterVolume;
}
}
public IAudioPlugin Tuner { get; private set; }
public IAudioPlugin InputGain { get; private set; }
public IAudioPlugin MasterVolume { get; private set; }
public IAudioPlugin Amp { get; private set; }
public IAudioPlugin Tonestack { get; private set; }
public IAudioPlugin Cabinet { get; private set; }
public IAudioPlugin AudioPlayer { get; private set; }
public IAudioPlugin AudioRecorder { get; private set; }
public float MaxDSPLoad { get; private set; }
public float MinDSPLoad { get; private set; }
Expand Down Expand Up @@ -427,6 +435,8 @@ public void UpdateUI()
{
Debug("*** Update UI");

Tuner = PluginFactory.CreatePlugin("Tuner");

InputGain = PluginFactory.CreatePlugin("Input");

Amp = CreateSlotPlugin("Amp", "NAM");
Expand All @@ -437,6 +447,8 @@ public void UpdateUI()

MasterVolume = PluginFactory.CreatePlugin("Master");

AudioPlayer = PluginFactory.CreatePlugin("AudioFilePlayer");

if (StompboxClient.Instance.InClientMode)
AudioRecorder = PluginFactory.CreatePlugin("AudioFileRecorder");

Expand Down

0 comments on commit 579a0b1

Please sign in to comment.