Beispiel #1
0
        public void Test()
        {
            var b1           = new TimedBeatId(0f, new BeatId(1));
            var b2           = new TimedBeatId(0.4f, new BeatId(2));
            var b3           = new TimedBeatId(0.6f, new BeatId(3));
            var beatTimeList = new BeatTimesList(0.5f);

            beatTimeList.Add(b1);
            beatTimeList.Add(b2);
            beatTimeList.Add(b3);
            Assert.Equal(3, beatTimeList.Count);
            var next = beatTimeList.Next;

            Assert.Equal(b1, beatTimeList.Next);
            var discarded = new List <TimedBeatId>();

            beatTimeList.Tick(0.6f, discarded.Add);
            Assert.Equal(new [] { b1 }, discarded);
            Assert.Equal(2, beatTimeList.Count);

            beatTimeList.Tick(0.9f, discarded.Add);
            Assert.Equal(new[] { b1 }, discarded);
            Assert.Equal(2, beatTimeList.Count);

            beatTimeList.Tick(0.91f, discarded.Add);
            Assert.Equal(new[] { b1, b2 }, discarded);
            Assert.Equal(1, beatTimeList.Count);

            beatTimeList.Tick(1.2f, discarded.Add);
            Assert.Equal(new[] { b1, b2, b3 }, discarded);
            Assert.Equal(0, beatTimeList.Count);
            Assert.True(beatTimeList.IsEmpty);
        }
        public void TestReset()
        {
            var pattern      = BuildBinaryPattern();
            var matchResults = new MatchResultCollector();
            var matcher      = PatternMatcher.Create(pattern, new PatternMatcher.Settings {
                MaxMatchingTime = 0.25f
            }, matchResults);
            var sn = new SimpleSoundId("SN", "default", "*");
            var bs = new SimpleSoundId("BS", "default", "*");

            short i = 1;

            matcher.Tick(0f);
            var beat = new TimedBeatId(0, new BeatId(i++));

            matcher.AddBeat(bs, beat, Velocity.Medium);
            Assert.Single(matchResults.Matches);

            matcher.Tick(100f);

            matcher.Reset();
            matchResults.Matches.Clear();
            matchResults.Missed.Clear();
            matcher.Tick(0f);
            matcher.AddBeat(bs, beat, Velocity.Medium);
            Assert.Single(matchResults.Matches);
        }
Beispiel #3
0
        public void AddPlayedBeat(TimedBeatId timedBeat, ISoundId sound)
        {
            var coord  = grid.Coordinates(sound.Instrument, timedBeat.T);
            var expiry = timedBeat.T + 0.75f * pattern.Info.TotalBeats;
            var mark   = new BeatMark(timedBeat.Id, coord, beatPaints.Paint(BeatStatus.Pending), expiry, sound.Mark);

            beatMarks.Enqueue(mark);
        }
 void IMatchResultsCollector.MissedBeat(TimedBeatId beat)
 {
     if (beat.Id.IsPattern)
     {
         summary.BeatSummary(beat.Id).AddMiss();
         PatternMissed?.Invoke(beat);
     }
     PlayedBeatStatusSet?.Invoke(beat.Id, BeatStatus.MissedPlay);
 }
 private void FlushBeatsBuffer()
 {
     while (playedBeatsBuffer.TryDequeue(out TimedEvent <Beat> beat))
     {
         var id        = playedBeats.New(beat);
         var timedBeat = new TimedBeatId(beat.Time, id);
         NewPlayedBeat?.Invoke(timedBeat, beat.Value.Sound);
         matcher.AddBeat(beat.Value.Sound, timedBeat, beat.Value.Velocity);
     }
 }
Beispiel #6
0
 public void AddPlayedBeat(TimedBeatId timedBeat, ISoundId sound)
 {
     beatsDrawer.AddPlayedBeat(timedBeat, sound);
 }
 public void MissedBeat(TimedBeatId missed)
 {
     Missed.Add(missed);
 }
Beispiel #8
0
        public readonly float Accuracy;// from -1 (max too early) to +1 (max too late)

        public BeatsMatch(TimedBeatId patternBeat, TimedBeatId playedBeat, float accuracy)
        {
            PatternBeat = patternBeat;
            PlayedBeat  = playedBeat;
            Accuracy    = accuracy;
        }
Beispiel #9
0
 public MissedBeat(int instrumentIndex, TimedBeatId beat)
 {
     InstrumentIndex = instrumentIndex;
     Beat            = beat;
 }