def SquareWave(): harmonics = 20 for n in range(0, len(Table)): Table[n] = sin((2 * pi * n) / TableLength) for k in range(3, 2 * harmonics, 2): Table[n] += 1.0 / k * sin((2 * k * pi * n) / TableLength) Table[n] *= 3.3 / pi py_plot(Table) py_plot_show()
def SquareWave(): harmonics = 20 for n in range(0,len(Table)): Table[n] = sin((2*pi*n)/TableLength) for k in range(3, 2*harmonics, 2): Table[n] += 1.0/k * sin((2*k*pi*n)/TableLength) Table[n] *= 3.3/pi py_plot(Table) py_plot_show()
def SineWave(): for n in range(0,TableLength): Table[n] = sin((2*pi*n)/TableLength) py_plot(Table) py_plot_show() f = open("sine.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def TriangleWave(): tmp=342 for n in range(0,TableLength): Table[n] = (2/pi) * asin(sin((2*pi*n)/TableLength)) py_plot(Table) py_plot_show() f = open("triangle.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def SineWave(): for n in range(0, TableLength): Table[n] = sin((2 * pi * n) / TableLength) py_plot(Table) py_plot_show() f = open("sine.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def SawtoothWave(): harmonics = 20 for n in range(0,TableLength): Table[n] = 0 for k in range(1,harmonics): Table[n] -= 1/(k*pi)*sin((2*k*pi*n)/TableLength) Table[n] *= 1.7 py_plot(Table) py_plot_show() f = open("sawtooth.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def SquareWave(): harmonics = 20 for n in range(0,TableLength): Table[n] = sin((2*pi*n)/TableLength) for k in range(3, 2*harmonics, 2): Table[n] += 1.0/k * sin((2*k*pi*n)/TableLength) Table[n] *= 3.3/pi py_plot(Table) py_plot_show() f = open("square.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def SawtoothWave(): harmonics = 20 for n in range(0, TableLength): Table[n] = 0 for k in range(1, harmonics): Table[n] -= 1 / (k * pi) * sin((2 * k * pi * n) / TableLength) Table[n] *= 1.7 py_plot(Table) py_plot_show() f = open("sawtooth.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
def SquareWave(): harmonics = 20 for n in range(0, TableLength): Table[n] = sin((2 * pi * n) / TableLength) for k in range(3, 2 * harmonics, 2): Table[n] += 1.0 / k * sin((2 * k * pi * n) / TableLength) Table[n] *= 3.3 / pi py_plot(Table) py_plot_show() f = open("square.txt", "w") f.write("= {") for num in Table: f.write(str(num) + ",\n") f.write("};") #print(Table) f.close()
from pylab import plot as py_plot from pylab import show as py_plot_show array=[] count=0 with open("points.txt") as f: for line in f: line=line.rstrip() array.append(line) py_plot(array) py_plot_show()
py_plot(Table) py_plot_show() fCutoff = 1.97835302 fDamping = 0.5 fLow = 0.0 fHigh = 0.0 fBand = 0.0 fDelay = [0.0, 0.0] def FilterProcess(inSample): fLow = fDelay[1] + fCutoff * fDelay[0] fHigh = fInput - fLow - fDamping * fDelay[0] fBand = fCutoff * fHigh + fDelay[0] fDelay[0] = fBand fDelay[1] = fLow return fLow if __name__ == "__main__": SquareWave() for n in range(0, len(Table)): Table[n] = FilterProcess(Table[n]) py_plot(Table) py_plot_show()