capital-G / musikinformatik-sose2021

Course materials for Musikinformatik course SoSe 2021 at RSH Düsseldorf
https://capital-g.github.io/musikinformatik-sose2021/
6 stars 2 forks source link

some intermediate steps #52

Closed telephon closed 2 years ago

telephon commented 3 years ago

I think it would help the students if we add some more basic transformations of the FFT before doing the sorting via ML techniques.

here are some suggestions:

## reconstruction of the original
data_inverted = librosa.istft(data_fft, hop_length=HOP_LENGTH, win_length=WIN_LENGTH)
display(Audio(data_inverted, rate=sr))

## backwards
data_fft_shifted = np.flip(data_fft, axis=1)
data_shifted = librosa.istft(data_fft_shifted, hop_length=HOP_LENGTH, win_length=WIN_LENGTH)
display(Audio(data_wo_phase, rate=sr))

## inverted spectrum
data_fft_shifted = np.flip(data_fft, axis=0)
data_shifted = librosa.istft(data_fft_shifted, hop_length=HOP_LENGTH, win_length=WIN_LENGTH)
display(Audio(data_wo_phase, rate=sr))

## scrambled spectrum
import random
data_fft_shuffled = data_fft.copy()
random.shuffle(data_fft_shuffled)
data_shuffled = librosa.istft(data_fft_shuffled, hop_length=HOP_LENGTH, win_length=WIN_LENGTH)
display(Audio(data_shuffled, rate=sr))

then it would be nice to have something similar to the following sclang transformations in python, of course only if there is a simple equivalent:

n = data_fft.size;
Array.fill(n, { if(0.3.coin) { 1 } { 0 } }) * data_fft
Array.fill(n, { |i| if(i.linlin(0, n, 0, 1).coin) { 1 } { 0 } }) * data_fft
data_fft.rotate(n div: 2)
capital-G commented 2 years ago

I think this is implemented via #59 which does a deep dive on FFT. if not feel free to re-open again.