Пример #1
0
 private void InsertInvisibleClefChanges(Voice voice, List <ClefChangeDef> clefChangeDefs)
 {
     foreach (ClefChangeDef ccd in clefChangeDefs)
     {
         ClefChangeSymbol invisibleClefChangeSymbol = new ClefChangeSymbol(voice, ccd.ClefType, _pageFormat.CautionaryNoteheadsFontHeight, ccd.MsPosition);
         invisibleClefChangeSymbol.IsVisible = false;
         InsertInvisibleClefChangeInNoteObjects(voice, invisibleClefChangeSymbol);
     }
 }
Пример #2
0
        public override NoteObject GetNoteObject(Voice voice, IUniqueDef iud, bool firstDefInVoice,
                                                 ref byte currentVelocity, float musicFontHeight)
        {
            NoteObject         noteObject         = null;
            CautionaryChordDef cautionaryChordDef = iud as CautionaryChordDef;
            MidiChordDef       midiChordDef       = iud as MidiChordDef;
            InputChordDef      inputChordDef      = iud as InputChordDef;
            RestDef            restDef            = iud as RestDef;
            ClefChangeDef      clefChangeDef      = iud as ClefChangeDef;

            PageFormat pageFormat              = voice.Staff.SVGSystem.Score.PageFormat;
            float      cautionaryFontHeight    = pageFormat.CautionaryNoteheadsFontHeight;
            int        minimumCrotchetDuration = pageFormat.MinimumCrotchetDuration;

            if (cautionaryChordDef != null && firstDefInVoice)
            {
                CautionaryChordSymbol cautionaryChordSymbol = new CautionaryChordSymbol(voice, cautionaryChordDef, cautionaryFontHeight);
                noteObject = cautionaryChordSymbol;
            }
            else if (midiChordDef != null)
            {
                OutputChordSymbol outputChordSymbol = new OutputChordSymbol(voice, midiChordDef, minimumCrotchetDuration, musicFontHeight);

                if (midiChordDef.MidiVelocity != currentVelocity)
                {
                    outputChordSymbol.AddDynamic(midiChordDef.MidiVelocity, currentVelocity);
                    currentVelocity = midiChordDef.MidiVelocity;
                }
                noteObject = outputChordSymbol;
            }
            else if (inputChordDef != null)
            {
                InputChordSymbol inputChordSymbol = new InputChordSymbol(voice, inputChordDef, minimumCrotchetDuration, musicFontHeight);
                noteObject = inputChordSymbol;
            }
            else if (restDef != null)
            {
                RestSymbol restSymbol = new RestSymbol(voice, iud, minimumCrotchetDuration, musicFontHeight);
                noteObject = restSymbol;
            }
            else if (clefChangeDef != null)
            {
                ClefChangeSymbol clefChangeSymbol = new ClefChangeSymbol(voice, clefChangeDef.ClefType, cautionaryFontHeight, ((IUniqueDef)iud).MsPosition);
                noteObject = clefChangeSymbol;
            }

            return(noteObject);
        }
Пример #3
0
        private string FindClefTypeAtEndOfStaff1(Voice staff1voice0)
        {
            ClefSymbol mainStaff1Clef = staff1voice0.NoteObjects[0] as ClefSymbol;

            Debug.Assert(mainStaff1Clef != null);

            string clefTypeAtEndOfStaff1 = mainStaff1Clef.ClefType;

            foreach (NoteObject noteObject in staff1voice0.NoteObjects)
            {
                ClefChangeSymbol ccs = noteObject as ClefChangeSymbol;
                if (ccs != null)
                {
                    clefTypeAtEndOfStaff1 = ccs.ClefType;
                }
            }
            return(clefTypeAtEndOfStaff1);
        }
