예제 #1
0
파일: CVoice.cs 프로젝트: da-ka/Vocaluxe
        public bool AddLine(int startBeat)
        {
            int insPos = FindPreviousLine(startBeat);

            //Check for actual notes (startbeat may be lower than first note)
            while (insPos >= 0 && _Lines[insPos].NoteCount > 0 && _Lines[insPos].FirstNoteBeat > startBeat)
            {
                insPos--;
            }
            CSongLine line = new CSongLine {
                StartBeat = startBeat
            };

            if (insPos >= 0)
            {
                CSongLine prevLine = _Lines[insPos];
                //We already have a line break here
                if (prevLine.StartBeat == startBeat && (prevLine.NoteCount == 0 || prevLine.FirstNoteBeat == startBeat))
                {
                    return(false);
                }
                //Maybe we have to split the previous line
                while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
                {
                    //throw new Exception("This should not happen on song loading!");
                    line.AddNote(prevLine.LastNote);
                    prevLine.DeleteNote(prevLine.NoteCount - 1);
                }
            }
            _Lines.Insert(insPos + 1, line);
            return(true);
        }
예제 #2
0
파일: CVoice.cs 프로젝트: da-ka/Vocaluxe
        public bool AddNote(CSongNote note, bool updateTimings = true)
        {
            int lineIndex = FindPreviousLine(note.StartBeat);

            if (lineIndex + 1 < _Lines.Count && _Lines[lineIndex + 1].FirstNoteBeat < note.EndBeat) //First note in next line starts before this one ends
            {
                return(false);
            }
            if (lineIndex < 0)
            {
                //Note is before ALL lines
                if (_Lines.Count > 0)
                {
                    //Add to first line
                    if (!_Lines[0].AddNote(note))
                    {
                        return(false);
                    }
                }
                else
                {
                    var line = new CSongLine();
                    line.AddNote(note);
                    _Lines.Add(line);
                }
            }
            else
            {
                if (!_Lines[lineIndex].AddNote(note))
                {
                    return(false);
                }
            }
            if (updateTimings)
            {
                UpdateTimings();
            }
            return(true);
        }