Commit ee81020e authored by Marie Tahon's avatar Marie Tahon
Browse files

add input for reference signal in params.py

parent 0ad894e0
......@@ -17,6 +17,8 @@ Modifiable parameters are located in params.py.
```
begin = 0.0 # start reading audio file after this time in seconds.
duration = 60 # read audio file between (begin) and (begin + duration)
begin_ref = 0.0 # beginning of the reference signal for computing cosine distance between clusters (in seconds).
end_ref = 0.05 # end of the reference signal for computing cosine distance between clusters (in seconds).
BINS_PER_OCTAVE = 12*3 # number of bins per octave, a multiple of 12 is suitable
N_OCTAVES = 7 # number of considered octaves
NFFT = 2**11 # number of points of the analysis window, a multiple of 2 is suitable (> 2**6)
......@@ -60,7 +62,7 @@ Usage:
python3 TF_differential.py audio/filename.wav
```
From an original idea of Jean-Marc Chouvel (http://www.ems-network.org/spip.php?article294).
From an original idea of Jean-Marc Chouvel [L'analyse musicale différentielle](http://www.ems-network.org/IMG/JMChouvelEMS07/index.html).
### Bibliography
* B. McFee and D P.W. Ellis (2014). Analyzing song structure with spectral clustering. In proc. of International Society for Music Information Retrieval.
......
#general load WAV
begin = 0.0 #start reading the analysed signal after this time (in seconds)
duration = 60*2 # duration of the analysed signal (in seconds).
begin_ref = 0.0 #beginning of the reference signal for computing cosine distance between clusters (in seconds).
end_ref = 0.05 #end of the reference signal for computing cosine distance between clusters (in seconds).
BINS_PER_OCTAVE = 12 * 3
N_OCTAVES = 7
NFFT = 2 ** 11 #(> 2**10) duration of analysis window in samples for feature extraction only.
......@@ -26,8 +28,8 @@ cluster_dist = True # add cosine distance between clusters on final plot
cluster_nb_max = 5 #maximum nb of clusters in 1 sec.
#plots
plot_simi = False
plot_struct = False
plot_dist = False
plot_simi = True
plot_struct = True
plot_dist = True
plot_features = True
timestamps = True
......@@ -564,6 +564,12 @@ def extract_distance_between_clusters(center_clusters, type_dist = 'cos'):
return distance
def extract_ref_signal(X, onset_times):
ind = np.where((onset_times >= params.begin_ref) & (onset_times < params.end_ref))
return X[ind,:]
def main():
......@@ -585,7 +591,6 @@ def main():
#extract acoustic feature from audio signal feat is a matrix np.array((nb features, Tmax*sr/STEP))
feat = feature_extraction(y, sr, params.opt_tuning)
#extract onset indexes and times + onset-synchronous CQT transform on onsets.
onsets, onset_times, Csync = extract_onsets(y, sr, args.manual_onset)
......@@ -651,6 +656,7 @@ def main():
#if needed compute the cosine distance between each cluster and a reference taken at the very begining of th signal
#KM.cluster_centers_ : array, [n_clusters, n_features]
if params.cluster_dist:
ref_signal = extract_ref_signal(X, onset_times)
distance_cosine_cluster = extract_cosine_distance_clusters( KM.cluster_centers_, np.mean(X[:10*NFFT,:], axis=0))
else:
distance_cosine_cluster = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment