I have been trying to get a gif file demonstrating the comb filtering resulting from delayed sinusoidal signals superposition. This is the code:
using Plots gr(size = (1200, 800)) Fₛ = 96000 # Sample Rate [Hz] δ = 0.001 # Lag [s] fₛ = 20 # Starting frequency [Hz] fₑ = 1000 # End frequency [Hz] τ = 1 / fₛ # Time width to display [s] F = 500 # Number of frames f = linspace(fₛ, fₑ, F) t = linspace(0, τ, 1000) x = zeros(t) y = zeros(t) z = zeros(t) H = zeros(f) lay = grid(1, 2) anim = Animation() for n = 1:length(f) x = cospi.(2 * f[n] * t) y = cospi.(2 * f[n] * (t - δ)) z = x + y H[n] = maximum(abs, z) plot( plot(t, [x y z], label = ["Primary" "Delayed by $δ seconds" "Sum"], ylim = (-2, 2), title = "Frequency: $(@sprintf("%.2f", f[n])) Hz", xlabel = "Time [s]", ylabel = "Amplitude [normalized]"), plot(f, H, label = "Comb Filter", ylim = (0, 2), title = "Amplitude as function of frequency", xlabel = "Frequency [Hz]", ylabel = "Amplitude [normalized]"), layout = lay) frame(anim) end
When I go ahead and create a gif out of the results all the frames are white except the first one.
gif(anim, "/tmp/anim_fps15.gif", fps = 15)
The weird thing is that the code above will work for simple plots (i.e. without subplots, for example just the plot showing the cosine waves).
Am I doing something wrong or did I hit a bug?