Index of /cpp/fftw2csound

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[   ]Makefile2021-11-05 21:55 583  
[TXT]README.html2021-11-17 22:08 5.2K 
[SND]Sine440.aiff2021-11-05 21:55 1.3M 
[SND]Sine440resynthBAD.wav2021-11-05 21:55 2.6M 
[SND]Sine440resynthBETTER.wav2021-11-05 21:55 2.6M 
[SND]Susato2011.aiff2021-11-05 21:55 2.0M 
[SND]Susato2011resynth.wav2021-11-05 21:55 2.0M 
[   ]fftw2csound2021-11-17 21:56 38K 
[TXT]fftw2csound.cpp2021-11-17 21:56 9.4K 
[IMG]parabolic.jpg2021-11-17 21:56 373K 
[TXT]rdaiff.cpp2021-11-05 21:55 24K 
[TXT]rdaiff.hpp2021-11-05 21:55 7.8K 
[TXT]resynth.orc2021-11-05 21:55 1.3K 
[TXT]resynth.sco2021-11-05 21:55 296  

C++ class to read AIFF files
 FFTW2CSOUND version 0.03 (november 17, 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. During STFT analysis, audio input is time-
 windowed with a 4-term Blackman-Harris window.

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

 This version applies spectral peak-finding and uses parabolic interpolation to
 approximate the peaks.

 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 bugs: 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.03.tar.gz
                  Older versions: fftw2csound-0.02.tar.gz
                                  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
=======
Running the program without parameters explains how to use it:

   ./fftw2csound

   Usage: fftw2csound WINS HOPS FFTS FILE
   where WINS is the input time window size in samples, not bound to a power of 2.
         HOPS is the hop size, best about 1/5th (or less) than the window size
              when using a Blackman-Harris shaped window.
              Ratio WINS : HOPS determines the overlap.
         FFTS is the FFT input size. It may be much larger than the window size
              (to increase resolution), but not smaller. Not bound to powers of 2.
         FILE is the pathname of the input AIFF file to be anaysed.
              Only the first channel of a multichannel file is read.

The following example 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!
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: Best results are achieved with overlap ≥5 (whereas theory 
predicts that 4 would be best, in case of using Blackman-Harris...
Hmm... yes, that is because phase information is diregarded here.)

PARABOLIC INTERPOLATION:
========================
Here is how I derived the calculation:


---
Happy hacking!