FFT re-aragenment in Python

2020-01-21

SFFT of piece

SFFT of a section of the generated piece

Playing around with fft we can rearrange the samples that make up an digital audio file in new ways.

from scipy.fft import rfft, irfft
from scipy.io import wavfile
import numpy as np

sr, data = wavfile.read('some_file.wav')
audio_fft = rfft(data)
wavfile.write(
    'foo.wav',
    sr,
    irfft(audio_fft[::-1]).reshape(-1)/2**16,  # scale down to 16 bit
)