Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Updated to work with latest BoxVR #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions BOXVR Playlist Manager/App.config
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="BoxVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="BOXVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="BoxVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
<section name="BOXVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<BoxVR_Playlist_Manager.Properties.Settings>
<setting name="BoxVRExePath" serializeAs="String">
<value />
<value/>
</setting>
<setting name="BoxVRAppDataPath" serializeAs="String">
<value />
<value/>
</setting>
</BoxVR_Playlist_Manager.Properties.Settings>
<BOXVR_Playlist_Manager.Properties.Settings>
<setting name="BOXVRExePath" serializeAs="String">
<value />
<value/>
</setting>
<setting name="BOXVRAppDataPath" serializeAs="String">
<value />
<value/>
</setting>
</BOXVR_Playlist_Manager.Properties.Settings>
</userSettings>
</configuration>
</configuration>
73 changes: 67 additions & 6 deletions BOXVR Playlist Manager/BOXVR Playlist Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
<OutputType>WinExe</OutputType>
<RootNamespace>BoxVR_Playlist_Manager</RootNamespace>
<AssemblyName>BoxVR Playlist Manager</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -51,6 +52,12 @@
<Reference Include="ATL, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\z440.atl.core.2.5.0\lib\net30\ATL.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack">
<HintPath>..\..\SpotiSharp\bin\Debug\netcoreapp3.1\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.10\lib\net45\NLog.dll</HintPath>
</Reference>
Expand All @@ -72,20 +79,77 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Unity3D.UnityEngine.2018.3.5.1\lib\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions.cs" />
<Compile Include="FitXr\BeatStructure\Bar.cs" />
<Compile Include="FitXr\BeatStructure\BarList.cs" />
<Compile Include="FitXr\BeatStructure\Beat.cs" />
<Compile Include="FitXr\BeatStructure\BeatInfo.cs" />
<Compile Include="FitXr\BeatStructure\BeatList.cs" />
<Compile Include="FitXr\BeatStructure\BeatStructureBase.cs" />
<Compile Include="FitXr\BeatStructure\BeatStructureMadmom.cs" />
<Compile Include="FitXr\BeatStructure\FFmpegJob.cs" />
<Compile Include="FitXr\BeatStructure\FFmpegJobConvert.cs" />
<Compile Include="FitXr\BeatStructure\FFmpegQueue.cs" />
<Compile Include="FitXr\BeatStructure\MadmomProcess.cs" />
<Compile Include="FitXr\BeatStructure\PlaylistManager.cs" />
<Compile Include="FitXr\BeatStructure\SegmentList.cs" />
<Compile Include="FitXr\BeatStructure\SongParser.cs" />
<Compile Include="FitXr\BeatStructure\TrackDataManager.cs" />
<Compile Include="FitXr\BeatStructure\UserSongClip.cs" />
<Compile Include="FitXr\BeatStructure\VampProcess.cs" />
<Compile Include="FitXr\Enums\TrackGenre.cs" />
<Compile Include="FitXr\Enums\WorkoutType.cs" />
<Compile Include="FitXr\Models\MusicActionSerializable.cs" />
<Compile Include="FitXr\Models\WorkoutId.cs" />
<Compile Include="FitXr\MusicActionListSerializer.cs" />
<Compile Include="FitXr\MusicActions\MessagePosition.cs" />
<Compile Include="FitXr\MusicActions\MoveAction.cs" />
<Compile Include="FitXr\MusicActions\MoveChannel.cs" />
<Compile Include="FitXr\MusicActions\MoveType.cs" />
<Compile Include="FitXr\MusicActions\MusicAction.cs" />
<Compile Include="FitXr\MusicActions\MusicActionAudio.cs" />
<Compile Include="FitXr\MusicActions\MusicActionBPM.cs" />
<Compile Include="FitXr\MusicActions\MusicActionMessage.cs" />
<Compile Include="FitXr\MusicActions\MusicActionMoveCue.cs" />
<Compile Include="FitXr\MusicActions\MusicActionType.cs" />
<Compile Include="FitXr\Tools\Format.cs" />
<Compile Include="FitXr\BeatStructure\Segment.cs" />
<Compile Include="FitXr\Enums\AudioClipStatus.cs" />
<Compile Include="FitXr\Enums\Game.cs" />
<Compile Include="FitXr\Enums\LocationMode.cs" />
<Compile Include="FitXr\Enums\TrackDataState.cs" />
<Compile Include="FitXr\ReadOnlyDictionary.cs" />
<Compile Include="FitXr\Tools\IO.cs" />
<Compile Include="FitXr\Utility\MD5.cs" />
<Compile Include="FitXr\Utility\ShuffleList.cs" />
<Compile Include="FitXr\WorkoutDefinitionManager.cs" />
<Compile Include="Helpers\NotifyingObject.cs" />
<Compile Include="Helpers\Paths.cs" />
<Compile Include="FitXr\Models\SerialisedActionList.cs" />
<Compile Include="FitXr\Models\TrackBase.cs" />
<Compile Include="FitXr\Models\TrackData.cs" />
<Compile Include="FitXr\Models\TrackDefinition.cs" />
<Compile Include="FitXr\Models\TrackId.cs" />
<Compile Include="FitXr\Models\WorkoutInfo.cs" />
<Compile Include="FitXr\Models\WorkoutPlaylist.cs" />
<Compile Include="FitXr\Models\SongDefinition.cs" />
<Compile Include="IsEnabledColorConverter.cs" />
<Compile Include="Track.cs" />
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="SafeNativeMethods.cs" />
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="Playlist.cs" />
<Compile Include="PlaylistViewModel.cs" />
<Compile Include="SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -131,9 +195,6 @@
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="beatmap.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
Expand Down
10 changes: 10 additions & 0 deletions BOXVR Playlist Manager/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
Expand All @@ -17,6 +18,15 @@ public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Wind
return win;
}

