Skip to content

Commit

Permalink
Sliders for time thresholds.
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoru committed Apr 18, 2017
1 parent 532c51e commit e399449
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 90 deletions.
90 changes: 90 additions & 0 deletions BmsonStemOptimizer/BmsonNoteLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace BmsonStemOptimizer
{
struct Note
{
public ulong x;
public ulong y;
public bool c;
public ulong l; // will go unchanged.
public Note(ulong x, ulong y, bool c, ulong l)
{
this.x = x;
this.y = y;
this.c = c;
this.l = l;
}
}



struct SoundChannel
{
public string name;
public Note[] notes;

public SoundChannel(string name, Note[] notes)
{
this.name = name;
this.notes = notes;
}

public SoundChannel Clone()
{
var newnotes = notes.Clone();
var output = new SoundChannel(name, notes);

return output;
}
}

class BmsonNoteLoader
{
private List<SoundChannel> StemNotes;

// Clones the internal parsed data!
public List<SoundChannel> GetNotes()
{
List<SoundChannel> Output = new List<SoundChannel>(StemNotes);
return Output;
}

private void LoadNotes(JObject root)
{
StemNotes = new List<SoundChannel>();
var soundchannels = root["sound_channels"];
if (soundchannels == null)
{
Logger.Log("INFO: sound_channels is null. No notes were loaded.");
}

foreach (var sc in soundchannels)
{
string stem = (string)sc["name"];

var notes = new List<Note>();
foreach (var note in sc["notes"])
{
notes.Add(new Note(
note["x"] != null ? (ulong)note["x"] : 0,
note["y"] != null ? (ulong)note["y"] : 0,
note["c"] != null ? (bool)note["c"] : true,
note["l"] != null ? (ulong)note["l"] : 0));
}

StemNotes.Add(new SoundChannel(stem, notes.ToArray()));
}
}

public BmsonNoteLoader(JObject root)
{
LoadNotes(root);
}
}
}
1 change: 1 addition & 0 deletions BmsonStemOptimizer/BmsonStemOptimizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Logger.cs" />
<Compile Include="BmsonNoteLoader.cs" />
<Compile Include="NoteRemapper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
120 changes: 96 additions & 24 deletions BmsonStemOptimizer/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions BmsonStemOptimizer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void BsoForm_Load(object sender, EventArgs e)
Logger.Log("@@@ Starting execution");

StemOptimizer.UseLoudEpsilon = epsilonCheckbox.Checked;
StemOptimizer.UseMinimumPlayback = minPlaybackCheckbox.Checked;
StemOptimizer.UseMinimumPlayback = true;

Logger.OnLogEvent += (ev) =>
{
Expand Down Expand Up @@ -231,7 +231,7 @@ private void epsilonCheckbox_CheckedChanged(object sender, EventArgs e)

private void minPlaybackCheckbox_CheckedChanged(object sender, EventArgs e)
{
StemOptimizer.UseMinimumPlayback = minPlaybackCheckbox.Checked;
// StemOptimizer.UseMinimumPlayback = minPlaybackCheckbox.Checked;
}

private void searchRemappingFileButton_Click(object sender, EventArgs e)
Expand All @@ -247,5 +247,27 @@ private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{

}

private void label5_Click(object sender, EventArgs e)
{

}

private void trackBar1_Scroll(object sender, EventArgs e)
{
lblPlaybackTime.Text = string.Format("{0}ms", tbMinPlayback.Value);
StemOptimizer.MinPlaybackTime = tbMinPlayback.Value / 1000.0;
}

private void label6_Click(object sender, EventArgs e)
{

}

private void trackBar1_Scroll_1(object sender, EventArgs e)
{
lblSilencePeriod.Text = string.Format("{0}ms", tbMinSilence.Value);
StemOptimizer.MinSilenceTime = tbMinSilence.Value / 1000.0;
}
}
}
Loading

0 comments on commit e399449

Please sign in to comment.