예제 #1
0
 public TimelineSource(TuneDuration duration, int alignmentOfStart)
 {
     this._workingDuration = TimeSpan.FromSeconds(duration.Duration() >= 0 ? duration.Duration() : DefaultDuration);
     this.Beginning        = this.StartingPointAlignedToSecond(
         TimeSpan.FromSeconds(new FiniteDouble(duration.StartingPoint())),
         alignmentOfStart);
 }
        public void GuardsValidPositionForRemaining()
        {
            var td = new TuneDuration(180, 1.0);

            Assert.AreEqual(180d, td.Remaining(-10d));
            Assert.AreEqual(0d, td.Remaining(10020d));
        }
        public void EqualityTest()
        {
            var td1 = new TuneDuration(0, 180, 1.0);

            Assert.IsTrue(td1.Equals(new TuneDuration(50, 180, 1.0d)));
            Assert.IsTrue(td1 == new TuneDuration(0, 180, 1));
            Assert.IsFalse(td1.Equals(new TuneDuration(0, 120, 1)));
            Assert.IsFalse(td1 == new TuneDuration(0, 120, 1));
        }
        public EndRevealingTimeline(TuneDuration tuneDuration, TimeSpan firstMark, ZeroToOne end)
        {
            this._firstMark = firstMark;
            var duration = tuneDuration.Duration();

            this._tickDuration      = new TickDuration(duration);
            this._lastThirdMarkTs   = TimeSpan.FromSeconds(duration * end);
            this._lastThirdDuration = new TickDuration(duration - this._lastThirdMarkTs.TotalSeconds);
        }
예제 #5
0
        public WaveformSection(TuneDuration tuneDuration, ITimedPlayback tune, int resolution)
        {
            this.Start = new Even((int)(new FiniteDouble(                    // gotta be even, baby
                                            tuneDuration.StartingPoint()     // this is number of seconds at which the area start
                                            / tune.TotalTime().TotalSeconds) // this is the total number of seconds - so the ratio is correct
                                        .Value() * resolution));

            this.End = this.Start + (int)Math.Min(resolution,                      // how much are we going to cover? max is the number of points available <=> resolution
                                                  resolution / tuneDuration.Zoom); // what is this if resolution == 8000 and zoom == 2, then we cover r/2 == 4000? seems like!
        }
        public void TimelineOfZoomedInDurationProvidesSecondsCorrespondingOfCoveredDuration()
        {
            var td   = new TuneDuration(120, 360, 4);
            var secs = new TimelineSource(td, 10).Seconds().ToList();

            Assert.AreEqual(85, secs.Count);
            Assert.AreEqual(120 - 45d, td.StartingPoint());
            Assert.AreEqual(TimeSpan.FromSeconds(80), secs.First());
            Assert.AreEqual(TimeSpan.FromSeconds(120 + 44d), secs.Last());
        }
        public void FactsAboutTheFullDuration()
        {
            var td = new TuneDuration(180);

            Assert.AreEqual(180d, td.Duration());
            Assert.AreEqual(180d, td.Remaining(0d));
            Assert.AreEqual(90d, td.Remaining(90d));
            Assert.IsTrue(td.Includes(0));
            Assert.IsTrue(td.Includes(new ZeroToOne(0)));
            Assert.IsTrue(td.Includes(1));
            Assert.IsTrue(td.Includes(new ZeroToOne(1)));
            Assert.AreEqual(0d, td.StartingPoint());
            Assert.AreEqual(0d, td.Progress(0d).Value());
            Assert.AreEqual(1d, td.Progress(180d).Value());
            Assert.AreEqual(0.5d, td.Progress(90d).Value());
            Assert.AreEqual(45d, td.ActualPosition(0.25d));
            Assert.AreEqual(0d, td.HiddenBefore(2450));
        }
        public void FactsAboutZoomedInDurationThatIncludesEnd()
        {
            var td = new TuneDuration(120, 180, 2.0);

            Assert.AreEqual(90d, td.Duration());
            Assert.AreEqual(90d, td.Remaining(90d));
            Assert.AreEqual(80, td.Remaining(100d));
            Assert.IsFalse(td.Includes(0));
            Assert.IsFalse(td.Includes(new ZeroToOne(0)));
            Assert.IsTrue(td.Includes(1));
            Assert.IsTrue(td.Includes(new ZeroToOne(1)));
            Assert.IsTrue(td.Includes(0.5));
            Assert.IsTrue(td.Includes(new ZeroToOne(0.5)));
            Assert.AreEqual(90d, td.StartingPoint());
            Assert.AreEqual(0d, td.Progress(0d).Value());
            Assert.AreEqual(0d, td.Progress(90d).Value());
            Assert.AreEqual(1d, td.Progress(180d).Value());
            Assert.AreEqual(135d, td.ActualPosition(0.5d));
            Assert.AreEqual(1225d, td.HiddenBefore(2450));
        }
예제 #9
0
 public static ITimelineMarkingStrategy Strategy(this TimelineType type, TuneDuration tuneDuration, TimeSpan firstMark, ZeroToOne end)
 {
     return(type == TimelineType.EndRevealing
         ? (ITimelineMarkingStrategy) new EndRevealingTimeline(tuneDuration, firstMark, end)
         : new ConstantTimeline(tuneDuration, firstMark));
 }
예제 #10
0
 public TimelineSource(TuneDuration duration) : this(duration, 10)
 {
 }
 public EndRevealingTimeline(TuneDuration tuneDuration, TimeSpan firstMark) : this(tuneDuration, firstMark, 0.8)
 {
 }
예제 #12
0
 public TimelineTickLocation(TuneDuration tuneDuration, WaveformDimensions waveformDimensions)
 {
     this._tuneDuration       = tuneDuration;
     this._waveformDimensions = waveformDimensions;
 }
 public ConstantTimeline(TuneDuration tuneDuration, TimeSpan firstMark)
 {
     this._firstMark    = firstMark;
     this._tickDuration = new TickDuration(tuneDuration.Duration());
 }