Skip to content

Commit

Permalink
v1.8 - Midi Support, Hotkeys support, AND/OR support and more...
Browse files Browse the repository at this point in the history
- `AND/OR` support on the Mode1 Check in the `Advanced Toggle`! You can now do things like `Strip[0].Mute AND Strip[1].B2` or `Strip[0].Solo OR Strip[0].B2 OR Strip[1].B1`
- Customizable `Long Press` length on the Press/Long-Press action
- **Hotkey Support** 🤩 - All advanced actions now support sending hotkeys to integrate with the :voicemeeter: Macros
- **Midi Support** 🤩 🤩 - All advanced actions now support the :voicemeeter: `SendMidi` commands
- Support for `\n` (new line) in the Enabled/Disabled Texts
  • Loading branch information
BarRaider committed Apr 13, 2020
1 parent 056c036 commit 4d1afc6
Show file tree
Hide file tree
Showing 29 changed files with 1,561 additions and 258 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# streamdeck-voicemeeter
# Voicemeeter Integration
VoiceMeeter integration and live feedback for the Elgato Stream Deck device.

**Author's website and contact information:** [https://barraider.github.io](https://barraider.github.io)
**Author's website and contact information:** [https://barraider.com](https://barraider.com)

## What's new in v1.8
- `AND/OR` support on the Mode1 Check in the `Advanced Toggle`! You can now do things like `Strip[0].Mute AND Strip[1].B2` or `Strip[0].Solo OR Strip[0].B2 OR Strip[1].B1`
- Customizable `Long Press` length on the Press/Long-Press action
- **Hotkey Support** :star_struck: - All advanced actions now support sending hotkeys to integrate with the :voicemeeter: Macros
- **Midi Support** :star_struck: :star_struck: - All advanced actions now support the :voicemeeter: `SendMidi` commands
- Support for `\n` (new line) in the Enabled/Disabled Texts

## What's new in 1.7
- VM Advanced actions now support renaming values that show 1 / 0 to a user-defined text (On/Off or Enabled/Disabled, etc.)
Expand All @@ -19,7 +26,7 @@ https://github.com/BarRaider/streamdeck-voicemeeter/releases/
- See a live indication of the current status on Stream Deck (never forget your microphone on again!)
- Can also be used to mute/unmute different Strips/Buses such as Spotify/Background music/etc.
- Choose from 4 different icons to display the mute/unmute settings
- **New in v1.0:** You can now choose your own images to display, instead of the 4 pre-defined icons
- Choose your own images to display, instead of the 4 pre-defined icons

#### VoiceMeeter Modify Setting
- Allows you to easily modify various VoiceMeeter settings
Expand Down Expand Up @@ -79,26 +86,16 @@ A: Valid values can be found starting on page 9 of VoiceMeeter API PDF: https://
Q: Can I make the title multi-line?
A: Yes, write `\n` in the `Title Prefix` parameter to add lines

