private static string GetBeamType(Note symbol, NoteBeamType beamType)
        {
            switch (beamType)
            {
            case NoteBeamType.BackwardHook:
                return("backward hook");

            case NoteBeamType.ForwardHook:
                return("forward hook");

            case NoteBeamType.Continue:
                return("continue");

            case NoteBeamType.End:
                return("end");

            case NoteBeamType.Single:
                return("single");

            case NoteBeamType.Start:
                return("begin");

            default:
                throw new ScoreException(symbol, $"Unsupported beam type {beamType}.");
            }
        }
Example #2
0
        private NoteBeamType GetNoteBeamType(Note currentNote, int index)
        {
            NoteBeamType noteBeamType = NoteBeamType.Single; // default

            if (staff.Symbols.Count > index + 1)
            {
                Model.StaffSymbol nextSymbol = staff.Symbols[index + 1];

                if (nextSymbol is Model.Note)
                {
                    var nextNote = nextSymbol as Model.Note;

                    if (continueNoteBeam)
                    {
                        if (amountNoteBeams >= 3)
                        {
                            noteBeamType     = NoteBeamType.End;
                            amountNoteBeams  = 1;
                            continueNoteBeam = false;
                        }
                        else if (currentNote.Duration == StaffSymbolDuration.EIGTH && nextNote.Duration == StaffSymbolDuration.EIGTH &&
                                 amountEights + GetDuration(currentNote.Duration, currentNote.NumberOfDots) + GetDuration(nextNote.Duration, nextNote.NumberOfDots) < maxAmountOfEights)
                        {
                            noteBeamType = NoteBeamType.Continue;
                            amountNoteBeams++;
                        }
                        else
                        {
                            noteBeamType     = NoteBeamType.End;
                            amountNoteBeams  = 1;
                            continueNoteBeam = false;
                        }
                    }
                    else
                    {
                        if (currentNote.Duration == StaffSymbolDuration.EIGTH && nextNote.Duration == StaffSymbolDuration.EIGTH &&
                            StaffSymbolFactory.Instance.GetIntDuration(currentNote.Duration) > 4) // everything with a shorter duration than quarter notes uses beams, quarter and higher don't
                        {
                            noteBeamType     = NoteBeamType.Start;
                            continueNoteBeam = true;
                        }
                    }
                }
                else if (continueNoteBeam)
                {
                    noteBeamType     = NoteBeamType.End;
                    amountNoteBeams  = 1;
                    continueNoteBeam = false;
                }
            }

            return(noteBeamType);
        }
Example #3
0
        public void Visit(Note note, int index)
        {
            bool chord = false;    // IsChord

            if (!continueNoteBeam) // TODO doesn't look very pretty
            {
                if (note.Octave - 1 >= 5)
                {
                    noteStemDirection = NoteStemDirection.Down;
                }
                else
                {
                    noteStemDirection = NoteStemDirection.Up;
                }
            }

            //NoteTieType noteTieType = NoteTieType.None;
            NoteBeamType noteBeamType = GetNoteBeamType(note, index);

            incipitViewer.AddMusicalSymbol(new PSAMControlLibrary.Note(
                                               note.StepString,
                                               note.Alter,
                                               note.Octave - 1,
                                               StaffSymbolFactory.Instance.GetMusicalSymbolDuration(note.Duration),
                                               noteStemDirection,
                                               NoteTieType.None,
                                               new List <NoteBeamType>()
            {
                noteBeamType
            })
            {
                NumberOfDots   = note.NumberOfDots,
                IsChordElement = chord
            });

            amountEights += GetDuration(note.Duration, note.NumberOfDots);
        }