import numpy as np
import matplotlib.pyplot as plt
import scipy.io.wavfile as wav

def generate_plot(filename):

	# Read the raw signal.
	(rate, sig) = wav.read(filename)

	# Read the trimmed signal.
	filename = filename.replace("raw", "trimmed")
	filename = filename.replace("_44100", "")
	(rate_trimmed, sig_trimmed) = wav.read(filename)

	t = np.linspace(0.0, len(sig)/rate, len(sig))
	t_trimmed = np.linspace(0.0, len(sig_trimmed)/rate_trimmed, len(sig_trimmed))

	# Print the untrimmed and trimmed signal.
	plt.figure(1)

	plt.subplot(2, 1, 1)
	plt.title("Untrimmed and Trimmed Signal in the Time Domain")
	plt.ylabel("Amplitude (normalized)")
	plt.plot(t, sig/np.max(np.abs(sig)))

	# plt.subplot(2, 1, 2)
	# plt.ylabel("Amplitude (normalized)")
	# plt.xlabel("Time (s)")
	# plt.plot(t_trimmed, sig_trimmed/np.max(np.abs(sig_trimmed)))
	plt.show()
