fourMs / MGT-python

Musical Gestures Toolbox for Python
https://www.uio.no/ritmo/english/research/labs/fourms/downloads/software/musicalgesturestoolbox/mgt-python/index.html
GNU General Public License v3.0
52 stars 11 forks source link

Harmonic/percussive waveform #301

Closed alexarje closed 1 year ago

alexarje commented 1 year ago

It would be nice to make [https://librosa.org/doc/latest/generated/librosa.display.waveshow.html](harmonic/percussive waveforms) (in addition to the spectrograms currently implemented).

y_harm, y_perc = librosa.effects.hpss(y)
librosa.display.waveshow(y_harm, sr=sr, alpha=0.5, label='Harmonic')
librosa.display.waveshow(y_perc, sr=sr, color='r', alpha=0.5, label='Percussive')

joachimpoutaraud commented 1 year ago

I have added the possibility to make harmonic/percussive source separation on waveforms. For this, you just need to specify a number of dimensions parameter corresponding to dim=1 (waveform) and dim=2 (spectrogram).

So if you want to render hpss with a waveform visualization you can write the following:

import musicalgestures
source_video = musicalgestures.MgVideo('path_to_your_video') 
source_video.audio.hpss(dim=1)