From d1df8fdf97d44b5681adac596ba9dbcbfd0641f1 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Wed, 15 Nov 2023 14:21:18 -0500 Subject: [PATCH] add variables to control cycle resolution and count --- reverse_goertzel.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/reverse_goertzel.py b/reverse_goertzel.py index 929ba84..ad0b6bd 100644 --- a/reverse_goertzel.py +++ b/reverse_goertzel.py @@ -28,16 +28,18 @@ def sinusoid(n, cycles=1): return result def main(): - cycles = 2 - signal = goertzel_sinusoid(cycles, 1, 1024, 1) - reference = np.array(sinusoid(1024, cycles)) + samp_per_cycle = 512 + cycles = 3 + len = cycles * samp_per_cycle + signal = goertzel_sinusoid(1, cycles, samp_per_cycle, 1) + reference = np.array(sinusoid(len, cycles)) error = reference - signal print("max error:", error.max()) - x = np.array(range(0, 1024)) + x = np.array(range(0, len)) plt.plot(x, signal) plt.plot(x, reference) plt.plot(x, error) - #plt.plot(x, error*1000/3) + #plt.plot(x, error*100) plt.show() if __name__ == "__main__":