Пример #4
0
        private void InsertInvisibleClefChangeInNoteObjects(Voice voice, ClefChangeSymbol invisibleClefChangeSymbol)
        {
            Debug.Assert(!(voice.NoteObjects[voice.NoteObjects.Count - 1] is Barline));

            int msPos = invisibleClefChangeSymbol.MsPosition;
            List <DurationSymbol> durationSymbols = new List <DurationSymbol>();

            foreach (DurationSymbol durationSymbol in voice.DurationSymbols)
            {
                durationSymbols.Add(durationSymbol);
            }

            Debug.Assert(durationSymbols.Count > 0);

            if (msPos <= durationSymbols[0].MsPosition)
            {
                InsertBeforeDS(voice.NoteObjects, durationSymbols[0], invisibleClefChangeSymbol);
            }
            else if (msPos > durationSymbols[durationSymbols.Count - 1].MsPosition)
            {
                // the noteObjects do not yet have a final barline (see Debug.Assert() above)
                voice.NoteObjects.Add(invisibleClefChangeSymbol);
            }
            else
            {
                Debug.Assert(durationSymbols.Count > 1);
                for (int i = 1; i < durationSymbols.Count; ++i)
                {
                    if (durationSymbols[i - 1].MsPosition < msPos && durationSymbols[i].MsPosition >= msPos)
                    {
                        InsertBeforeDS(voice.NoteObjects, durationSymbols[i], invisibleClefChangeSymbol);
                        break;
                    }
                }
            }
        }
Пример #5
0
        public override NoteObject GetNoteObject(Voice voice, int absMsPosition, IUniqueDef iud, bool firstDefInVoice,
            ref byte currentVelocity, float musicFontHeight)
        {
            NoteObject noteObject = null;
            CautionaryChordDef cautionaryChordDef = iud as CautionaryChordDef;
            MidiChordDef midiChordDef = iud as MidiChordDef;
            InputChordDef inputChordDef = iud as InputChordDef;
            RestDef restDef = iud as RestDef;
            ClefChangeDef clefChangeDef = iud as ClefChangeDef;

            PageFormat pageFormat = voice.Staff.SVGSystem.Score.PageFormat;
            float cautionaryFontHeight = pageFormat.CautionaryNoteheadsFontHeight;
            int minimumCrotchetDuration = pageFormat.MinimumCrotchetDuration;

            if(cautionaryChordDef != null && firstDefInVoice)
            {
                if(cautionaryChordDef.NotatedMidiVelocities != null)
                {
                    CautionaryOutputChordSymbol cautionaryOutputChordSymbol = new CautionaryOutputChordSymbol(voice, cautionaryChordDef, absMsPosition, cautionaryFontHeight);
                    noteObject = cautionaryOutputChordSymbol;
                }
                else
                {
                    CautionaryInputChordSymbol cautionaryInputChordSymbol = new CautionaryInputChordSymbol(voice, cautionaryChordDef, absMsPosition, cautionaryFontHeight);
                    noteObject = cautionaryInputChordSymbol;

                }
            }
            else if(midiChordDef != null)
            {
                OutputChordSymbol outputChordSymbol = new OutputChordSymbol(voice, midiChordDef, absMsPosition, minimumCrotchetDuration, musicFontHeight);

                if(this._coloredVelocities == true)
                {
                    outputChordSymbol.SetNoteheadColors();
                }
                else if(midiChordDef.NotatedMidiVelocities[0] != currentVelocity)
                {
                    outputChordSymbol.AddDynamic(midiChordDef.NotatedMidiVelocities[0], currentVelocity);
                    currentVelocity = midiChordDef.NotatedMidiVelocities[0];
                }
                noteObject = outputChordSymbol;
            }
            else if(inputChordDef != null)
            {
                InputChordSymbol inputChordSymbol = new InputChordSymbol(voice, inputChordDef, absMsPosition, minimumCrotchetDuration, musicFontHeight);
                noteObject = inputChordSymbol;
            }
            else if(restDef != null)
            {
                RestSymbol restSymbol = new RestSymbol(voice, iud, absMsPosition, minimumCrotchetDuration, musicFontHeight);
                noteObject = restSymbol;
            }
            else if(clefChangeDef != null)
            {
                ClefChangeSymbol clefChangeSymbol = new ClefChangeSymbol(voice, clefChangeDef.ClefType, absMsPosition, cautionaryFontHeight);
                noteObject = clefChangeSymbol;
            }

            return noteObject;
        }
