public LinqedDetector() { sampleRate = 8000; numSamples = 205; threshold = 35.0; lows = lowTones.Select(f => Goertzel.Init(f, sampleRate, numSamples)).ToArray(); highs = highTones.Select(f => Goertzel.Init(f, sampleRate, numSamples)).ToArray(); }
public LessStatefulDetector() { sampleRate = 8000; numSamples = 205; threshold = 35.0; initLoResps = lowTones.Select(f => Goertzel.Init(f, sampleRate, numSamples)).ToArray(); initHiResps = highTones.Select(f => Goertzel.Init(f, sampleRate, numSamples)).ToArray(); }
public void TestGoertzel() { float[] array = { 1, 2, 3, 4, 5, 6, 7, 8 }; var cmpx = new Goertzel(8).Direct(array, 2); Assert.Multiple(() => { Assert.That(cmpx.Real, Is.EqualTo(-4).Within(1e-6)); Assert.That(cmpx.Imaginary, Is.EqualTo(4).Within(1e-6)); }); }
public static Goertzel MeasureFrequency(this IEnumerable <float> samples, int targetFreq) => samples .Take(Config.Default.SampleBlockSize) .Aggregate( Goertzel.Init(targetFreq, Config.Default.SampleRate, Config.Default.SampleBlockSize), (g, s) => g.AddSample(s));