public void StereoDtmfTones() { using var file = new AudioFileReader("./testdata/stereo_dtmf_tones.wav"); var dtmfs = file.DtmfChanges(forceMono: false); dtmfs.ShouldBe(new[] { DtmfChange.Start(PhoneKey.One, TimeSpan.Parse("00:00:00"), 0), DtmfChange.Stop(PhoneKey.One, TimeSpan.Parse("00:00:00.9994557"), 0), DtmfChange.Start(PhoneKey.Two, TimeSpan.Parse("00:00:01.9988208"), 1), DtmfChange.Stop(PhoneKey.Two, TimeSpan.Parse("00:00:02.9982086"), 1), DtmfChange.Start(PhoneKey.Three, TimeSpan.Parse("00:00:03.9975736"), 0), DtmfChange.Start(PhoneKey.Four, TimeSpan.Parse("00:00:04.9969614"), 1), DtmfChange.Stop(PhoneKey.Three, TimeSpan.Parse("00:00:05.9963265"), 0), DtmfChange.Stop(PhoneKey.Four, TimeSpan.Parse("00:00:06.9957142"), 1), DtmfChange.Start(PhoneKey.Five, TimeSpan.Parse("00:00:07.9950793"), 0), DtmfChange.Start(PhoneKey.Six, TimeSpan.Parse("00:00:07.9950793"), 1), DtmfChange.Stop(PhoneKey.Five, TimeSpan.Parse("00:00:08.9944444"), 0), DtmfChange.Stop(PhoneKey.Six, TimeSpan.Parse("00:00:08.9944444"), 1), DtmfChange.Start(PhoneKey.Seven, TimeSpan.Parse("00:00:09.9938321"), 0), DtmfChange.Start(PhoneKey.Eight, TimeSpan.Parse("00:00:11.0188208"), 1), DtmfChange.Stop(PhoneKey.Eight, TimeSpan.Parse("00:00:11.9925850"), 1), DtmfChange.Stop(PhoneKey.Seven, TimeSpan.Parse("00:00:12.9919501"), 0), DtmfChange.Start(PhoneKey.Nine, TimeSpan.Parse("00:00:14.0169614"), 0), DtmfChange.Stop(PhoneKey.Nine, TimeSpan.Parse("00:00:14.9907029"), 0), DtmfChange.Start(PhoneKey.Zero, TimeSpan.Parse("00:00:15.0163265"), 0), DtmfChange.Stop(PhoneKey.Zero, TimeSpan.Parse("00:00:15.9900680"), 0), }); }
public void ImplementsIEquatable() => new HashSet <DtmfChange> { DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3) } .Contains(DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3)) .ShouldBeTrue();
public void PcmData() => Concat(Space(), Mark(PhoneKey.A), Space(), Mark(PhoneKey.C), Space(), Mark(PhoneKey.A), Space(), Mark(PhoneKey.B), Space()).ToArray() .DtmfChanges() .ShouldBe(new[] { DtmfChange.Start(PhoneKey.A, TimeSpan.Parse("00:00:00.0000026"), 0), DtmfChange.Stop(PhoneKey.A, TimeSpan.Parse("00:00:00.0000051"), 0), DtmfChange.Start(PhoneKey.C, TimeSpan.Parse("00:00:00.0000077"), 0), DtmfChange.Stop(PhoneKey.C, TimeSpan.Parse("00:00:00.0000128"), 0), DtmfChange.Start(PhoneKey.A, TimeSpan.Parse("00:00:00.0000154"), 0), DtmfChange.Stop(PhoneKey.A, TimeSpan.Parse("00:00:00.0000179"), 0), DtmfChange.Start(PhoneKey.B, TimeSpan.Parse("00:00:00.0000205"), 0), DtmfChange.Stop(PhoneKey.B, TimeSpan.Parse("00:00:00.0000231"), 0) });
public void CanHandleOverlapAcrossChannels() => new List <DtmfChange> { DtmfChange.Start(PhoneKey.A, TimeSpan.FromSeconds(1), 0), DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(2), 1), DtmfChange.Stop(PhoneKey.B, TimeSpan.FromSeconds(3), 1), DtmfChange.Start(PhoneKey.C, TimeSpan.FromSeconds(4), 2), DtmfChange.Stop(PhoneKey.A, TimeSpan.FromSeconds(5), 0), DtmfChange.Stop(PhoneKey.C, TimeSpan.FromSeconds(6), 2) } .ToDtmfTones() .ShouldBe(new[] { new DtmfTone(PhoneKey.A, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(4), 0), new DtmfTone(PhoneKey.B, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1), 1), new DtmfTone(PhoneKey.C, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(2), 2) });
public void MergesStartsAndStopsIntoDtmfTones() => new List <DtmfChange> { DtmfChange.Start(PhoneKey.A, TimeSpan.FromSeconds(1), 0), DtmfChange.Stop(PhoneKey.A, TimeSpan.FromSeconds(3), 0), DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(4), 0), DtmfChange.Stop(PhoneKey.B, TimeSpan.FromSeconds(7), 0), DtmfChange.Start(PhoneKey.C, TimeSpan.FromSeconds(9), 0), DtmfChange.Stop(PhoneKey.C, TimeSpan.FromSeconds(10), 0) } .ToDtmfTones() .ShouldBe(new[] { new DtmfTone(PhoneKey.A, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), 0), new DtmfTone(PhoneKey.B, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(3), 0), new DtmfTone(PhoneKey.C, TimeSpan.FromSeconds(9), TimeSpan.FromSeconds(1), 0) });
public void LongDtmfTones() { using var file = new AudioFileReader("./testdata/long_dtmf_tones.mp3"); var dtmfs = file.DtmfChanges(); dtmfs.ShouldBe(new[] { DtmfChange.Start(PhoneKey.One, TimeSpan.Parse("00:00:02.7675736"), 0), DtmfChange.Stop(PhoneKey.One, TimeSpan.Parse("00:00:05.5607029"), 0), DtmfChange.Start(PhoneKey.Two, TimeSpan.Parse("00:00:06.7138321"), 0), DtmfChange.Stop(PhoneKey.Two, TimeSpan.Parse("00:00:06.8675736"), 0), DtmfChange.Start(PhoneKey.Three, TimeSpan.Parse("00:00:07.3031972"), 0), DtmfChange.Stop(PhoneKey.Three, TimeSpan.Parse("00:00:07.4313378"), 0), DtmfChange.Start(PhoneKey.Four, TimeSpan.Parse("00:00:08.2000680"), 0), DtmfChange.Stop(PhoneKey.Four, TimeSpan.Parse("00:00:10.5319501"), 0), DtmfChange.Start(PhoneKey.Five, TimeSpan.Parse("00:00:12.0950793"), 0), DtmfChange.Stop(PhoneKey.Five, TimeSpan.Parse("00:00:12.2744444"), 0), DtmfChange.Start(PhoneKey.Six, TimeSpan.Parse("00:00:12.7357142"), 0), DtmfChange.Stop(PhoneKey.Six, TimeSpan.Parse("00:00:12.8125850"), 0), DtmfChange.Start(PhoneKey.Seven, TimeSpan.Parse("00:00:14.5038321"), 0), DtmfChange.Stop(PhoneKey.Seven, TimeSpan.Parse("00:00:14.5294557"), 0), DtmfChange.Start(PhoneKey.Seven, TimeSpan.Parse("00:00:14.5550793"), 0), DtmfChange.Stop(PhoneKey.Seven, TimeSpan.Parse("00:00:16.8357142"), 0), DtmfChange.Start(PhoneKey.Eight, TimeSpan.Parse("00:00:17.6813378"), 0), DtmfChange.Stop(PhoneKey.Eight, TimeSpan.Parse("00:00:17.7582086"), 0), DtmfChange.Start(PhoneKey.Nine, TimeSpan.Parse("00:00:18.4500680"), 0), DtmfChange.Stop(PhoneKey.Nine, TimeSpan.Parse("00:00:18.5269614"), 0), DtmfChange.Start(PhoneKey.Hash, TimeSpan.Parse("00:00:19.1163265"), 0), DtmfChange.Stop(PhoneKey.Hash, TimeSpan.Parse("00:00:19.1419501"), 0), DtmfChange.Start(PhoneKey.Hash, TimeSpan.Parse("00:00:19.1675736"), 0), DtmfChange.Stop(PhoneKey.Hash, TimeSpan.Parse("00:00:19.3469614"), 0), DtmfChange.Start(PhoneKey.Zero, TimeSpan.Parse("00:00:19.8338321"), 0), DtmfChange.Stop(PhoneKey.Zero, TimeSpan.Parse("00:00:19.8850793"), 0), DtmfChange.Start(PhoneKey.Star, TimeSpan.Parse("00:00:20.4744444"), 0), DtmfChange.Stop(PhoneKey.Star, TimeSpan.Parse("00:00:20.6025850"), 0), DtmfChange.Start(PhoneKey.One, TimeSpan.Parse("00:00:22.0119501"), 0), DtmfChange.Stop(PhoneKey.One, TimeSpan.Parse("00:00:23.7544444"), 0) }); }
public static DtmfChange Stop(PhoneKey k, int channel = 0) => DtmfChange.Stop(k, new TimeSpan(), channel);
public void ToStringPrintsInfoLine() => DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3) .ToString() .ShouldBe("B started @ 00:00:05 (ch: 3)");
public void OverridesNotEqualsOperator() => (DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3) != DtmfChange.Stop(PhoneKey.C, TimeSpan.FromSeconds(2), 4)) .ShouldBeTrue();
public void OverridesEqualsOperator() => (DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3) == DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3)) .ShouldBeTrue();
public void OverridesEquals() => DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3) .Equals((object)DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3)) .ShouldBeTrue();
public void OverridesGetHashCode() => DtmfChange.Start(PhoneKey.B, TimeSpan.FromSeconds(5), 3).GetHashCode() .ShouldNotBe(DtmfChange.Stop(PhoneKey.C, TimeSpan.FromSeconds(2), 4).GetHashCode());
public void ThrowsWhenStopIsMissing() => new Action(() => new List <DtmfChange> { DtmfChange.Start(PhoneKey.A, TimeSpan.FromSeconds(1), 0) } .ToDtmfTones().ToList()) .ShouldThrow <InvalidOperationException>();