public static string Md5Hash(this string text)
{
using(MD5 md5 = MD5.Create())
{
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(text));
return Encoding.UTF8.GetString(hash);
}
}

private class OldWindow : System.Windows.Forms.IWin32Window
{
private readonly IntPtr _handle;
Expand Down
26 changes: 26 additions & 0 deletions BOXVR Playlist Manager/FitXr/BeatStructure/Bar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Newtonsoft.Json;

namespace BoxVR_Playlist_Manager.FitXr.BeatStructure
{
public class Bar
{
[JsonProperty("_avgEnergy")]
public float _avgEnergy;
[JsonProperty("_duration")]
public float _duration;
[JsonProperty("_startTime")]
public float _startTime;
[JsonProperty("_beatIndex")]
public int _beatIndex;

public float Bpm => Bar.DurationToBpm(this._duration);

public float EndTime => this._startTime + this._duration;

public static float DurationToBpm(float duration) => 240f / duration;

public static float BpmToDuration(float bpm) => 240f / bpm;

public override string ToString() => "Start:" + (object)this._startTime + " Length:" + (object)this._duration;
}
}
162 changes: 162 additions & 0 deletions BOXVR Playlist Manager/FitXr/BeatStructure/BarList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace BoxVR_Playlist_Manager.FitXr.BeatStructure
{
public class BarList
{
public List<Bar> _bars;

protected float CalcMedianLength()
{
List<Bar> barList = new List<Bar>((IEnumerable<Bar>)this._bars);
barList.Sort((Comparison<Bar>)((x, y) => (int)Mathf.Sign(x._duration - y._duration)));
return barList[barList.Count / 2]._duration;
}

public void HalfSpeed()
{
for(int index = 0; index < this._bars.Count - 1; ++index)
{
Bar bar1 = this._bars[index];
Bar bar2 = this._bars[index + 1];
bar1._duration += bar2._duration;
bar1._avgEnergy = (float)(((double)bar1._avgEnergy + (double)bar2._avgEnergy) / 2.0);
this._bars.RemoveAt(index + 1);
}
}

public void DoubleSpeed(BeatList beats)
{
for(int index = 0; index < this._bars.Count; index += 2)
{
Bar bar1 = this._bars[index];
Bar bar2 = new Bar();
this._bars.Insert(index + 1, bar2);
float num = bar1._duration / 2f;
bar1._duration = num;
bar2._duration = num;
bar2._startTime = bar1._startTime + num;
}
}

public void UpdateEnergies(List<BeatInfo> beats)
{
for(int index1 = 0; index1 < this._bars.Count; ++index1)
{
Bar bar = this._bars[index1];
for(int index2 = 0; index2 <= 3; ++index2)
{
int index3 = bar._beatIndex + index2;
if(index3 < beats.Count && beats[index3]._beatInBar == index2 + 1)
bar._avgEnergy += beats[index3]._magnitude;
}
bar._avgEnergy /= 4f;
}
}

public void FillEmptyRegions(float deltaBpm, float songLength)
{
float duration1 = this.CalcMedianLength();
while(true)
{
float num = this._bars[0]._startTime - duration1;
if((double)num >= 0.0)
this._bars.Insert(0, new Bar()
{
_duration = duration1,
_startTime = num
});
else
break;
}
float duration2 = Bar.BpmToDuration(Bar.DurationToBpm(duration1) + deltaBpm);
for(int index = 0; index < this._bars.Count - 1; ++index)
{
double startTime = (double)this._bars[index + 1]._startTime;
float endTime = this._bars[index].EndTime;
double num1 = (double)endTime;
float num2 = (float)(startTime - num1);
if((double)num2 >= (double)duration1)
this._bars.Insert(index + 1, new Bar()
{
_duration = duration1,
_startTime = endTime
});
else if((double)num2 >= (double)duration2)
this._bars.Insert(index + 1, new Bar()
{
_duration = num2,
_startTime = endTime
});
else if((double)num2 > 0.0)
this._bars[index]._duration += num2;
}
while(true)
{
Bar bar = this._bars[this._bars.Count - 1];
if((double)bar.EndTime + (double)duration1 <= (double)songLength)
this._bars.Add(new Bar()
{
_startTime = bar.EndTime,
_duration = duration1
});
else
break;
}
}

public void RemoveDeviants(float bpmDelta)
{
float num = 240f / this.CalcMedianLength();
int index = 0;
while(index < this._bars.Count)
{
Bar bar = this._bars[index];
if((double)Mathf.Abs(bar.Bpm - num) > (double)bpmDelta)
this._bars.Remove(bar);
else
++index;
}
}

public void CreateFromBeats(List<BeatInfo> beats)
{
this._bars = new List<Bar>();
Bar bar = (Bar)null;
for(int index = 0; index < beats.Count; ++index)
{
BeatInfo beat = beats[index];
if(beat._beatInBar == 1)
{
bar = new Bar()
{
_startTime = beat._triggerTime,
_beatIndex = index
};
this._bars.Add(bar);
}
if(bar != null && beat._beatInBar == 4)
bar._duration = beat._triggerTime + beat._beatLength - bar._startTime;
}
this.UpdateEnergies(beats);
}

public int FindClosestBar(float time, List<BeatInfo> beats)
{
float num1 = float.MaxValue;
int num2 = -1;
for(int index = 0; index < this._bars.Count; ++index)
{
float num3 = Mathf.Abs(this._bars[index]._startTime - time);
if((double)num3 < (double)num1)
{
num2 = index;
num1 = num3;
}
}
return num2;
}
}
}
16 changes: 16 additions & 0 deletions BOXVR Playlist Manager/FitXr/BeatStructure/Beat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace BoxVR_Playlist_Manager.FitXr.BeatStructure
{
public class Beat
{
public float length;
public float bpm;
public int index;

public Beat(float length, float bpm, int index)
{
this.length = length;
this.bpm = bpm;
this.index = index;
}
}
}
Loading