-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchromaplot.py
More file actions
43 lines (32 loc) · 1 KB
/
Copy pathchromaplot.py
File metadata and controls
43 lines (32 loc) · 1 KB
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
import matplotlib.pyplot as plot
import numpy as np
from scipy.io import wavfile
import librosa, librosa.display
# Read the wav file (mono)
audioPath ='resources/Feel_Like_Makin_Love/sing-1s.wav'
samplingFrequency, signalData = wavfile.read(audioPath)
def plot_amplitude():
plot.subplot(211)
plot.plot(signalData)
plot.xlabel('Sample')
plot.ylabel('Amplitude')
def plot_spectrogram():
plot.subplot(212)
plot.specgram(signalData,Fs=samplingFrequency)
plot.xlabel('Time')
plot.ylabel('Frequency')
N = 4096
H = 32
eps = np.finfo(float).eps
def plot_chromagram():
plot.subplot(212)
x, Fs = librosa.load(audioPath, sr=samplingFrequency)
C = librosa.feature.chroma_stft(y=x, sr=Fs, tuning=0, norm=None, hop_length=H)
plot.figure(figsize=(8, 2))
librosa.display.specshow(10 * np.log10(eps + C), x_axis='time',
y_axis='chroma', sr=Fs, hop_length=H)
plot.colorbar();
plot_amplitude()
plot_spectrogram()
plot_chromagram()
plot.show()