Exemplo n.º 1
0
        private void Bar()
        {
            var master = new MasterBar();

            _score.AddMasterBar(master);

            var bar = new Bar();

            _track.AddBarToStaff(0, bar);

            if (master.Index > 0)
            {
                master.KeySignature             = master.PreviousMasterBar.KeySignature;
                master.TimeSignatureDenominator = master.PreviousMasterBar.TimeSignatureDenominator;
                master.TimeSignatureNumerator   = master.PreviousMasterBar.TimeSignatureNumerator;
                bar.Clef = bar.PreviousBar.Clef;
            }
            BarMeta(bar);

            var voice = new Voice();

            bar.AddVoice(voice);

            while (_sy != AlphaTexSymbols.Pipe && _sy != AlphaTexSymbols.Eof)
            {
                Beat(voice);
            }

            if (voice.Beats.Count == 0)
            {
                var emptyBeat = new Beat();
                emptyBeat.IsEmpty = true;
                voice.AddBeat(emptyBeat);
            }
        }
Exemplo n.º 2
0
        private void Bar()
        {
            var master = new MasterBar();

            _score.AddMasterBar(master);

            var bar = new Bar();

            _track.AddBar(bar);

            if (master.Index > 0)
            {
                master.KeySignature             = master.PreviousMasterBar.KeySignature;
                master.TimeSignatureDenominator = master.PreviousMasterBar.TimeSignatureDenominator;
                master.TimeSignatureNumerator   = master.PreviousMasterBar.TimeSignatureNumerator;
                bar.Clef = bar.PreviousBar.Clef;
            }
            BarMeta(bar);

            var voice = new Voice();

            bar.AddVoice(voice);

            while (_sy != AlphaTexSymbols.Pipe && _sy != AlphaTexSymbols.Eof)
            {
                Beat(voice);
            }
        }
Exemplo n.º 3
0
        private MasterBar GetOrCreateMasterBar(int index)
        {
            if (index < _score.MasterBars.Count)
            {
                return(_score.MasterBars[index]);
            }

            for (int i = _score.MasterBars.Count; i <= index; i++)
            {
                var mb = new MasterBar();
                if (_score.MasterBars.Count > 0)
                {
                    var prev = _score.MasterBars[_score.MasterBars.Count - 1];
                    mb.TimeSignatureDenominator = prev.TimeSignatureDenominator;
                    mb.TimeSignatureNumerator   = prev.TimeSignatureNumerator;
                    mb.KeySignature             = prev.KeySignature;
                    mb.KeySignatureType         = prev.KeySignatureType;
                }


                _score.AddMasterBar(mb);
            }

            return(_score.MasterBars[index]);
        }
Exemplo n.º 4
0
        private MasterBar GetOrCreateMasterBar(int index)
        {
            if (index < _score.MasterBars.Count)
            {
                return(_score.MasterBars[index]);
            }

            for (int i = _score.MasterBars.Count; i <= index; i++)
            {
                var mb = new MasterBar();
                _score.AddMasterBar(mb);
            }

            return(_score.MasterBars[index]);
        }
Exemplo n.º 5
0
        private static void AddMasterBarToScore(Score score, string sessionText, eBeatWrapper measureBeats)
        {
            var measureBeatsCount = measureBeats.MeasureSubBeats.Count + 1;
            var masterBar         = new MasterBar();

            if (measureBeatsCount == 2)
            {
                masterBar.TimeSignatureNumerator   = 2;
                masterBar.TimeSignatureDenominator = 4;
            }
            else if (measureBeatsCount == 3)
            {
                masterBar.TimeSignatureNumerator   = 3;
                masterBar.TimeSignatureDenominator = 4;
            }
            else if (measureBeatsCount == 6)
            {
                masterBar.TimeSignatureNumerator   = 6;
                masterBar.TimeSignatureDenominator = 8;
            }
            else
            {
                masterBar.TimeSignatureNumerator   = 4;
                masterBar.TimeSignatureDenominator = 4;

                if (measureBeatsCount != 4)
                {
                    System.Diagnostics.Debug.WriteLine("Unknown timesignature (measureBeatsCount: {0}). Defaulting to 4/4.", measureBeatsCount);
                }
            }

            masterBar.Section = new global::AlphaTab.Model.Section()
            {
                Text = sessionText
            };
            score.AddMasterBar(masterBar);
        }
