Пример #1
0
        public static Barline CreateBarline(BarlineProperties bi)
        {
            ObjectFactory factory = new ObjectFactory();
            Barline       barline = factory.createBarline();

            //create an ending
            if (bi.EndingValue != "")
            {
                Ending ending = factory.createEnding();
                ending.setType(StartStopDiscontinue.fromValue(bi.EndingType));
                ending.setValue(bi.EndingValue);
                barline.setEnding(ending);
            }

            //create a repeat
            if (bi.RepeatTimes != "")
            {
                Repeat repeat = factory.createRepeat();
                repeat.setTimes(new BigInteger(bi.RepeatTimes));
                repeat.setDirection(BackwardForward.fromValue(bi.RepeatDirection));
                barline.setRepeat(repeat);
            }

            //set bar line location
            if (bi.Location != "")
            {
                barline.setLocation(RightLeftMiddle.fromValue(bi.Location));
            }

            return(barline);
        }
        /// <summary>
        /// Parse the barline information given and create an appropriate label that can be put onto a canvas.
        /// </summary>
        /// <param name="barline">The Barline information to parse</param>
        /// <param name="fontSize">The fontsize to use</param>
        /// <returns>Label that holds the barline</returns>
        public static FrameworkElement RenderBarline(Barline barline, double fontSize)
        {
            string barlineChar;
            switch (barline.barStyle.Value)
            {
                case BarStyle.regular:
                    barlineChar = Constants.Barlines.REGULAR;
                    break;
                case BarStyle.lightlight:
                    barlineChar = Constants.Barlines.LIGHT_LIGHT;
                    break;
                case BarStyle.lightheavy:
                    barlineChar = Constants.Barlines.LIGHT_HEAVY;
                    break;
                case BarStyle.heavylight:
                    barlineChar = Constants.Barlines.HEAVY_LIGHT;
                    break;
                case BarStyle.dashed:
                    barlineChar = Constants.Barlines.DASHED;
                    break;
                default:
                    barlineChar = Constants.Barlines.REGULAR;
                    break;
                //todo: remainder of barlines
            }

            FrameworkElement barlineLabel = WPFRendering.GetMusicalLabel(barlineChar, fontSize);
            WPFRendering.RecalculateSize(barlineLabel);
            return barlineLabel;
        }
        protected override void AddBarline(PlaineAndEasieBarlineTypes barlineType)
        {
            var barlineStyle = barlineType != PlaineAndEasieBarlineTypes.Single ? BarlineStyle.LightHeavy : BarlineStyle.Regular;
            var barline      = new Barline(barlineStyle);

            if (barlineType == PlaineAndEasieBarlineTypes.RepeatForward)
            {
                barline.RepeatSign = RepeatSignType.Forward;
            }
            else if (barlineType == PlaineAndEasieBarlineTypes.RepeatBackward)
            {
                barline.RepeatSign = RepeatSignType.Backward;
            }
            else if (barlineType == PlaineAndEasieBarlineTypes.RepeatBoth)
            {
                barline.RepeatSign = RepeatSignType.Backward;
            }

            output.FirstStaff.Add(barline);
            if (barlineType == PlaineAndEasieBarlineTypes.RepeatBoth)
            {
                output.FirstStaff.Add(new Barline {
                    RepeatSign = RepeatSignType.Forward
                });
            }
        }
Пример #4
0
        private void HandleRepeat()
        {
            _repeat           = (Repeat)_element;
            _repeatGroup      = 0;
            _repeats          = _repeat.Repeats;
            _isCreatingRepeat = true;
            HandleTime(_repeat.TimeSignature);

            // Check and remove previous bar if it exists
            var index = _symbols.Count - 1;

            if (_symbols[index].Type is MusicalSymbolType.Barline)
            {
                _symbols.RemoveAt(_symbols.Count - 1);
            }

            // Add bar for repeat
            var barLine = new Barline {
                RepeatSign = RepeatSignType.Forward
            };

            _symbols.Add(barLine);

            // Repeat block
            RunActions(_repeat.Elements);

            _isCreatingRepeat = false;
        }
