-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphs.py
47 lines (40 loc) · 1.38 KB
/
Graphs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 18 22:48:20 2019
@author: Maria Ausilia Napoli Spatafora
"""
import matplotlib.pyplot as plt
class Graphs:
def __init__(self):
pass
#It plots the waveform
def waveform(self, entry): #input read file
plt.figure()
plt.plot(entry[2])
plt.title("Waveform: {}"\
.format(entry[0]))
plt.savefig("{}_WAVE.png".format(entry[0]))
plt.show()
#It plots the frequency spectrum aftet fft
def frequency_spectrum(self, entry_fft, entry_file): #input: fft and read audio
plt.figure()
plt.xlim([10, entry_file[1]/2.])
plt.grid(True)
plt.xlabel("Frequency (Hz)")
plt.plot(entry_fft[1][:int(entry_fft[1].size/2.)], entry_fft[0][:int(entry_fft[1].size/2.)])
plt.title("Frequency Spectrum: {}"\
.format(entry_file[0]))
plt.savefig("{}_FREQ.png".format(entry_file[0]))
plt.show()
#It plots the spectrogram
def spectrogram(self, entry): #input: read file
plt.figure()
plt.specgram(entry[2], Fs = entry[1])
plt.xlabel("Time")
plt.ylabel("Frequency")
plt.xlabel("Time")
plt.ylabel("Frequency")
plt.title("Spectrogram: {}"\
.format(entry[0]))
plt.savefig("{}_SPECT.png".format(entry[0]))
plt.show()