FFTW2CSOUND version 0.02 (november 5, 2021)

 A C++ program that analyses audio files, producing Csound orchestra files.
 It uses the famous FFTW library (and its MFFM C++ wrapper) for STFT analysis.
 The generated Csound orchestra file can be used for audio resynthesis, it
 contains (lots of) starttimes, durations and linear amplitudes.
 The program can only read AIFF input files, and it only reads the first audio
 channel. Any samplerate can be used. Before STFT analysis, audio input is time-
 windowed by a 4-term Blackman-Harris window.

 Note that phase information from the Fourier analysis is disregarded, only the
 power spectrum is used. Like early days, with for example Ceres on SGI (1998).

 Sound effects --like time stretching and pitch shifting-- may be created by
 hacking function csoundline() in file fftw2csound.cpp.
 Please let me know if you find errors: pieter.suurmond@ecomaan.nl

 Latest version available at: https://ecomaan.nl/cpp/fftw2csound/

 COPYLEFT 2020 2021 Schreck Ensemble

DOWNLOAD SOURCECODE
===================
These are the most important files in this directory:

    fftw2csound                         Precompiled binary for linux AMD 64 bit.
    fftw2csound.cpp                     C++ sourcefile.
                                        Best documentation is that file itself.
    Makefile                            For [re]compilation.
    rdaiff.cpp                          C++-class to read AIFF files.
    rdaiff.hpp
    README
    resynth.orc                         Resynth with Blackman-Harris envelope.
    resynth.sco                         Just for testing our resynth-envelope.

Some analysis-resynthesis examples are included:

    Sine440.aiff
    Sine440resynthBAD.wav               (see parameters below)
    Sine440resynthBETTER.wav            (see parameters below)
    Susato2011.aiff                     Schreck Ensemble recording snippet.
    Susato2011resynth.wav               (Not too bad! see parameters below)

Download this complete directory: fftw2csound-0.02.tar.gz
Older version (january 27, 2021): fftw2csound-0.01.tar.gz

COMPILE SOURCECODE
==================
Before compilation, make sure the following packages are installed:

    g++                 A C++ compiler.
    libfftw3
    libfftw3-dev
   (libfftw3-doc        Just handy to have the documentaion on your own machine.
    mffm-fftw-dev
    mffm-fftw1

Then simply type 'make' on the commandline to compile the fftw2csound program.

RUNNING
=======
The following command analyses an audiofile named Sine440.aiff, with a window of
1000 samples, a hop size of 249 and a FFT size of 8192 (to boost frequency reso-
lution by more than a factor 8). It generates a textfile named Sine440.aiff.sco.

   ./fftw2csound 1000 249 8192 Sine440.aiff

To test the score file, run CSound and listen to the resynthesis:

   csound -o Sine440resynthBAD.wav -W resynth.orc Sine440.aiff.sco

Amplitude modulation and side-bands, a horrible reproduction!
Much better results may be achieved by using an overlap of 5 (instead of 4):

    ./fftw2csound 1000 200 8192 Sine440.aiff

This overwrites the previously written scorefile Sine440.aiff.sco so we can run
CSound again:

    csound -o Sine440resynthBETTER.wav -W resynth.orc Sine440.aiff.sco

Another example (also with overlap 5) where FFT size is twice as large as the
window size are equal (frequency resolution boost by a factor 2):

   ./fftw2csound 5000 1000 10000 Susato2011.aiff
   csound -o Susato2011resynth.wav -W resynth.orc Susato2011.aiff.sco

Remark: For now, I get the best results with overlap 5 (whereas the theory 
predicts that 4 would be best, in case of using Blackman-Harris)... Hmm...

-----
Happy hacking!