Пример #5
0
        private void AddRepeat(Repeat repeat)
        {
            AddSymbolGroup(repeat.Alternatives.First());

            if (_symbols.Last() is Barline)
            {
                _symbols.RemoveAt(_symbols.Count - 1);
            }

            if (repeat.Alternatives.Count > 1)
            {
                var index = _symbols.FindLastIndex(b => b is Barline);
                _symbols[index] = new Barline {
                    AlternateRepeatGroup = 1
                };
                _symbols.Add(new Barline()
                {
                    RepeatSign = RepeatSignType.Backward, AlternateRepeatGroup = 2
                });

                foreach (var alt in repeat.Alternatives.GetRange(1, repeat.Alternatives.Count - 1))
                {
                    AddSymbolGroup(alt);
                }
            }
            else
            {
                _symbols.Add(new Barline()
                {
                    RepeatSign = RepeatSignType.Backward
                });
            }
        }
Пример #6
0
        private void HandleBar()
        {
            var barLine = new Barline();

            if (_isCreatingAlternative)
            {
                barLine.AlternateRepeatGroup = _repeatGroup;
            }
            _symbols.Add(barLine);
        }
 public void ProcessToken(Barline barLine)
 {
     currentBarsOnLine++;
     lilypondText.Append("| ");
     if (currentBarsOnLine >= Constants.Lilypond.BARS_PER_LINE)
     {
         currentBarsOnLine = 0;
         lilypondText.AppendLine();
     }
 }
Пример #8
0
        public static void barlineToABC(StreamWriter file, Barline barline)
        {
            if (barline.Location != string.Empty)
            {
                if (barline.isSetStyle)
                {
                    if (barline.isSetRepeat && barline.Repeat == "backward")
                    {
                        file.Write(" :");
                    }
                    if (barline.isSetStyle)
                    {
                        switch (barline.Style)
                        {
                        case "light-heavy":
                            file.Write("|]");
                            break;

                        case "heavy-light":
                            file.Write("[|");
                            break;

                        case "light-light":
                            file.Write("||");
                            break;

                        case "dotted":
                            file.Write(".|");
                            break;

                        default:
                            file.Write("|");
                            break;
                        }
                    }
                }
                if (barline.Location == "left")
                {
                    if (barline.isSetRepeat && barline.Repeat == "forward")
                    {
                        file.Write(":");
                    }
                    if (barline.isSetEnding)
                    {
                        file.Write("[%s ", barline.Ending.Number);
                    }
                }
                if (barline.Location == "right" && barline.isSetEnding && barline.Ending.Type == "discontinue")
                {
                    file.Write(" |");
                }
            }
        }
Пример #9
0
        private void DoBarline()
        {
            if (!ShouldDoBarline())
            {
                return;
            }
            Barline br = new Barline();

            br.RepeatSign = RepeatSignType.None;
            barlinecount  = 0;
            symbols.Add(br);
        }
        public override void ParseElement(MusicXmlParserState state, Staff staff, XElement element)
        {
            var b = new Barline();

            element.IfAttribute("location").HasValue("left")
            .Then(() => b.Location     = HorizontalPlacement.Left)
            .Otherwise(r => b.Location = HorizontalPlacement.Right);

            element.IfElement("bar-style").HasValue("light-heavy").Then(() => b.Style = BarlineStyle.LightHeavy);
            element.IfElement("bar-style").HasValue("none").Then(() => b.Style        = BarlineStyle.None);
            element.IfElement("bar-style").HasValue("dashed").Then(() => b.Style      = BarlineStyle.Dashed);
            var repeatAttribute = element.Elements().FirstOrDefault(e => e.Name == "repeat");
            var attribute       = repeatAttribute?.Attributes().FirstOrDefault(a => a.Name == "direction");

            bool add = false;

            if (attribute != null)
            {
                if (attribute.Value == "forward")
                {
                    b.RepeatSign = RepeatSignType.Forward;
                }
                else if (attribute.Value == "backward")
                {
                    b.RepeatSign = RepeatSignType.Backward;
                    state.BarlineAlreadyAdded = true;
                }
                add = true;
            }
            else if (b.Style != BarlineStyle.Regular)
            {
                state.BarlineAlreadyAdded = true;
                add = true;
            }

            if (add)
            {
                if (staff.Part?.Staves.Any() ?? false)  //If part contains many staves, add to all staves
                {
                    foreach (var s in staff.Part.Staves)
                    {
                        s.Elements.Add(b);
                    }
                }
                else
                {
                    staff.Elements.Add(b);
                }
            }
        }
