fourier_series

Fourier Series

  • any periodic signal can be approximated by a sum of \(N_\mathit{part}\) sinusoids
  • with individual
    • amplitude \(a_i\)
    • frequency \(f_i\)
    • phase \(\varphi_i\)

Basic Waveforms

Certain basic waveforms can be generated with spefific Fourier series.

Triangular

from numpy import linspace, sin, zeros
from math import pi
import matplotlib.pyplot as plt
from matplotlib2tikz import save as tikz_save

from IPython.display import display, Markdown, clear_output
import IPython.display as ipd
import ipywidgets as widgets


slider = widgets.FloatSlider(
         value=1,
         min=0,
         max=10.0,
         step=0.1,)

nPartials   = 5 # number of partials
f0          = 200  # signal frequency
fs          = 48000

def triang(t,f0, partCNT):

    y = (8/pow(pi,2)) * pow(-1, partCNT) * \
    sin(2*pi* f0 * (2* partCNT +1) *t) *  \
    (1/pow(2*partCNT+1,2))

    return y

t = linspace(0,1,fs)
f = linspace(-0.5,0.5,fs)

x = zeros(fs)
for partCNT in range(nPartials):
    x+=triang(t,f0,partCNT)

fig1, ax1 = plt.subplots()
ax1.plot(t[0:1000],x[0:1000])
plt.title("Triangular")


ax1.set_xlabel('t/s');
ax1.set_ylabel('x' ,color = [ 0.3, 0.3, 0.3]);


slider

ipd.display(ipd.Audio(x, rate=fs))
output_4_1.png
True


Contents © Henrik von Coler 2020