Compare commits

...

1 Commits
0.1 ... master

Author SHA1 Message Date
Elias Stepanik
0cfd7f73c5
Add files via upload 2021-09-18 18:22:18 +02:00
7 changed files with 162 additions and 51 deletions

18
Dockerfile Normal file
View 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"]

View File

@ -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;
}
}
}

View File

@ -1,7 +1,8 @@
namespace VoicemeeterSliderControl
{
public class SliderSet
{
}
namespace VoicemeeterSliderControl
{
public class SliderSet
{
public int Slider { get; set; }
public string VoicemeeterValue { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -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>

View File

@ -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

View File

@ -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">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer /&gt;</s:String></wpf:ResourceDictionary>