mirror of
https://github.com/eliasstepanik/VoicemeeterSliderControlCSharp.git
synced 2026-01-11 20:48:27 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cfd7f73c5 |
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["VoicemeeterSliderControl.csproj", "./"]
|
||||||
|
RUN dotnet restore "VoicemeeterSliderControl.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/"
|
||||||
|
RUN dotnet build "VoicemeeterSliderControl.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "VoicemeeterSliderControl.csproj" -c Release -o /app/publish
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "VoicemeeterSliderControl.dll"]
|
||||||
88
Program.cs
88
Program.cs
@ -1,12 +1,96 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Ports;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace VoicemeeterSliderControl
|
namespace VoicemeeterSliderControl
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static SerialPort _serialPort;
|
||||||
|
static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Hello World!");
|
string fileName = "Config.json";
|
||||||
|
string jsonString = File.ReadAllText(fileName);
|
||||||
|
Sliders sliders = JsonSerializer.Deserialize<Sliders>(jsonString);
|
||||||
|
|
||||||
|
_serialPort = new SerialPort();
|
||||||
|
_serialPort.PortName = sliders.PortName;
|
||||||
|
_serialPort.BaudRate = sliders.BaudRate;
|
||||||
|
_serialPort.Open();
|
||||||
|
|
||||||
|
/*Sliders slider = new Sliders()
|
||||||
|
{
|
||||||
|
SliderSets = new List<SliderSet>()
|
||||||
|
{
|
||||||
|
new SliderSet()
|
||||||
|
{
|
||||||
|
Slider = 0,
|
||||||
|
VoicemeeterValue = "Strip[0].Gain"
|
||||||
|
},
|
||||||
|
new SliderSet()
|
||||||
|
{
|
||||||
|
Slider = 1,
|
||||||
|
VoicemeeterValue = "Strip[1].Gain"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
string fileNameSave = "Slider.json";
|
||||||
|
using FileStream createStream = File.Create(fileNameSave);
|
||||||
|
|
||||||
|
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||||
|
await JsonSerializer.SerializeAsync(createStream, slider);
|
||||||
|
await createStream.DisposeAsync();*/
|
||||||
|
|
||||||
|
using (var _ = await VoiceMeeter.Remote.Initialize(Voicemeeter.RunVoicemeeterParam.VoicemeeterPotato).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
int startSkip = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
string rawInput = _serialPort.ReadLine();
|
||||||
|
|
||||||
|
if (startSkip++ < 30)
|
||||||
|
continue;
|
||||||
|
if(rawInput.Equals(string.Empty))
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<float> valuesFloat = ParseValuesFloat(rawInput);
|
||||||
|
|
||||||
|
foreach (var slidersSlider in sliders.SliderSets)
|
||||||
|
{
|
||||||
|
var parameter = slidersSlider.VoicemeeterValue;
|
||||||
|
float setValue = map(valuesFloat[slidersSlider.Slider], 0f, 100f, -60f, 12f);
|
||||||
|
VoiceMeeter.Remote.SetParameter(parameter, setValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<float> ParseValuesFloat(string input)
|
||||||
|
{
|
||||||
|
List<float> floats = new List<float>();
|
||||||
|
|
||||||
|
string[] valueStrings = input.Split("|");
|
||||||
|
valueStrings[10] = valueStrings[10].Replace("\r", "");
|
||||||
|
|
||||||
|
foreach (var value in valueStrings)
|
||||||
|
{
|
||||||
|
if(!value.Contains("|") && !value.Equals(" ") && !value.Equals(String.Empty))
|
||||||
|
floats.Add(map(int.Parse(value), 0, 1024, 0f, 100f));
|
||||||
|
}
|
||||||
|
|
||||||
|
return floats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float map (float value, float from1, float to1, float from2, float to2) {
|
||||||
|
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class SliderSet
|
public class SliderSet
|
||||||
{
|
{
|
||||||
|
public int Slider { get; set; }
|
||||||
|
public string VoicemeeterValue { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,11 @@
|
|||||||
namespace VoicemeeterSliderControl
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace VoicemeeterSliderControl
|
||||||
{
|
{
|
||||||
public class Sliders
|
public class Sliders
|
||||||
{
|
{
|
||||||
+
|
public string PortName { get; set; }
|
||||||
|
public int BaudRate { get; set; }
|
||||||
|
public IList<SliderSet> SliderSets { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,12 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.IO.Ports" Version="5.0.1" />
|
||||||
|
<PackageReference Include="VoicemeeterRemote" Version="1.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,4 +1,2 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer /></s:String></wpf:ResourceDictionary>
|
||||||
<Assembly Path="C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll" />
|
|
||||||
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user