Example #1
0
        public void TestBackwardsAndForwardsConversionSpectrograms(int frame, int bin)
        {
            UnitConverters converter = new UnitConverters(
                60,
                22050,
                512,
                256);

            var endFrame = frame + 1;

            var secondsStart = converter.GetStartTimeInSecondsOfFrame(frame);
            var secondsEnd   = converter.GetEndTimeInSecondsOfFrame(endFrame);
            var hertz        = converter.GetHertzFromFreqBin(bin);

            var outFrame    = converter.FrameFromStartTime(secondsStart);
            var endOutFrame = converter.FrameFromEndTime(secondsEnd);
            var outBin      = converter.GetFreqBinFromHertz(hertz);

            Assert.AreEqual(frame, outFrame, $"Frames do not match, expected: {frame}, actual: {outFrame}, seconds was: {secondsStart}");
            Assert.AreEqual(endFrame, endOutFrame, $"Frame ends do not match, expected: {endFrame}, actual: {endOutFrame}, seconds was: {secondsEnd}");
            Assert.AreEqual(bin, outBin, $"Bins do not match, expected: {bin}, actual: {outBin}, hertz was: {hertz}");
        }