private void SetBarlineProgress(double duration, int dots)
        {
            _progress -= DurationUtils.GetProgressDuration((double)_lastTimeSignature.Beat / duration, dots);

            if (_progress <= 0)
            {
                _output  += $" |\n{new string(' ', _scopes * SPACES_IN_TAB)}";
                _progress = _lastTimeSignature.Ticks;
            }
        }
Exemple #2
0
        public IList <MusicalSymbol> Build()
        {
            double progress = _meter.Ticks; // set progress to ticks, e.g. 4

            foreach (var symbol in _notes)
            {
                if (symbol is PSAMNote note)
                {
                    var duration = DurationUtils.GetProgressDuration((double)_meter.Beat / (double)note.Duration,
                                                                     note.NumberOfDots);
                    progress -= duration; // subtract duration from progress
                }

                if (symbol is PSAMRest rest)
                {
                    var duration = DurationUtils.GetProgressDuration((double)_meter.Beat / (double)rest.Duration,
                                                                     rest.NumberOfDots);
                    progress -= duration; // subtract duration from progress
                }


                if (progress == 0) // Bar is full add symbol, then barline. Reset the progress
                {
                    _symbols.Add(symbol);
                    _symbols.Add(new Barline());
                    progress = _meter.Ticks;
                }
                else if (progress < 0) // Symbol won't fit in the bar. Add barline then symbol. Reset progress with remaining number.
                {
                    _symbols.Add(new Barline());
                    _symbols.Add(symbol);
                    progress = progress + _meter.Ticks;
                }
                else
                {
                    _symbols.Add(symbol); // Add symbol
                }
            }

            _notes = new List <MusicalSymbol>();
            return(_symbols);
        }