oggy22 / MusicTools

Various musical tools including music hearing, machine composer and Chomsky music analyzer.
4 stars 2 forks source link

MelodyPart perf improvement #79

Open oggy22 opened 5 years ago

oggy22 commented 5 years ago

MelodyPartList can improve perf by refactoring as: insert

class MelodyPartList
{
   struct NotePartChunck
   {
      NoteWithDuration nwd;
      MelodyPart mp;
   }
   private List<NotePartChunk> npc;

  void AssertValid()
  {
    for (int i=0; i<npc.lenght; i++)
    {
        if (i!=0) Debug.Assert(npc.nwd.Count != 0);
        if (i!=npc.Lenght-1) Debug.Assert(npc.mp.Count != 0);
    }
  }
}