Пример #11
0
        public void DoRepeat()
        {
            DomainModel.BarLine br = (DomainModel.BarLine)currentNote;

            Barline b = new Barline();


            if (br.Type == BarLine.TYPE.REPEAT)
            {
                int     alt      = 1;
                Barline startAlt = new Barline();
                startAlt.AlternateRepeatGroup = alt;
                symbols.Add(startAlt);

                for (int i = 0; i < br.Alternatives.Count; i++)
                {
                    Symbol temp = br.Alternatives[i];
                    while (temp != null)
                    {
                        DomainModel.Note        cr = (DomainModel.Note)temp;
                        PSAMControlLibrary.Note n  = new PSAMControlLibrary.Note(cr.Pitch.ToUpper(), 0, 2 + cr.Octave, durriation[cr.Duration],
                                                                                 NoteStemDirection.Up, NoteTieType.None,
                                                                                 new List <NoteBeamType>()
                        {
                            NoteBeamType.Single
                        });
                        symbols.Add(n);
                        temp = temp.nextSymbol;
                    }

                    if (i == 0)
                    {
                        alt++;
                        Barline blt = new Barline();
                        blt.RepeatSign           = RepeatSignType.Backward;
                        blt.AlternateRepeatGroup = alt;
                        symbols.Add(blt);

                        continue;
                    }
                }
                return;
            }
            b.RepeatSign = reapeatType[br.Type];
            symbols.Add(b);
            barlinecount = 0;
        }
Пример #12
0
        // Moves the next barline to the position immediately after the specified element. If there are no more barlines on
        // the staff, creates a new one.
        private Barline moveOrAddBarlineAfter(MusicalSymbol item)
        {
            var     elems        = item.Staff.Elements;
            int     itemPosition = elems.IndexOf(item);
            Barline bar          = (Barline)elems.FirstOrDefault(b => elems.IndexOf(b) > itemPosition && b.GetType() == typeof(Barline));

            if (bar == null)
            {
                bar = new Barline();
            }
            else
            {
                item.Staff.Elements.Remove(bar);
            }
            item.Staff.Elements.Insert(itemPosition + 1, bar);
            return(bar);
        }
Пример #13
0
        public override void ParseElement(MusicXmlParserState state, Staff staff, XElement element)
        {
            var b = new Barline();

            element.IfAttribute("location").HasValue("left")
            .Then(() => b.Location      = HorizontalPlacement.Left)
            .Otherwise(() => b.Location = HorizontalPlacement.Right);

            element.IfElement("bar-style").HasValue("light-heavy").Then(() => b.Style = BarlineStyle.LightHeavy);

            foreach (XElement barlineAttribute in element.Elements())
            {
                if (barlineAttribute.Name == "repeat")
                {
                    var attribute = barlineAttribute.Attribute("direction");
                    if (attribute != null)
                    {
                        if (attribute.Value == "forward")
                        {
                            b.RepeatSign = RepeatSignType.Forward;
                        }
                        else if (attribute.Value == "backward")
                        {
                            b.RepeatSign = RepeatSignType.Backward;
                            state.BarlineAlreadyAdded = true;
                        }

                        //Usuń pojedynczą kreskę taktową, jeśli już taka została dodana:
                        //Barline existingBarline = staff.Elements.LastOrDefault() as Barline;
                        //if (existingBarline != null) staff.Elements.Remove(existingBarline);

                        if (staff.Part != null && staff.Part.Staves.Any())  //If part contains many staves, add to all staves
                        {
                            foreach (var s in staff.Part.Staves)
                            {
                                s.Elements.Add(b);
                            }
                        }
                        else
                        {
                            staff.Elements.Add(b);
                        }
                    }
                }
            }
        }
