import argparse
import numpy as np
import matplotlib.pyplot as plt
from FAUSTPy import *

#######################################################
# set up command line arguments
#######################################################

parser = argparse.ArgumentParser()
parser.add_argument('-f', '--faustfloat',
                    dest="faustfloat",
                    default="float",
                    help="The value of FAUSTFLOAT.")
parser.add_argument('-p', '--path',
                    dest="faust_path",
                    default="",
                    help="The path of FAUSTFLOAT.")
parser.add_argument('-c', '--cflags',
                    dest="cflags",
                    default=[],
                    type=str.split,
                    help="Extra compiler flags")
parser.add_argument('-s', '--fs',
                    dest="fs",
                    default=48000,
                    type=int,
                    help="The sampling frequency")
args = parser.parse_args()

#######################################################
# initialise the FAUST object and get the default parameters
#######################################################

wrapper.FAUST_PATH = args.faust_path

dattorro = FAUST("dattorro_notch_cut_regalia.dsp", args.fs, args.faustfloat,
                 extra_compile_args=args.cflags)

#######################################################
# plot the frequency response with the default settings
#######################################################

audio = np.zeros((dattorro.dsp.num_in, args.fs), dtype=dattorro.dsp.dtype)
audio[:,0] = 1

out = dattorro.compute(audio)

print(audio)
print(out)

spec = np.fft.fft(out)[:,:args.fs/2]

fig = plt.figure()
p   = fig.add_subplot(1,1,1)
p.plot(20*np.log10(np.absolute(spec.T)+1e-8))

################
# show the plots
################

plt.show()

print("everything passes!")

import argparse
import numpy as np
import matplotlib.pyplot as plt
from FAUSTPy import *

#######################################################
# set up command line arguments
#######################################################

parser = argparse.ArgumentParser()
parser.add_argument('-f', '--faustfloat',
                    dest="faustfloat",
                    default="float",
                    help="The value of FAUSTFLOAT.")
parser.add_argument('-p', '--path',
                    dest="faust_path",
                    default="",
                    help="The path of FAUSTFLOAT.")
parser.add_argument('-c', '--cflags',
                    dest="cflags",
                    default=[],
                    type=str.split,
                    help="Extra compiler flags")
parser.add_argument('-s', '--fs',
                    dest="fs",
                    default=48000,
                    type=int,
                    help="The sampling frequency")
args = parser.parse_args()

#######################################################
# initialise the FAUST object and get the default parameters
#######################################################

wrapper.FAUST_PATH = args.faust_path

dattorro = FAUST("dattorro_notch_cut_regalia.dsp", args.fs, args.faustfloat,
                 extra_compile_args=args.cflags)

def_Q = dattorro.dsp.dattorro_notch_cut_regalia.Q
def_Gain = dattorro.dsp.dattorro_notch_cut_regalia.Gain
def_Freq = dattorro.dsp.dattorro_notch_cut_regalia.Center_Freq_

#######################################################
# plot the frequency response with the default settings
#######################################################

audio = np.zeros((dattorro.dsp.num_in, args.fs), dtype=dattorro.dsp.dtype)
audio[:,0] = 1

out = dattorro.compute(audio)

print(audio)
print(out)

spec = np.fft.fft(out)[:,:args.fs/2]

fig = plt.figure()
p   = fig.add_subplot(
    1,1,1,
    title="Frequency response with the default settings\n"
          "(Q={}, F={:.2f} Hz, G={:.0f} dB FS)".format(
              def_Q.zone, def_Freq.zone, 20*np.log10(def_Gain.zone+1e-8)
          ),
    xlabel="Frequency in Hz (log)",
    ylabel="Magnitude in dB FS",
    xscale="log"
)
p.plot(20*np.log10(np.absolute(spec.T)+1e-8))
p.legend(("Left channel", "Right channel"), loc="best")

################
# show the plots
################

plt.show()

print("everything passes!")

make the plot look nicer.