Exemplo n.º 1
0
        // Inputs are absolute note indices from beginning of song.
        public void DeleteNotesBetween(int minFrame, int maxFrame, bool preserveFx = false)
        {
            var patternIdxMin = Song.FindPatternInstanceIndex(minFrame, out var patternNoteIdxMin);
            var patternIdxMax = Song.FindPatternInstanceIndex(maxFrame, out var patternNoteIdxMax);

            if (patternIdxMin == patternIdxMax)
            {
                if (patternIdxMin < song.Length)
                {
                    var pattern = patternInstances[patternIdxMin];
                    if (pattern != null)
                    {
                        pattern.DeleteNotesBetween(patternNoteIdxMin, patternNoteIdxMax, preserveFx);
                        pattern.ClearLastValidNoteCache();
                    }
                }
            }
            else
            {
                for (int p = patternIdxMin; p <= patternIdxMax && p < song.Length; p++)
                {
                    var pattern = patternInstances[p];

                    if (pattern != null)
                    {
                        if (p == patternIdxMin)
                        {
                            pattern.DeleteNotesBetween(patternNoteIdxMin, Pattern.MaxLength, preserveFx);
                        }
                        else if (p == patternIdxMax)
                        {
                            pattern.DeleteNotesBetween(0, patternNoteIdxMax, preserveFx);
                        }
                        else
                        {
                            if (preserveFx)
                            {
                                pattern.DeleteNotesBetween(0, Pattern.MaxLength, true);
                            }
                            else
                            {
                                pattern.Notes.Clear();
                            }
                        }

                        pattern.ClearLastValidNoteCache();
                    }
                }
            }
        }