-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
55 lines (43 loc) · 1.53 KB
/
main.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
48
49
50
51
52
53
54
from midi import midi2piece
from plots import plot_cqt
from samples import get_samples_set
from time_frequency import cqt
from signals import *
from parameters import *
import time
import sounddevice as sd
def example_1():
_sta = time.time()
_signal = signal_from_file('anastasia')
_end = time.time()
log.info("Time to recover signal: " + str(round(_end - _sta, 3)) + " seconds.")
_sta = time.time()
_spectrogram, _time_vector = cqt(_signal)
_end = time.time()
log.info("Time compute the CQT: " + str(round(_end - _sta, 3)) + " seconds.")
_sta = time.time()
plot_cqt(_spectrogram, _time_vector)
_end = time.time()
log.info("Time to plot: " + str(round(_end - _sta, 3)) + " seconds.")
if __name__ == '__main__':
# Parameters
play = True
# Create the signal
sta = time.time()
samples_set = get_samples_set('basic')
end = time.time()
log.info("Time to create samples set: " + str(round(end - sta, 3)) + " seconds.")
sta = time.time()
piece = midi2piece('prelude_em')
signal = samples_set.synthesize(piece)
end = time.time()
log.info("Time to synthesize the signal: " + str(round(end - sta, 3)) + " seconds.")
# Time-frequency transform of the signal
sta = time.time()
spectrogram, time_vector = cqt(signal)
end = time.time()
log.info("Time to compute the CQT of the signal: " + str(round(end - sta, 3)) + " seconds.")
if play:
sd.play(signal, FS)
plot_cqt(spectrogram, time_vector)
# Morphological transform of the signal