Example #1
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);
            }
        }
Example #2
0
        private static Voice AddBarAndVoiceToTrack(Track track, Clef clef)
        {
            var bar = new Bar();

            bar.Clef = clef;
            track.AddBar(bar);
            var voice = new Voice();

            bar.AddVoice(voice);
            return(voice);
        }
Example #3
0
        public void ReadBar(Track track)
        {
            var newBar = new Bar();

            if (track.IsPercussion)
            {
                newBar.Clef = Clef.Neutral;
            }
            track.AddBar(newBar);

            var voiceCount = 1;

            if (_versionNumber >= 500)
            {
                _data.ReadByte();
                voiceCount = 2;
            }

            for (int v = 0; v < voiceCount; v++)
            {
                ReadVoice(track, newBar);
            }
        }
Example #4
0
        private void ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
        {
            var barIndex = 0;

            if (isFirstMeasure)
            {
                _trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
                barIndex = 0;
            }
            else
            {
                barIndex = Std.ParseInt(element.GetAttribute("number")) - _trackFirstMeasureNumber;
            }

            // create empty bars to the current index
            Bar       bar       = null;
            MasterBar masterBar = null;

            for (int i = track.Bars.Count; i <= barIndex; i++)
            {
                bar       = new Bar();
                masterBar = GetOrCreateMasterBar(barIndex);
                track.AddBar(bar);

                for (int j = 0; j < _maxVoices; j++)
                {
                    var emptyVoice = new Voice();
                    bar.AddVoice(emptyVoice);
                    var emptyBeat = new Beat {
                        IsEmpty = true
                    };
                    emptyVoice.AddBeat(emptyBeat);
                }
            }

            bool chord       = false;
            bool isFirstBeat = true;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "note":
                        chord       = ParseNoteBeat(c, track, bar, chord, isFirstBeat);
                        isFirstBeat = false;
                        break;

                    case "forward":
                        break;

                    case "direction":
                        ParseDirection(c, masterBar);
                        break;

                    case "attributes":
                        ParseAttributes(c, bar, masterBar);
                        break;

                    case "harmony":
                        // TODO
                        break;

                    case "sound":
                        // TODO
                        break;

                    case "barline":
                        // TODO
                        break;
                    }
                }
            });
        }