# calculate Butterworth Low-pass coordinates

import numpy as np
from numpy import zeros
from scipy.io.wavfile import read, write
from scipy.signal import butter, lfilter, lfilter_zi   
import matplotlib.pyplot as plt

(freqSamp,triwav)=read('triangle.wav')

# initialising filter

tribut=zeros(freqSamp)

order=12
cutoff=5000
Nyquist=freqSamp/2
Wn=cutoff/Nyquist

(b,a)=butter(order,Wn)
zi=lfilter_zi(b,a)

# applying filter

(tribut,_)=lfilter(b,a,triwav,zi=zi*triwav[0])

# writing filtered samples

write('tribut.wav',freqSamp,tribut)