Пример #14
0
        private void CheckEndingRepeat()
        {
            if (_repeat == null || _isCreatingAlternative || _isCreatingRepeat)
            {
                return;
            }

            // Closing bar repeat
            var barLineEnd = new Barline {
                RepeatSign = RepeatSignType.Backward
            };

            _symbols.Add(barLineEnd);

            _repeat      = null;
            _repeats     = 0;
            _repeatGroup = 0;
        }
Пример #15
0
        private Barline GetBarline(XmlNode barlineNode)
        {
            var barline = new Barline();

            var styleNode = barlineNode.SelectSingleNode("barline-style");

            if (styleNode != null)
            {
                barline.Style = styleNode.InnerText;
            }

            string location = barlineNode.Attributes["location"].ToString();

            if (location != string.Empty)
            {
                barline.Location = location;
            }

            var ending = barlineNode.SelectSingleNode("ending");

            if (ending != null)
            {
                string endingType = ending.Attributes["type"].ToString();
                barline.Ending.Type = endingType;
                barline.isSetEnding = true;
            }

            var repeat = barlineNode.SelectSingleNode("repeat");

            if (repeat != null)
            {
                string direction = repeat.Attributes["direction"].ToString();
                barline.isSetRepeat = true;
                if (direction != string.Empty)
                {
                    barline.Repeat = direction;
                }
            }

            return(barline);
        }
Пример #16
0
 //Read the barline
 public static BarlineProperties ReadBarline(int barnumber, ScorePartwise.Part.Measure measure)
 {
     if (getbarindex(barnumber, measure) != -1)
     {
         Barline           barline = (Barline)measure.getNoteOrBackupOrForward().get(getbarindex(barnumber, measure));
         BarlineProperties barprop = new BarlineProperties();
         if (barline.getEnding() != null)
         {
             barprop.EndingType  = barline.getEnding().getType().value();
             barprop.EndingValue = barline.getEnding().getValue();
         }
         if (barline.getRepeat() != null)
         {
             barprop.RepeatTimes     = barline.getRepeat().getTimes().intValue().ToString();
             barprop.RepeatDirection = barline.getRepeat().getDirection().value();
         }
         barprop.Location = barline.getLocation().value();
         return(barprop);
     }
     return(null);
 }
        public MidiBarLineEvent(MidiEvent barLineEvent, INote previousNote, ref bool startedNoteIsClosed, ref int previousNoteAbsoluteTicks, int division, TimeSignature timeSignature,
                                ref double percentageOfBarReached)
        {
            if (startedNoteIsClosed)
            {
                return;
            }

            // Finish the previous note with the length.
            SetNoteLength(previousNoteAbsoluteTicks,
                          barLineEvent.AbsoluteTicks, division, timeSignature.BeatUnit,
                          timeSignature.BeatsPerBar, out double percentageOfBar, previousNote);
            previousNoteAbsoluteTicks = barLineEvent.AbsoluteTicks;

            percentageOfBarReached += percentageOfBar;
            if (percentageOfBarReached >= 1)
            {
                BarLine = new Barline();
                percentageOfBarReached -= 1;
            }
            startedNoteIsClosed = true;
        }
Пример #18
0
        /// <summary>
        /// Parse the barline information given and create an appropriate label that can be put onto a canvas.
        /// </summary>
        /// <param name="barline">The Barline information to parse</param>
        /// <param name="fontSize">The fontsize to use</param>
        /// <returns>Label that holds the barline</returns>
        public static FrameworkElement RenderBarline(Barline barline, double fontSize)
        {
            string barlineChar;

            switch (barline.barStyle.Value)
            {
            case BarStyle.regular:
                barlineChar = Constants.Barlines.REGULAR;
                break;

            case BarStyle.lightlight:
                barlineChar = Constants.Barlines.LIGHT_LIGHT;
                break;

            case BarStyle.lightheavy:
                barlineChar = Constants.Barlines.LIGHT_HEAVY;
                break;

            case BarStyle.heavylight:
                barlineChar = Constants.Barlines.HEAVY_LIGHT;
                break;

            case BarStyle.dashed:
                barlineChar = Constants.Barlines.DASHED;
                break;

            default:
                barlineChar = Constants.Barlines.REGULAR;
                break;
                //todo: remainder of barlines
            }

            FrameworkElement barlineLabel = WPFRendering.GetMusicalLabel(barlineChar, fontSize);

            WPFRendering.RecalculateSize(barlineLabel);
            return(barlineLabel);
        }
