mirror of
https://github.com/eliasstepanik/VoicemeeterSliderControlCSharp.git
synced 2026-01-11 12:38: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"]
|
||||
108
Program.cs
108
Program.cs
@ -1,12 +1,96 @@
|
||||
using System;
|
||||
|
||||
namespace VoicemeeterSliderControl
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static SerialPort _serialPort;
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
SliderSet.cs
13
SliderSet.cs
@ -1,7 +1,8 @@
|
||||
namespace VoicemeeterSliderControl
|
||||
{
|
||||
public class SliderSet
|
||||
{
|
||||
|
||||
}
|
||||
namespace VoicemeeterSliderControl
|
||||
{
|
||||
public class SliderSet
|
||||
{
|
||||
public int Slider { get; set; }
|
||||
public string VoicemeeterValue { get; set; }
|
||||
}
|
||||
}
|
||||
16
Sliders.cs
16
Sliders.cs
@ -1,7 +1,11 @@
|
||||
namespace VoicemeeterSliderControl
|
||||
{
|
||||
public class Sliders
|
||||
{
|
||||
+
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VoicemeeterSliderControl
|
||||
{
|
||||
public class Sliders
|
||||
{
|
||||
public string PortName { get; set; }
|
||||
public int BaudRate { get; set; }
|
||||
public IList<SliderSet> SliderSets { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Ports" Version="5.0.1" />
|
||||
<PackageReference Include="VoicemeeterRemote" Version="1.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoicemeeterSliderControl", "VoicemeeterSliderControl.csproj", "{21650B59-0EEF-46AB-8663-DB1162392300}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoicemeeterSliderControl", "VoicemeeterSliderControl.csproj", "{21650B59-0EEF-46AB-8663-DB1162392300}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{21650B59-0EEF-46AB-8663-DB1162392300}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@ -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">
|
||||
<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>
|
||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer /></s:String></wpf:ResourceDictionary>
|
||||
Loading…
x
Reference in New Issue
Block a user