Пример #6
0
 private void InsertInvisibleClefChanges(Voice voice, List<ClefChangeDef> clefChangeDefs)
 {
     foreach(ClefChangeDef ccd in clefChangeDefs)
     {
         ClefChangeSymbol invisibleClefChangeSymbol = new ClefChangeSymbol(voice, ccd.ClefType, _pageFormat.CautionaryNoteheadsFontHeight, ccd.MsPosition);
         invisibleClefChangeSymbol.IsVisible = false;
         InsertInvisibleClefChangeInNoteObjects(voice, invisibleClefChangeSymbol);
     }
 }
Пример #7
0
        private void InsertInvisibleClefChangeInNoteObjects(Voice voice, ClefChangeSymbol invisibleClefChangeSymbol)
        {
            Debug.Assert(!(voice.NoteObjects[voice.NoteObjects.Count - 1] is Barline));

            int msPos = invisibleClefChangeSymbol.MsPosition;
            List<DurationSymbol> durationSymbols = new List<DurationSymbol>();
            foreach(DurationSymbol durationSymbol in voice.DurationSymbols)
            {
                durationSymbols.Add(durationSymbol);
            }

            Debug.Assert(durationSymbols.Count > 0);

            if(msPos <= durationSymbols[0].MsPosition)
            {
                InsertBeforeDS(voice.NoteObjects, durationSymbols[0], invisibleClefChangeSymbol);
            }
            else if(msPos > durationSymbols[durationSymbols.Count - 1].MsPosition)
            {
                // the noteObjects do not yet have a final barline (see Debug.Assert() above)
                voice.NoteObjects.Add(invisibleClefChangeSymbol);
            }
            else
            {
                Debug.Assert(durationSymbols.Count > 1);
                for(int i = 1; i < durationSymbols.Count; ++i)
                {
                    if(durationSymbols[i - 1].MsPosition < msPos && durationSymbols[i].MsPosition >= msPos)
                    {
                        InsertBeforeDS(voice.NoteObjects, durationSymbols[i], invisibleClefChangeSymbol);
                        break;
                    }
                }
            }
        }
Пример #8
0
 private void InsertBeforeDS(List<NoteObject> noteObjects, DurationSymbol insertBeforeDS, ClefChangeSymbol invisibleClefChangeSymbol)
 {
     for(int i = 0; i < noteObjects.Count; ++i)
     {
         DurationSymbol durationSymbol = noteObjects[i] as DurationSymbol;
         if(durationSymbol != null && durationSymbol == insertBeforeDS)
         {
             noteObjects.Insert(i, invisibleClefChangeSymbol);
             break;
         }
     }
 }
