Module used to handle compute the Barwise TF matrix, presented in [1]
(Barwise TF matrix: a 2D representation of barwise features,
each feature representing Time-Frequency content, where time is expressed at barscale)
See [1 - Chapter 2.4] or [2] for more information.
References
----------
[1] Unsupervised Machine Learning Paradigms for the Representation of Music Similarity and Structure,
PhD Thesis Marmoret Axel
(not uploaded yet but will be soon!)
(You should check the website hal.archives-ouvertes.fr/ in case this docstring is not updated with the reference.)
[2] Marmoret, A., Cohen, J.E, and Bimbot, F., "Barwise Compression Schemes
for Audio-Based Music Structure Analysis"", in: 19th Sound and Music Computing Conference,
SMC 2022, Sound and music Computing network, 2022.
"""
importas_seg.data_manipulationasdm
importas_seg.model.errorsaserr
importnumpyasnp
importtensorlyastl
importlibrosa
# %% Tensors barwise spectrograms construction
# !!! Be extremely careful with the organization of modes, which can be either Frequency-Time at barscale-Bars (FTB) or Bars-Frequency-Time at barscale (BFT) depending on the method.
Module used to handle compute the Barwise TF matrix, presented in [1]
(Barwise TF matrix: a 2D representation of barwise features,
each feature representing Time-Frequency content, where time is expressed at barscale)
See [1 - Chapter 2.4] or [2] for more information.
References
----------
[1] Unsupervised Machine Learning Paradigms for the Representation of Music Similarity and Structure,
PhD Thesis Marmoret Axel
(not uploaded yet but will be soon!)
(You should check the website hal.archives-ouvertes.fr/ in case this docstring is not updated with the reference.)
[2] Marmoret, A., Cohen, J.E, and Bimbot, F., "Barwise Compression Schemes
for Audio-Based Music Structure Analysis"", in: 19th Sound and Music Computing Conference,
SMC 2022, Sound and music Computing network, 2022.
"""
importas_seg.data_manipulationasdm
importas_seg.model.errorsaserr
importnumpyasnp
importtensorlyastl
importlibrosa
# %% Spectrograms to tensors
# !!! Be extremely careful with the organization of modes, which can be either Frequency-Time at barscale-Bars (FTB) or Bars-Frequency-Time at barscale (BFT) depending on the method.
iflen(samples)!=len(set(samples)):# Check for repetitions
ifidx!=len(bars_idx)-1:# It's not a problem if it's the last bar, because it is due to inconsistencies between the last downbeat estimated and the end of the song.
raiseerr.ToDebugException("The subdivision is too large, it leads to repeated samples chosen in the bar!")