public void CheckWithDelayFilter() { var channelCount = 3; var impulseResponses = new double[][] { new double[] { 0.0, 0.0, 0.0, 1.0 }, new double[] { 0.0, 0.0, 1.0 }, new double[] { 0.0, 0.0, 0.0, 0.0, 1.0 } }; var delaySampleCounts = new int[] { 3, 2, 4 }; var dftLength = 1024; var sv = SteeringVector.FromImpulseResponse(impulseResponses, dftLength); Assert.AreEqual(dftLength / 2 + 1, sv.Length); for (var ch = 0; ch < channelCount; ch++) { var expected = Filtering.CreateFrequencyDomainDelayFilter(dftLength, delaySampleCounts[ch]); for (var w = 0; w < dftLength / 2 + 1; w++) { Assert.AreEqual(expected[w].Real, sv[w][ch].Real, 1.0E-6); Assert.AreEqual(expected[w].Imaginary, sv[w][ch].Imaginary, 1.0E-6); } } }
public void CheckWithDelayFilter_Case2() { var delaySampleCount = 3; var sampleRate = 16000; var dftLength = 1024; var time = (double)delaySampleCount / sampleRate; var distance = AcousticConstants.SoundSpeed * time; var soundSource = new SoundSource(1.0, 1.0, 1.0); var microphones = new Microphone[] { new Microphone(1.0 + 1 * distance, 1.0, 1.0), new Microphone(1.0 + 2 * distance, 1.0, 1.0), new Microphone(1.0 + 3 * distance, 1.0, 1.0) }; var sv = SteeringVector.FromFarFieldGeometry(microphones, Math.PI / 4, 0.0, sampleRate, dftLength); Assert.AreEqual(dftLength / 2 + 1, sv.Length); var delayFilters = new Complex[][] { Filtering.CreateFrequencyDomainDelayFilter(dftLength, 0 / Math.Sqrt(2)), Filtering.CreateFrequencyDomainDelayFilter(dftLength, 3 / Math.Sqrt(2)), Filtering.CreateFrequencyDomainDelayFilter(dftLength, 6 / Math.Sqrt(2)) }; for (var w = 0; w < dftLength / 2 + 1; w++) { for (var ch = 0; ch < 3; ch++) { var actual = sv[w][ch]; var expected = delayFilters[ch][w]; Assert.AreEqual(expected.Real, actual.Real, 1.0E-6); Assert.AreEqual(expected.Imaginary, actual.Imaginary, 1.0E-6); } } }