mirror of
https://github.com/eliasstepanik/VoicemeeterSliderControlCSharp.git
synced 2026-01-12 21:18:26 +00:00
Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
18
Dockerfile
18
Dockerfile
@ -1,18 +0,0 @@
|
|||||||
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,96 +1,12 @@
|
|||||||
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 SerialPort _serialPort;
|
static void Main(string[] args)
|
||||||
static async Task Main(string[] args)
|
|
||||||
{
|
{
|
||||||
string fileName = "Config.json";
|
Console.WriteLine("Hello World!");
|
||||||
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,7 +2,6 @@
|
|||||||
{
|
{
|
||||||
public class SliderSet
|
public class SliderSet
|
||||||
{
|
{
|
||||||
public int Slider { get; set; }
|
|
||||||
public string VoicemeeterValue { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,11 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
namespace VoicemeeterSliderControl
|
||||||
|
|
||||||
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,12 +3,6 @@
|
|||||||
<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,2 +1,4 @@
|
|||||||
<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></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||||
|
<Assembly Path="C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll" />
|
||||||
|
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
||||||
Loading…
x
Reference in New Issue
Block a user