Exemplo n.º 6
0
        public void ReadMasterBar()
        {
            MasterBar previousMasterBar = default(MasterBar);

            if (_score.MasterBars.Count > 0)
            {
                previousMasterBar = _score.MasterBars[_score.MasterBars.Count - 1];
            }

            MasterBar newMasterBar = new MasterBar();
            int       flags        = _data.ReadByte();

            // time signature
            if ((flags & 0x01) != 0)
            {
                newMasterBar.TimeSignatureNumerator = _data.ReadByte();
            }
            else if (previousMasterBar != null)
            {
                newMasterBar.TimeSignatureNumerator = previousMasterBar.TimeSignatureNumerator;
            }
            if ((flags & 0x02) != 0)
            {
                newMasterBar.TimeSignatureDenominator = _data.ReadByte();
            }
            else if (previousMasterBar != null)
            {
                newMasterBar.TimeSignatureDenominator = previousMasterBar.TimeSignatureDenominator;
            }

            // repeatings
            newMasterBar.IsRepeatStart = (flags & 0x04) != 0;
            if ((flags & 0x08) != 0)
            {
                newMasterBar.RepeatCount = _versionNumber >= 500 ? _data.ReadByte() : 1;
            }

            // marker
            if ((flags & 0x20) != 0)
            {
                Section section = new Section();
                section.Text   = ReadStringIntByte();
                section.Marker = "";
                ReadColor();
                newMasterBar.Section = section;
            }

            // alternate endings
            if ((flags & 0x10) != 0)
            {
                if (_versionNumber < 500)
                {
                    MasterBar currentMasterBar = previousMasterBar;
                    // get the already existing alternatives to ignore them
                    int existentAlternatives = 0;
                    while (currentMasterBar != null)
                    {
                        // found another repeat ending?
                        if (currentMasterBar.IsRepeatEnd && currentMasterBar != previousMasterBar)
                        {
                            break;
                        }
                        // found the opening?
                        if (currentMasterBar.IsRepeatStart)
                        {
                            break;
                        }

                        existentAlternatives |= currentMasterBar.AlternateEndings;
                    }

                    // now calculate the alternative for this bar
                    var repeatAlternative = 0;
                    var repeatMask        = _data.ReadByte();
                    for (var i = 0; i < 8; i++)
                    {
                        // only add the repeating if it is not existing
                        var repeating = (1 << i);
                        if (repeatMask > i && (existentAlternatives & repeating) == 0)
                        {
                            repeatAlternative |= repeating;
                        }
                    }


                    newMasterBar.AlternateEndings = (byte)repeatAlternative;
                }
                else
                {
                    newMasterBar.AlternateEndings = (byte)_data.ReadByte();
                }
            }


            // keysignature
            if ((flags & 0x40) != 0)
            {
                newMasterBar.KeySignature = _data.ReadSignedByte();
                _data.ReadByte(); // keysignature type
            }
            else if (previousMasterBar != null)
            {
                newMasterBar.KeySignature = previousMasterBar.KeySignature;
            }

            if ((_versionNumber >= 500) && ((flags & 0x03) != 0))
            {
                _data.Skip(4);
            }

            // better alternate ending mask in GP5
            if ((_versionNumber >= 500) && ((flags & 0x10) == 0))
            {
                newMasterBar.AlternateEndings = (byte)_data.ReadByte();
            }

            // tripletfeel
            if (_versionNumber >= 500)
            {
                var tripletFeel = _data.ReadByte();
                switch (tripletFeel)
                {
                case 1:
                    newMasterBar.TripletFeel = TripletFeel.Triplet8th;
                    break;

                case 2:
                    newMasterBar.TripletFeel = TripletFeel.Triplet16th;
                    break;
                }

                _data.ReadByte();
            }
            else
            {
                newMasterBar.TripletFeel = _globalTripletFeel;
            }

            newMasterBar.IsDoubleBar = (flags & 0x80) != 0;
            _score.AddMasterBar(newMasterBar);
        }