예제 #1
0
        // Neither the krystals, nor the palettes argument is used.
        public override List<List<VoiceDef>> DoAlgorithm(List<Krystal> krystals, List<Palette> palettes)
        {
            List<Trk> tracks1and6 = GetTracks1and6();
            List<Trk> tracks2and5 = GetTracks2and5();
            List<Trk> tracks3and4 = GetTracks3and4();

            // Add each Trk to trks here, in top to bottom (=channelIndex) order in the score.
            List<Trk> trks = new List<Trk>() { tracks1and6[0], tracks2and5[0], tracks3and4[0], tracks3and4[1], tracks2and5[1], tracks1and6[1] };
            Debug.Assert(trks.Count == MidiChannelIndexPerOutputVoice.Count);

            Seq seq = new Seq(0, trks, MidiChannelIndexPerOutputVoice);
            double approxBarMsDuration = ((double)seq.MsDuration / 8);
            List<int> approxBarlineMsPositions = new List<int>();
            for(int barnumber = 1; barnumber < 9; ++barnumber)
            {
                approxBarlineMsPositions.Add((int)Math.Round(approxBarMsDuration * barnumber));
            }
            Block block = new Block(seq, approxBarlineMsPositions);

            MainBlock mainBlock = new MainBlock(InitialClefPerChannel, new List<Block>() { block });

            List <List<VoiceDef>> bars = mainBlock.ConvertToBars();

            SetPatch0InAllChords(bars);

            return bars;
        }
예제 #2
0
파일: Block.cs 프로젝트: notator/Moritz
        public void Concat(Block block2)
        {
            Debug.Assert(_voiceDefs.Count == block2._voiceDefs.Count);

            IReadOnlyList<int> block2BarlineMsPositions = block2.BarlineMsPositionsReBlock;
            foreach(int msPosition in block2BarlineMsPositions)
            {
                _barlineMsPositionsReBlock.Add(this.MsDuration + msPosition);
            }

            for(int i = 0; i < _voiceDefs.Count; ++i)
            {
                VoiceDef vd1 = _voiceDefs[i];
                VoiceDef vd2 = block2._voiceDefs[i];

                Trk trk1 = vd1 as Trk;
                Trk trk2 = vd2 as Trk;

                InputVoiceDef ivd1 = vd1 as InputVoiceDef;
                InputVoiceDef ivd2 = vd2 as InputVoiceDef;

                Debug.Assert((trk1 != null && trk2 != null) || (ivd1 != null && ivd2 != null));

                vd1.Container = null;
                vd2.Container = null;
                vd1.AddRange(vd2);
                vd1.RemoveDuplicateClefChanges();
                vd1.AgglomerateRests();
                vd1.Container = this;
            }

            AssertNonEmptyBlockConsistency();
        }
예제 #3
0
파일: Block.cs 프로젝트: notator/Moritz
        /// <summary>
        /// A deep clone of the Block
        /// </summary>
        public Block Clone()
        {
            List<Trk> clonedTrks = new List<Trk>();
            List<int> midiChannelPerOutputVoice = new List<int>();
            foreach(Trk trk in Trks)
            {
                Trk trkClone = trk.Clone();
                clonedTrks.Add(trkClone);
                midiChannelPerOutputVoice.Add(trk.MidiChannel);
            }
            Seq clonedSeq = new Seq(this.AbsMsPosition, clonedTrks, midiChannelPerOutputVoice);
            List<InputVoiceDef> clonedInputVoiceDefs = new List<Spec.InputVoiceDef>();
            foreach(InputVoiceDef ivd in InputVoiceDefs)
            {
                clonedInputVoiceDefs.Add(ivd.Clone());
            }
            Block clone = new Block(clonedSeq, this.BarlineMsPositionsReBlock, clonedInputVoiceDefs);

            return clone;
        }