Exemplo n.º 1
0
        public bool FindNextNoteForSlide(int patternIdx, int noteIdx, int maxNotes, out int nextPatternIdx, out int nextNoteIdx)
        {
            nextPatternIdx = patternIdx;
            nextNoteIdx    = noteIdx;

            var noteCount     = 0;
            var patternLength = song.GetPatternLength(patternIdx);
            var pattern       = patternInstances[patternIdx];

            if (pattern.Notes.ContainsKey(noteIdx) &&
                pattern.Notes[noteIdx].HasCutDelay)
            {
                return(true);
            }

            for (var it = pattern.GetNoteIterator(noteIdx + 1, patternLength); !it.Done && noteCount < maxNotes; it.Next(), noteCount++)
            {
                var time = it.CurrentTime;
                var note = it.CurrentNote;
                if (note != null && (note.IsMusical || note.IsStop || note.HasCutDelay))
                {
                    nextPatternIdx = patternIdx;
                    nextNoteIdx    = time;
                    return(true);
                }
            }

            for (int p = patternIdx + 1; p < song.Length && noteCount < maxNotes; p++)
            {
                pattern = patternInstances[p];
                if (pattern != null && pattern.FirstValidNoteTime >= 0)
                {
                    nextPatternIdx = p;
                    nextNoteIdx    = noteCount + pattern.FirstValidNoteTime > maxNotes ? pattern.FirstValidNoteTime - (maxNotes - noteCount) : pattern.FirstValidNoteTime; // MATTT : Test this!
                    return(true);
                }
                else
                {
                    noteCount += song.GetPatternLength(p);
                }
            }

            // This mean we hit the end of the song.
            if (noteCount < maxNotes)
            {
                nextPatternIdx = song.Length;
                nextNoteIdx    = 0;
                return(true);
            }

            // Didnt find anything, just advance to the max note location and return false.
            song.AdvanceNumberOfNotes(maxNotes, ref nextPatternIdx, ref nextNoteIdx);

            return(false);
        }