Esempio n. 1
0
        public void GetBeatLength_ConstantTimeSignature(long bars, int timeSignatureNumerator, int timeSignatureDenominator)
        {
            const short ticksPerQuarterNote = 100;

            var tempoMap = TempoMap.Create(new TicksPerQuarterNoteTimeDivision(ticksPerQuarterNote), new TimeSignature(timeSignatureNumerator, timeSignatureDenominator));
            var length   = BarBeatUtilities.GetBeatLength(bars, tempoMap);

            Assert.AreEqual(ticksPerQuarterNote * 4 / timeSignatureDenominator, length, "Beat length is invalid.");
        }
Esempio n. 2
0
        public void GetBeatLength_ChangedTimeSignature(long bars, int timeSignatureNumerator, int timeSignatureDenominator, bool changeOnEdge)
        {
            const short ticksPerQuarterNote = 100;

            TempoMap tempoMap;

            using (var tempoMapManager = new TempoMapManager(new TicksPerQuarterNoteTimeDivision(ticksPerQuarterNote)))
            {
                tempoMapManager.SetTimeSignature(new BarBeatTicksTimeSpan(changeOnEdge ? bars : bars - 1), new TimeSignature(timeSignatureNumerator, timeSignatureDenominator));
                tempoMap = tempoMapManager.TempoMap;
            }

            var length = BarBeatUtilities.GetBeatLength(bars, tempoMap);

            Assert.AreEqual(ticksPerQuarterNote * 4 / timeSignatureDenominator, length, "Beat length is invalid.");
        }