Пример #19
0
        public void ProcessToken(Barline barline)
        {
            var staffBarline = new PSAMControlLibrary.Barline();

            _symbols.Add(staffBarline);
        }
 public void ProcessToken(Barline barLine)
 {
     // do nothing
 }
Пример #21
0
        private void CreateAlternativesMusicBlock()
        {
            _currentAlternative++;
            var musicBlock = (MusicBlock)_element;

            HandleTime(musicBlock.TimeSignature);

            // Get difference in octaves
            var differenceOctaves = 0;

            musicBlock.Elements.ForEach(e =>
            {
                if (!(e is MusicElement))
                {
                    return;
                }

                var musicElement   = (MusicElement)e;
                differenceOctaves += musicElement.Octaves;
            });

            // Check runs
            var runs = 1;

            if (_currentAlternative == 1)
            {
                runs = 1 + _repeats - _alternatives;
            }

            // Do runs
            for (var i = 1; i <= runs; i++)
            {
                // Create repeat group
                _repeatGroup++;

                // Opening bar
                if (_symbols.Last() is Barline)
                {
                    var bar = (Barline)_symbols.Last();
                    bar.AlternateRepeatGroup = _repeatGroup;
                }
                else
                {
                    var barLine = new Barline {
                        AlternateRepeatGroup = _repeatGroup
                    };
                    _symbols.Add(barLine);
                }

                _remembedFirstOctaveAlternative = true;

                // Elements in alternative
                RunActions(musicBlock.Elements);

                if (runs > 1 && i < runs)
                {
                    _mustAlterOctave = true;
                    _alterOctave     = _firstOctaveAlternative;
                }

                // Closing bar repeat if needed
                if (_repeatGroup < _repeats)
                {
                    var barLineEnd = new Barline {
                        RepeatSign = RepeatSignType.Backward
                    };
                    _symbols.Add(barLineEnd);
                }
                else
                {
                    var barLineEnd = new Barline {
                        AlternateRepeatGroup = _repeatGroup
                    };
                    _symbols.Add(barLineEnd);
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Render a measure onto a canvas
        /// </summary>
        /// <param name="measure">The measure to render</param>
        /// <param name="staff">The staff being rendered for</param>
        /// <returns>A Framework Element with the measure rendered onto it</returns>
        public static Panel RenderMeasure(ScorePartwisePartMeasure measure, int staff, double fontSize) //todo: not return canvas
        {
            //todo: stack/queue for tie
            //todo: stack/queue for slur
            //todo: stack/queue for beam

            //todo: maybe approach this by doing all staves in render measure?

            double left = 0; //todo: padding/margin
            double top  = 0; //todo: padding/margin

            ICollection <object> itemList = measure.Items;
            FrameworkElement     element  = null;
            Panel grid = WPFRendering.CreateAutoSizingGrid();

            grid.Margin = new Thickness(50, 50, 0, 0); //todo: proper margin

            //todo: render each item
            for (int i = 0; i < itemList.Count; i++)
            {
                object obj  = itemList.ElementAt(i);
                Type   type = obj.GetType();


                if (type == typeof(Attributes))
                {
                    Attributes attributes = (Attributes)obj;
                    element = RenderAttributes(attributes, staff, fontSize);
                }
                else if (type == typeof(Note))
                {
                    //todo: may need to use attributes from previous measure to figure out where to render
                    Note note = (Note)obj;
                    element = RenderNoteOrRest(note, fontSize);
                }
                else if (type == typeof(Barline))
                {
                    Barline barline = (Barline)obj;
                    element = RenderBarline(barline, fontSize);
                }
                else if (type == typeof(Print))
                {
                    //todo: complete this section
                    element = new Label();
                }
                else if (type == typeof(Direction))
                {
                    //todo: complete this section
                    element = new Label();
                }

                if (element != null)
                {
                    element.Margin = new Thickness(left, top, 0, 0);
                    grid.Children.Add(element);
                    left += element.ActualWidth + 0; //todo: margin
                }
                else
                {
                    throw new NullMeasureElementException("Null element: " + obj.GetType() + "\n");
                }
            }

            //todo: render multiple staves for multi-part instruments etc
            //      This should be as simple as rendering a second staff then putting the note onto that staff as required
            //      Then joining those two staves via a wrapper container

            element = RenderStaff(Constants.Colors.DEFAULT_NOTE_COLOR, left, fontSize);
            grid.Children.Add(element);

            WPFRendering.RecalculateSize(grid);
            return(grid);
        }
Пример #23
0
 public bool Equals(Barline obj)
 {
     return(obj != null);
 }
Пример #24
0
        /// <summary>
        /// Adds a barline to the current measure if needed, and breaks the last note of the measure if it
        /// exceeds the allowed beats/measure, inserting the remainder into the next measure. Then recursively calls
        /// itself on subsequent measures until it hits a measure that does not overflow.
        /// </summary>
        /// <param name="m"></param>
        /// <param name="ts"></param>
        internal void fitMeasure(Measure m, TimeSignature ts) // Still need to add support for deletion
        {
            bool  nextMeasureChanged = false;
            Staff staff        = m.Staff;
            int   measureIndex = staff.Measures.IndexOf(m);


            foreach (MusicalSymbol item in m.Elements)
            {
                // If new time signature, update
                if (item.GetType() == typeof(TimeSignature))
                {
                    ts = (TimeSignature)item;
                }

                // Make sure that any cleffs and signatures are at the beginning of the measure, before notes and rests
                if (item.GetType() == typeof(TimeSignature) || item.GetType() == typeof(Key) || item.GetType() == typeof(Clef))
                {
                    NoteOrRest firstBeat = getFirstBeat(m);
                    if (m.Elements.IndexOf(firstBeat) < m.Elements.IndexOf(item))
                    {
                        swapPositions(staff, item, firstBeat);
                    }
                }
            }

            // While the current measure is not full and is not the end of the song, steal the first beat from the next measure
            // ****VERIFY THIS CODE ONCE NOTE DELETION IS IN PLACE****
            while (getDurations(m).Sum() < ts.WholeNoteCapacity &&
                   m.Number < staff.Measures.Count &&
                   getFirstBeat(getNextMeasure(m)) != null)
            {
                Measure    next = getNextMeasure(m);
                NoteOrRest nr   = getFirstBeat(next);
                next.Elements.Remove(nr);
                m.Elements.Add(nr);     // This note might be longer than we have room for, but the next loop will take care of it
                nextMeasureChanged = true;
            }

            // While the current measure has too many beats, push the extra into the next measure
            while (getDurations(m).Sum() > ts.WholeNoteCapacity)
            {
                double     overage           = getOverage(m, ts);                                                              // How much the content of the current measure exceeds its alloted time
                NoteOrRest lastNoteOrRest    = (NoteOrRest)m.Elements.Last(e => e.GetType().IsSubclassOf(typeof(NoteOrRest))); // Last note or rest in measure
                double     lastDurationValue = lastNoteOrRest.Duration.ToDouble();                                             // Value of last note or rest in measure
                int        lastItemIndex     = staff.Elements.IndexOf(lastNoteOrRest);                                         // Index of last note or rest in the measure
                NoteOrRest itemToMove        = null;                                                                           // The last note or portion thereof that doesn't fit in the current measure

                // If the overage is because the last note is too big, break it into two notes
                if (lastDurationValue > overage)
                {
                    NoteOrRest itemInPlace;     // Shortened version of lastNoteOrRest that fits in currrent measure
                    if (lastNoteOrRest.GetType() == typeof(Note))
                    {
                        itemInPlace = new Note(((Note)lastNoteOrRest).Pitch, toRhythmicDuration(lastDurationValue - overage));
                        itemToMove  = new Note(((Note)lastNoteOrRest).Pitch, toRhythmicDuration(overage)); // Remaining note value
                    }
                    else
                    {
                        itemInPlace = new Rest(toRhythmicDuration(lastDurationValue - overage));
                        itemToMove  = new Rest(toRhythmicDuration(overage));
                    }
                    // Have to remove lastNoteOrRest from both the staff and the measure
                    staff.Elements.Remove(lastNoteOrRest);
                    m.Elements.Remove(lastNoteOrRest);
                    // Replace with shortened version, automatically populates to measure when adding
                    staff.Elements.Insert(lastItemIndex, itemInPlace);
                }
                else
                {
                    itemToMove = lastNoteOrRest;
                    staff.Elements.Remove(lastNoteOrRest);
                    m.Elements.Remove(lastNoteOrRest);
                    lastItemIndex--;
                }

                // Refresh the updated measure in the staff.measures collection
                Barline bar = moveOrAddBarlineAfter(staff.Elements[lastItemIndex]);

                // Add itemToMove after the barline
                staff.Elements.Insert(lastItemIndex + 2, itemToMove);

                // Add it to the measure as well if it's not already there
                Measure nextMeasure = getNextMeasure(m);
                if (!nextMeasure.Elements.Contains(itemToMove))
                {
                    nextMeasure.Elements.Insert(0, itemToMove);
                }

                // set the flag to check the next measure
                nextMeasureChanged = true;
            }

            // If there are changes to the next measure, fix it.
            if (nextMeasureChanged)
            {
                fitMeasure(getNextMeasure(m), ts);
            }
        }
Пример #25
0
 public void ProcessToken(Barline barLine)
 {
     barPercentage = 0;
 }
Пример #26
0
        public void BuildSequence_checkConversion()
        {
            foreach (Sequence testSequence in testList)
            {
                foreach (ObjectInSequence obj in testSequence.ObjectsInSequence)
                {
                    Assert.AreNotEqual(obj.Evidence, Evidence.Invalid);

                    switch (obj.Type)
                    {
                    case ObjectType.Accidental:
                        Accidental accid = (Accidental)obj;
                        Assert.AreNotEqual(Model.AccidType.Null, accid.AccidentalType);
                        break;

                    case ObjectType.Barline:
                        Barline bl = (Barline)obj;
                        Assert.AreNotEqual(Model.BarlineType.Null, bl.BarlineType);
                        break;

                    case ObjectType.Clef:
                        Model.Clef clef = (Model.Clef)obj;
                        Assert.AreNotEqual(Model.Clefshape.Null, clef.Shape);
                        break;

                    case ObjectType.KeyAccidental:
                        KeyAccidental keyacc = (KeyAccidental)obj;
                        Assert.AreNotEqual(Model.AccidType.Null, keyacc.AccidentalType);
                        break;

                    case ObjectType.Mensur:
                        Model.Mensur mens = (Model.Mensur)obj;
                        Assert.AreNotEqual(0, mens.Tempus);
                        break;

                    case ObjectType.Note:
                        Model.Note note = (Model.Note)obj;
                        Assert.AreNotEqual(0, note.WrittenPitch);
                        Assert.AreNotEqual(Model.Duration.Null, note.Duration);
                        break;

                    case ObjectType.Proportion:
                        Proportion prop = (Proportion)obj;
                        Assert.AreNotEqual(0, prop.Num);
                        Assert.AreNotEqual(0, prop.Numbase);
                        break;

                    case ObjectType.Rest:
                        Model.Rest rest = (Model.Rest)obj;
                        Assert.AreNotEqual(Model.Duration.Null, rest.Duration);
                        break;

                    case ObjectType.Custos:
                        break;

                    case ObjectType.Dot:
                        break;

                    case ObjectType.Gap:
                        Model.Gap gap = (Model.Gap)obj;
                        Assert.AreNotEqual(Model.GapType.Null, gap.GapType);
                        break;

                    default:
                        Assert.Fail($"Test of {obj.Type} {obj.ID} failed!");
                        break;
                    }
                }
            }
        }
Пример #27
0
 public abstract void AddSymbol(Barline barLine);