Skip to content

Commit

Permalink
#TODO: Delayed Slide work
Browse files Browse the repository at this point in the history
  • Loading branch information
Neskol committed Nov 26, 2021
1 parent 2cb4511 commit 2f74156
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
29 changes: 5 additions & 24 deletions BPMChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,21 @@ public BPMChange(int bar, int startTime, double BPM)
this.BPM = BPM;
}

/// <summary>
/// Construct BPMChange with takein value
/// </summary>
/// <param name="takein">Take in BPMChange</param>
public BPMChange(BPMChange takein)
{
this.Bar = takein.Bar;
this.StartTime = takein.StartTime;
this.BPM = takein.BPM;
}

//public int Bar
//{
// get { return this.Bar; }
// set { this.Bar = value; }
//}

public int Tick
{
get
{ return this.StartTime; }
set
{ this.StartTime = value; }
}

//public int StartTime
//{
// get
// { return this.StartTime; }
// set
// {
// this.StartTime = value;
// }
//}

public override bool CheckValidity()
{
throw new NotImplementedException();
return this.BPM != 0;
}

public override string Compose(int format)
Expand Down
13 changes: 12 additions & 1 deletion BPMChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public void Add(int bar, int tick, double bpm)
this.changeNotes.Add(x);
}

/// <summary>
/// Compose change notes according to BPMChanges
/// </summary>
public void Update()
{
for (int i = 0; i < tick.Count; i++)
Expand Down Expand Up @@ -127,6 +130,10 @@ public string InitialChange
}
}

/// <summary>
/// See if the BPMChange is valid
/// </summary>
/// <returns>True if valid, false elsewise</returns>
public bool CheckValidity()
{
bool result = bar.IndexOf(0) == 0;
Expand All @@ -135,12 +142,16 @@ public bool CheckValidity()
return result;
}

/// <summary>
/// Compose BPMChanges in beginning of MA2
/// </summary>
/// <returns></returns>
public string Compose()
{
string result = "";
for (int i = 0; i < bar.Count; i++)
{
result += "BPM" + "\t" + changeNotes[i].Bar + "\t" + changeNotes[i].Tick + "\t" + changeNotes[i].BPM + "\n";
result += "BPM" + "\t" + changeNotes[i].Bar + "\t" + changeNotes[i].StartTime + "\t" + changeNotes[i].BPM + "\n";
//result += "BPM" + "\t" + bar[i] + "\t" + tick[i] + "\t" + String.Format("{0:F3}", bpm[i])+"\n";
}
return result;
Expand Down
19 changes: 12 additions & 7 deletions GoodBrother1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ public void Update()
afterBar.AddRange(bar);
this.chart.Add(FinishBar(afterBar, this.BPMChanges.ChangeNotes, i, CalculateQuaver(CalculateLeastMeasure(bar))));
}
Console.WriteLine("TOTAL DELAY: "+this.TotalDelay);
Console.WriteLine("TOTAL COUNT: "+ this.chart.Count * 384);
if (this.totalDelay<this.chart.Count*384)
{
this.totalDelay = 0;
Expand Down Expand Up @@ -550,23 +552,26 @@ public static List<Note> FinishBar(List<Note> bar, List<BPMChange> bpmChanges, i
// writeRest = false;
//}
}
bool addedTouch = false;
foreach (BPMChange x in bpmChanges)
{
if (eachSet.Contains(x))
if (eachSet.Contains(x)&&!addedTouch)
{
eachSet.Remove(x);
List<Note> adjusted = new List<Note>();
adjusted.Add(x);
adjusted.AddRange(touchEachSet);
adjusted.AddRange(eachSet);
eachSet = adjusted;
addedTouch = true;
}
else
else if (!addedTouch)
{
List<Note> adjusted = new List<Note>();
adjusted.AddRange(touchEachSet);
adjusted.AddRange(eachSet);
eachSet = adjusted;
addedTouch= true;
}
}
//for (int index = 0;index<eachSet.Count;index++)
Expand All @@ -590,16 +595,16 @@ public static List<Note> FinishBar(List<Note> bar, List<BPMChange> bpmChanges, i
if (RealNoteNumber(result) != RealNoteNumber(bar))
{
string error = "";
error += ("Bar notes not match in bar: " + barNumber);
error += ("Expected: " + RealNoteNumber(bar));
error += ("Bar notes not match in bar: " + barNumber)+"\n";
error += ("Expected: " + RealNoteNumber(bar)) + "\n";
foreach (Note x in bar)
{
error += (x.Compose(1));
error += (x.Compose(1)) + "\n";
}
error += ("\nActrual: " + RealNoteNumber(result));
error += ("\nActrual: " + RealNoteNumber(result)) + "\n";
foreach (Note y in result)
{
error += (y.Compose(1));
error += (y.Compose(1)) + "\n";
}
Console.WriteLine(error);
throw new Exception("NOTE NUMBER IS NOT MATCHING");
Expand Down
2 changes: 1 addition & 1 deletion MaidataCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public string Compose()
public string Compose(GoodBrother1 chart)
{
string result = "";
int delayBar = (chart.TotalDelay) / 384 + 1;
int delayBar = (chart.TotalDelay) / 384 + 2;
//Console.WriteLine(chart.Compose());
//foreach (BPMChange x in chart.BPMChanges.ChangeNotes)
//{
Expand Down
9 changes: 8 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
namespace MusicConverterTest
{
/// <summary>
/// Main program of converter
/// </summary>
class Program
{
/// <summary>
/// Main method to process charts
/// </summary>
/// <param name="args">Parameters to takein</param>
public static void Main(string[] args)
{
//GoodBrother1 good = new GoodBrother1(@"C:\MUG\maimai\SDEZ1.17\Package\Sinmai_Data\StreamingAssets\A000\music\music011089\011089_03.ma2");
//GoodBrother1 good = new GoodBrother1(@"C:\MUG\maimai\SDEZ1.17\Package\Sinmai_Data\StreamingAssets\A000\music\music011038\011038_03.ma2");
//MaidataCompiler compiler = new MaidataCompiler();
//Console.WriteLine(good.Compose());
//Console.WriteLine(compiler.Compose(good));
Expand Down

0 comments on commit 2f74156

Please sign in to comment.