Skip to content

Commit

Permalink
Fixed Touch Portal plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
oddbear committed Feb 4, 2022
1 parent 6f5923e commit 6b091f7
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
44 changes: 44 additions & 0 deletions Revelator.io24.TouchPortal/RevelatorIo24Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ private void RoutingUpdated(object? sender, EventArgs e)
_client.StateUpdate(PluginId + ".states.return/ch2/assign_aux2", routing.MixB_VirtualA ? "On" : "Off");
_client.StateUpdate(PluginId + ".states.return/ch3/assign_aux2", routing.MixB_VirtualB ? "On" : "Off");
_client.StateUpdate(PluginId + ".states.aux/ch2/mute", routing.MixB_Mix ? "On" : "Off");

_client.StateUpdate(PluginId + ".states.line/ch1/bypassDSP", routing.FatChannel_MicL ? "On" : "Off");
_client.StateUpdate(PluginId + ".states.line/ch2/bypassDSP", routing.FatChannel_MicR ? "On" : "Off");
}

public void Init()
Expand All @@ -76,6 +79,11 @@ public void OnActionEvent(ActionEvent message)
{
HeadphonesSourceChange(actionId + ".data", message.Data);
}

if (actionId.EndsWith(".fatchanneltoggle.action.change"))
{
FatChannelChange(actionId + ".data", message.Data);
}
}

private void RouteChange(string name, IReadOnlyCollection<ActionDataSelected> datalist)
Expand Down Expand Up @@ -169,6 +177,42 @@ private void HeadphonesSourceChange(string name, IReadOnlyCollection<ActionDataS
}
}

private void FatChannelChange(string name, IReadOnlyCollection<ActionDataSelected> datalist)
{
var dict = datalist
.ToDictionary(kv => kv.Id, kv => kv.Value);

var microphone = dict[name + ".microphone"];
var action = dict[name + ".actions"];

var route = GetFatChannelRoute(microphone);
var state = GetCurrentFatChannelState(route);
var value = GetFatChannelAction(action, route);

_updateService.SetRouteValue(route, value);
}

private string GetFatChannelRoute(string microphone)
=> microphone switch
{
"Mic L" => "line/ch1/bypassDSP",
"Mic R" => "line/ch2/bypassDSP",
_ => throw new InvalidOperationException()
};

private bool GetCurrentFatChannelState(string route)
=> route == "line/ch1/bypassDSP"
? _updateService.Routing.FatChannel_MicL
: _updateService.Routing.FatChannel_MicR;

private float GetFatChannelAction(string action, string route)
=> action switch
{
"Turn On" => 0.0f,
"Turn Off" => 1.0f,
_ => GetCurrentFatChannelState(route) ? 1.0f : 0.0f,
};

private Headphones GetHeadphoneEnum(string headphoneValue)
{
return headphoneValue switch
Expand Down
49 changes: 47 additions & 2 deletions Revelator.io24.TouchPortal/entry.tp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": 4,
"version": 1,
"version": 2,
"name": "Revelator io24 TouchPortal Plugin",
"id": "oddbear.touchportal.revelator.io24",
"configuration": {
Expand Down Expand Up @@ -66,7 +66,7 @@
"name": "io24 Headphones source Select",
"type": "communicate",
"tryInline": true,
"format": "Profile {$oddbear.touchportal.revelator.io24.headphones.action.change.data.headphones$}",
"format": "Headphone Source {$oddbear.touchportal.revelator.io24.headphones.action.change.data.headphones$}",
"description": "The profile to select on the io24 device.",
"data": [
{
Expand All @@ -81,6 +81,38 @@
]
}
]
},
{
"id": "oddbear.touchportal.revelator.io24.fatchanneltoggle.action.change",
"prefix": "io24:",
"name": "io24 Fat Channel Toggle",
"type": "communicate",
"tryInline": true,
"format": "Microphone {$oddbear.touchportal.revelator.io24.fatchanneltoggle.action.change.data.microphone$} Action {$oddbear.touchportal.revelator.io24.fatchanneltoggle.action.change.data.actions$}",
"description": "The Fat Channel to toggle on the io24 device.",
"data": [
{
"id": "oddbear.touchportal.revelator.io24.fatchanneltoggle.action.change.data.microphone",
"type": "choice",
"label": "Microphone",
"default": "Mic L",
"valueChoices": [
"Mic L",
"Mic R"
]
},
{
"id": "oddbear.touchportal.revelator.io24.fatchanneltoggle.action.change.data.actions",
"type": "choice",
"label": "Action",
"default": "Toggle",
"valueChoices": [
"Toggle",
"Turn On",
"Turn Off"
]
}
]
}
],
"states": [
Expand Down Expand Up @@ -200,6 +232,19 @@
"type": "text",
"desc": "io24: Mute All / Stream Mix B",
"default": ""
},

{
"id": "oddbear.touchportal.revelator.io24.states.line/ch1/bypassDSP",
"type": "text",
"desc": "io24: Fat Channel Left",
"default": ""
},
{
"id": "oddbear.touchportal.revelator.io24.states.line/ch2/bypassDSP",
"type": "text",
"desc": "io24: Fat Channel Right",
"default": ""
}
],
"events": []
Expand Down

0 comments on commit 6b091f7

Please sign in to comment.