Пример #9
0
        /// <summary>
        /// There is still one system per bar.
        /// </summary>
        /// <param name="systems"></param>
        public void ConvertVoiceDefsToNoteObjects(List <SvgSystem> systems)
        {
            byte[] currentChannelVelocities = new byte[systems[0].Staves.Count];

            List <ClefChangeDef> voice0ClefChangeDefs = new List <ClefChangeDef>();
            List <ClefChangeDef> voice1ClefChangeDefs = new List <ClefChangeDef>();

            for (int systemIndex = 0; systemIndex < systems.Count; ++systemIndex)
            {
                SvgSystem system            = systems[systemIndex];
                int       visibleStaffIndex = -1;
                for (int staffIndex = 0; staffIndex < system.Staves.Count; ++staffIndex)
                {
                    Staff staff = system.Staves[staffIndex];
                    if (!(staff is InvisibleOutputStaff))
                    {
                        visibleStaffIndex++;
                    }
                    voice0ClefChangeDefs.Clear();
                    voice1ClefChangeDefs.Clear();
                    for (int voiceIndex = 0; voiceIndex < staff.Voices.Count; ++voiceIndex)
                    {
                        Voice voice           = staff.Voices[voiceIndex];
                        float musicFontHeight = (voice is OutputVoice) ? _pageFormat.MusicFontHeight : _pageFormat.MusicFontHeight * _pageFormat.InputStavesSizeFactor;
                        if (!(staff is InvisibleOutputStaff))
                        {
                            Debug.Assert(_pageFormat.ClefsList[visibleStaffIndex] != null);
                            voice.NoteObjects.Add(new ClefSymbol(voice, _pageFormat.ClefsList[visibleStaffIndex], musicFontHeight));
                        }
                        bool firstLmdd = true;

                        if (staff is InputStaff)
                        {
                            InputVoice inputVoice = staff.Voices[voiceIndex] as InputVoice;
                            if (systemIndex == 0)
                            {
                                InputVoiceDef inputVoiceDef = inputVoice.VoiceDef as InputVoiceDef;
                                inputVoice.SetMidiChannel(inputVoiceDef.MidiChannel, systemIndex);
                            }
                        }
                        foreach (IUniqueDef iud in voice.VoiceDef.UniqueDefs)
                        {
                            NoteObject noteObject =
                                SymbolSet.GetNoteObject(voice, iud, firstLmdd, ref currentChannelVelocities[staffIndex], musicFontHeight);

                            ClefChangeSymbol clefChangeSymbol = noteObject as ClefChangeSymbol;
                            if (clefChangeSymbol != null)
                            {
                                if (voiceIndex == 0)
                                {
                                    voice0ClefChangeDefs.Add(iud as ClefChangeDef);
                                }
                                else
                                {
                                    voice1ClefChangeDefs.Add(iud as ClefChangeDef);
                                }
                            }

                            voice.NoteObjects.Add(noteObject);

                            firstLmdd = false;
                        }
                    }

                    if (voice0ClefChangeDefs.Count > 0 || voice1ClefChangeDefs.Count > 0)
                    {
                        // the main clef on this staff in the next system
                        SetNextSystemClefType(staffIndex, voice0ClefChangeDefs, voice1ClefChangeDefs);
                    }

                    if (staff.Voices.Count == 2)
                    {
                        InsertInvisibleClefChangeSymbols(staff.Voices, voice0ClefChangeDefs, voice1ClefChangeDefs);

                        CheckClefTypes(staff.Voices);

                        StandardSymbolSet standardSymbolSet = SymbolSet as StandardSymbolSet;
                        if (standardSymbolSet != null)
                        {
                            standardSymbolSet.ForceNaturalsInSynchronousChords(staff);
                        }
                    }
                }
            }
        }
Пример #10
0
 private void InsertBeforeDS(List <NoteObject> noteObjects, DurationSymbol insertBeforeDS, ClefChangeSymbol invisibleClefChangeSymbol)
 {
     for (int i = 0; i < noteObjects.Count; ++i)
     {
         DurationSymbol durationSymbol = noteObjects[i] as DurationSymbol;
         if (durationSymbol != null && durationSymbol == insertBeforeDS)
         {
             noteObjects.Insert(i, invisibleClefChangeSymbol);
             break;
         }
     }
 }
Пример #11
0
 private void InsertInvisibleClefChanges(Voice voice, int systemAbsMsPos, List<ClefChangeDef> clefChangeDefs)
 {
     foreach(ClefChangeDef ccd in clefChangeDefs)
     {
         int absPos = systemAbsMsPos + ccd.MsPositionReFirstUD;
         ClefChangeSymbol invisibleClefChangeSymbol = new ClefChangeSymbol(voice, ccd.ClefType, absPos, _pageFormat.CautionaryNoteheadsFontHeight);
         invisibleClefChangeSymbol.IsVisible = false;
         InsertInvisibleClefChangeInNoteObjects(voice, invisibleClefChangeSymbol);
     }
 }