~led/faustcgp

Create DSP programs in FAUST via Recurrent Cartesian Genetic Programming.
Update copyright
Update CHANGELOG.md
Adjust MFCC count and frequency range

clone

read-only
https://git.sr.ht/~led/faustcgp
read/write
git@git.sr.ht:~led/faustcgp

You can also use your local clone with git send-email.

REUSE status Keep a Changelog badge

#FaustCGP

Generate new audio synthesizers and filters in FAUST with Recurrent Cartesian Genetic Programming [1] [2]. Given a target sound or impulse response as input, the RCGP will return a FAUST synthesizer or filter, respectively, that best approximates the given signal or impulse response.

#Build

#Dependencies

On Arch-based Linux distributions (preferred, as this is the main distribution for development):

sudo pacman -Syu --needed faust fftw libsndfile graphviz parallel r

On Debian-based Linux distributions, the following command may work for Debian "sid" and Ubuntu 22.10:

sudo apt install faust libfftw3-dev libsndfile1-dev graphviz parallel r-base

Otherwise, LLVM and FAUST might need to be installed manually for the time being:

# install and configure LLVM
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo ln -s /usr/bin/llvm-config-15 /usr/bin/llvm-config

# install additional dependencies to build FAUST
sudo apt install build-essential cmake libmicrohttpd-dev pkg-config

# build and install FAUST from source
git clone https://github.com/grame-cncm/faust.git
cd faust
make all
sudo make install
sudo ldconfig

# install remaining FaustCGP dependencies
sudo apt install libfftw3-dev libsndfile1-dev graphviz parallel r-base

Similarly, on Fedora/RPM-based Linux distributions:

# install FAUST dependencies
sudo dnf install cmake llvm-devel libmicrohttpd-devel

# build and install FAUST from source
git clone https://github.com/grame-cncm/faust.git
cd faust
make all
sudo make install
sudo ldconfig /usr/local/lib

# install remaining FaustCGP dependencies
sudo dnf install fftw-devel libsndfile-devel graphviz parallel R
#Compiling the Programs

Simply run make from the project root directory, which will compile the needed binaries and place them in the bin directory.

To delete the binaries and reset the build process, run make clean.

#Usage

See the -?/--help option for detailed usage of each program.

#Audio Synthesizer
./bin/audio2cgp -o audio.data path/to/input.wav
./bin/cgp2faust -o output.dsp audio.data
#Audio Effect Chain
./bin/faust2cgp -o filter.data path/to/input.dsp
./bin/cgp2faust -e -o output.dsp filter.data

#Testing

#Synth Mode

Running make sharc_test TEST_DIR=path/to/test will clone and analyze the SHARC timbre database [3], then run the cgp2faust program in synth mode in the background across a selected number of tones. Requires GNU parallel in order to run the test across as many CPU cores as possible.

Once completed, the output files can be analyzed with make sharc_results TEST_DIR=path/to/test, which will perform the following steps:

  1. Extract the fitness values and other information from the audio files and save them into fitness.csv files.
  2. Extract the functions used in the program graphs and save them into nodes.csv files.
  3. If Graphviz is installed, convert the .dot files to .pdf for ease of viewing graphs.
  4. Read and run statistical analysis on the .csv files via the provided R scripts.

#Effect Mode

Running make filter_test will perform a similar test, but using an inverse filter from MIT's KEMAR database [4] as a target instead. Likewise, make filter_results will read and analyze the data from this test.

#License

See each individual file for details, but in short:

In addition, all FAUST source code produced by the compiled binaries are licensed under MIT, and any generated audio files likewise under CC-BY-SA-4.0.

#Publications

This software has been featured in the following research publications:

E. Ly and J. Villegas, "Digital Filter Design via Recurrent Cartesian Genetic Programming," IEEE 13th International Workshop on Computational Intelligence and Applications (IWCIA), Hiroshima, Japan, Nov. 2023, pp. 7-12.

E. Ly and J. Villegas, "Cartesian Genetic Programming Parameterization in the Context of Audio Synthesis," IEEE Signal Processing Letters, vol. 30, Aug. 2023, pp. 1077-1081.

E. Ly and J. Villegas, "Additive Synthesis via Recurrent Cartesian Genetic Programming in FAUST," 153rd AES Fall Convention, New York, Oct. 2022, pp. 1-7.

#References

[1] A. J. Turner and J. F. Miller, "Introducing A Cross Platform Open Source Cartesian Genetic Programming Library," Genetic Programming and Evolvable Machines, vol. 16, 2014, pp. 83-91.

[2] A. J. Turner and J. F. Miller, "Recurrent Cartesian Genetic Programming," 13th International Conference on Parallel Problem Solving from Nature (PPSN XIII), Cham: Springer, 2014, pp. 476-486.

[3] G. J. Sandell, "A Library of Orchestral Instrument Spectra" (GitHub), 1991 International Computer Music Conference, Michigan Publishing, 1991, pp. 98-101.

[4] B. Gardner and K. Martin, "HRTF Measurements of a KEMAR Dummy-Head Microphone," Perceptual Computing - Technical Report #280, Cambridge: MIT Media Lab, 1994, pp. 1-7.