## Dependencies
This plugin uses the [StreamDeck-Tools](https://github.com/BarRaider/streamdeck-tools) v2.0
### Download

## How do I get started using it?
Install by clicking the com.barraider.voicemeeter.streamDeckPlugin file in the Releases folder:
https://github.com/BarRaider/streamdeck-voicemeeter/releases
* [Download plugin](https://github.com/BarRaider/streamdeck-voicemeeter/releases/)

## I found a bug, who do I contact?
For support please contact the developer. Contact information is available at https://barraider.github.io
For support please contact the developer. Contact information is available at https://barraider.com

## I have a feature request, who do I contact?
Please contact the developer. Contact information is available at https://barraider.github.io

## License
MIT License

Copyright (c) 2019
Please contact the developer. Contact information is available at https://barraider.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Dependencies
* Uses StreamDeck-Tools by BarRaider: [![NuGet](https://img.shields.io/nuget/v/streamdeck-tools.svg?style=flat)](https://www.nuget.org/packages/streamdeck-tools)
* Uses [Easy-PI](https://github.com/BarRaider/streamdeck-easypi) by BarRaider - Provides seamless integration with the Stream Deck PI (Property Inspector)
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using BarRaider.SdTools;
using HotkeyCommands;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VoiceMeeter.Midi;

namespace VoiceMeeter
{
[PluginActionId("com.barraider.vmadvancedptt")]
public class VMAdvancedPTT : PluginBase
public class VMAdvancedPTTAction : PluginBase
{
private class PluginSettings
{
Expand Down Expand Up @@ -50,6 +52,18 @@ public static PluginSettings CreateDefaultSettings()

[JsonProperty(PropertyName = "disabledText")]
public string DisabledText { get; set; }

[JsonProperty(PropertyName = "keypressHotkey")]
public string KeypressHotkey { get; set; }

[JsonProperty(PropertyName = "keypressMidi")]
public string KeypressMidi { get; set; }

[JsonProperty(PropertyName = "releaseHotkey")]
public string ReleaseHotkey { get; set; }

[JsonProperty(PropertyName = "releaseMidi")]
public string ReleaseMidi { get; set; }
}

#region Private members
Expand All @@ -60,7 +74,7 @@ public static PluginSettings CreateDefaultSettings()

#region Public Methods

public VMAdvancedPTT(SDConnection connection, InitialPayload payload) : base(connection, payload)
public VMAdvancedPTTAction(SDConnection connection, InitialPayload payload) : base(connection, payload)
{
if (payload.Settings == null || payload.Settings.Count == 0)
{
Expand All @@ -71,6 +85,7 @@ public VMAdvancedPTT(SDConnection connection, InitialPayload payload) : base(con
{
this.settings = payload.Settings.ToObject<PluginSettings>();
}
InitializeSettings();
}

public async override void KeyPressed(KeyPayload payload)
Expand All @@ -85,6 +100,12 @@ public async override void KeyPressed(KeyPayload payload)
{
VMManager.Instance.SetParameters(settings.KeyPressValue);
}
MidiCommandHandler.HandleMidiParameters(settings.KeypressMidi);

if (!String.IsNullOrEmpty(settings.KeypressHotkey))
{
HotkeyHandler.RunHotkey(settings.KeypressHotkey);
}
}

public override void KeyReleased(KeyPayload payload)
Expand All @@ -93,6 +114,12 @@ public override void KeyReleased(KeyPayload payload)
{
VMManager.Instance.SetParameters(settings.KeyReleaseValue);
}
MidiCommandHandler.HandleMidiParameters(settings.ReleaseMidi);

if (!String.IsNullOrEmpty(settings.ReleaseHotkey))
{
HotkeyHandler.RunHotkey(settings.ReleaseHotkey);
}
}

public async override void OnTick()
Expand Down Expand Up @@ -127,8 +154,8 @@ public async override void OnTick()

public override void ReceivedSettings(ReceivedSettingsPayload payload)
{
// New in StreamDeck-Tools v2.0:
Tools.AutoPopulateSettings(settings, payload.Settings);
InitializeSettings();
Logger.Instance.LogMessage(TracingLevel.INFO, $"Settings loaded: {payload.Settings}");
}

Expand All @@ -140,5 +167,29 @@ public override void Dispose()
}

#endregion

#region Private Methods

private void InitializeSettings()
{
string keypressHotkey = HotkeyHandler.ParseKeystroke(settings.KeypressHotkey);
string releaseHotkey = HotkeyHandler.ParseKeystroke(settings.ReleaseHotkey);

// If the parsed hotkey is different than what the user inputed, overwrite the user input
// because it's invalid
if (keypressHotkey != settings.KeypressHotkey || releaseHotkey != settings.ReleaseHotkey)
{
settings.KeypressHotkey = keypressHotkey;
settings.ReleaseHotkey = releaseHotkey;
SaveSettings();
}
}

private Task SaveSettings()
{
return Connection.SetSettingsAsync(JObject.FromObject(settings));
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using BarRaider.SdTools;
using HotkeyCommands;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VoiceMeeter.Midi;

namespace VoiceMeeter
{
[PluginActionId("com.barraider.vmadvanced")]
class VMAdvancedPress : PluginBase
class VMAdvancedPressAction : PluginBase
{
private class PluginSettings
{
Expand All @@ -24,7 +26,12 @@ public static PluginSettings CreateDefaultSettings()
TitleParam = String.Empty,
TitlePrefix = String.Empty,
EnabledText = String.Empty,
DisabledText = String.Empty
DisabledText = String.Empty,
KeypressHotkey = String.Empty,
KeypressMidi = String.Empty,
LongHotkey = String.Empty,
LongMidi = String.Empty,
LongKeypressTime = LONG_KEYPRESS_LENGTH_MS.ToString()
};

return instance;
Expand All @@ -50,22 +57,39 @@ public static PluginSettings CreateDefaultSettings()

[JsonProperty(PropertyName = "disabledText")]
public string DisabledText { get; set; }

[JsonProperty(PropertyName = "keypressHotkey")]
public string KeypressHotkey { get; set; }

[JsonProperty(PropertyName = "keypressMidi")]
public string KeypressMidi { get; set; }

[JsonProperty(PropertyName = "longHotkey")]
public string LongHotkey { get; set; }

[JsonProperty(PropertyName = "longMidi")]
public string LongMidi { get; set; }

[JsonProperty(PropertyName = "longKeypressTime")]
public string LongKeypressTime { get; set; }
}

#region Private members

private const int LONG_KEYPRESS_LENGTH = 1;
private const int LONG_KEYPRESS_LENGTH_MS = 600;

private readonly PluginSettings settings;
private bool keyPressed = false;
private bool longKeyPressed = false;
private DateTime keyPressStart;
private int longKeypressTime = LONG_KEYPRESS_LENGTH_MS;
private readonly System.Timers.Timer tmrRunLongPress = new System.Timers.Timer();

#endregion

#region Public Methods

public VMAdvancedPress(SDConnection connection, InitialPayload payload) : base(connection, payload)
public VMAdvancedPressAction(SDConnection connection, InitialPayload payload) : base(connection, payload)
{
if (payload.Settings == null || payload.Settings.Count == 0)
{
Expand All @@ -76,6 +100,14 @@ public VMAdvancedPress(SDConnection connection, InitialPayload payload) : base(c
{
this.settings = payload.Settings.ToObject<PluginSettings>();
}
tmrRunLongPress.Elapsed += TmrRunLongPress_Elapsed;

InitializeSettings();
}

private void TmrRunLongPress_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
LongKeyPressed();
}

public void LongKeyPressed()
Expand All @@ -85,6 +117,12 @@ public void LongKeyPressed()
{
VMManager.Instance.SetParameters(settings.LongPressValue);
}
MidiCommandHandler.HandleMidiParameters(settings.LongMidi);

if (!String.IsNullOrEmpty(settings.LongHotkey))
{
HotkeyHandler.RunHotkey(settings.LongHotkey);
}
}

#endregion
Expand All @@ -93,8 +131,8 @@ public void LongKeyPressed()

public override void ReceivedSettings(ReceivedSettingsPayload payload)
{
// New in StreamDeck-Tools v2.0:
Tools.AutoPopulateSettings(settings, payload.Settings);
InitializeSettings();
Logger.Instance.LogMessage(TracingLevel.INFO, $"Settings loaded: {payload.Settings}");
}

Expand All @@ -110,15 +148,24 @@ public async override void KeyPressed(KeyPayload payload)
await Connection.ShowAlert();
return;
}

tmrRunLongPress.Interval = longKeypressTime > 0 ? longKeypressTime : LONG_KEYPRESS_LENGTH_MS;
tmrRunLongPress.Start();
}

public override void KeyReleased(KeyPayload payload)
{
keyPressed = false;
tmrRunLongPress.Stop();

if (!longKeyPressed && !String.IsNullOrEmpty(settings.SetValue))
{
VMManager.Instance.SetParameters(settings.SetValue);
MidiCommandHandler.HandleMidiParameters(settings.KeypressMidi);
if (!String.IsNullOrEmpty(settings.KeypressHotkey))
{
HotkeyHandler.RunHotkey(settings.KeypressHotkey);
}
}
}

Expand All @@ -130,13 +177,6 @@ public async override void OnTick()
return;
}

// Stream Deck calls this function every second,
// so this is the best place to determine if we need to call the long keypress
if (!String.IsNullOrEmpty(settings.LongPressValue) && keyPressed && (DateTime.Now - keyPressStart).TotalSeconds >= LONG_KEYPRESS_LENGTH)
{
LongKeyPressed();
}

if (settings.TitleType == TitleTypeEnum.VMLive && !String.IsNullOrEmpty(settings.TitleParam))
{
string prefix = String.Empty;
Expand Down Expand Up @@ -167,5 +207,35 @@ public override void Dispose()
public override void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload) { }

#endregion

#region Private Methods

private void InitializeSettings()
{
string keypressHotkey = HotkeyHandler.ParseKeystroke(settings.KeypressHotkey);
string longHotkey = HotkeyHandler.ParseKeystroke(settings.LongHotkey);

// If the parsed hotkey is different than what the user inputed, overwrite the user input
// because it's invalid
if (keypressHotkey != settings.KeypressHotkey || longHotkey != settings.LongHotkey)
{
settings.KeypressHotkey = keypressHotkey;
settings.LongHotkey = longHotkey;
SaveSettings();
}

if (!Int32.TryParse(settings.LongKeypressTime, out longKeypressTime))
{
settings.LongKeypressTime = LONG_KEYPRESS_LENGTH_MS.ToString();
SaveSettings();
}
}

private Task SaveSettings()
{
return Connection.SetSettingsAsync(JObject.FromObject(settings));
}

#endregion
}
}
Loading

0 comments on commit 4d1afc6

Please sign in to comment.