// caution: this is called very frequently i.e. as often as possible internal bool TimerTick(long msec, int beatsPerMinute, int sliderBarOffset, Action <int> setNewBarIndex) { if (sliderBarOffset < 1) { throw new Exception(); } --sliderBarOffset; Model.Bar firstBar = modelBars[sliderBarOffset]; int firstMsecs = firstBar.getMsec(beatsPerMinute); if (msec < firstMsecs) { int interval = (int)((double)firstBar.state.nIntervalsPerBar * msec / firstMsecs); bars[sliderBarOffset].CountdownTick(interval); return(true); } msec -= firstMsecs; Model.When?when = modelBars.getWhen(msec, beatsPerMinute, sliderBarOffset); if (!when.HasValue) { // end of play StopPlay(); return(false); } timerTick(when.Value, setNewBarIndex); return(true); }
internal Bar(Model.Bar modelBar, Model.Bar likeOther = null) { state = modelBar.state; Width = 220; Height = 190; for (int i = 0; i < 6; ++i) { newHorizontal(20, 200, lineY(i)); } newLabel( lineY(5), timeX(0, LabelType.BarNumber), modelBar.barNumber.number.ToString(), LabelType.BarNumber ); string comment = modelBar.barNumber.comment; if (string.IsNullOrEmpty(comment) && (likeOther != null)) { comment = string.Format("(like {0})", likeOther.barNumber.number); } if (!string.IsNullOrEmpty(comment)) { newLabel( lineY(-1), timeX(0, LabelType.Comment), comment, LabelType.Comment ); } if (likeOther != null) { showContents(likeOther); } else { showContents(modelBar); } this.Background = backgroundBrush; }
void showContents(Model.Bar modelBar) { foreach (Chord chord in modelBar.chords) { newLabel( lineY(6), timeX(chord.time, LabelType.Chord), chord.name, LabelType.Chord ); } foreach (Note note in modelBar.notes) { newLabel( lineY(note.line), timeX(note.time, LabelType.Note), note.fret.ToString(), LabelType.Note ); } }