Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Faust2touchdesigner #23

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
submodules: true

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -45,20 +45,21 @@ jobs:
env:
PYTHONVER: ${{ matrix.python-version}}

- name: Build Reverb operator
shell: cmd
run: |
set PATH=%CD%/thirdparty/libfaust/win64/Release/bin;%PATH%
python faust2td.py --dsp reverb.dsp --type "Reverb" --label "Reverb" --icon "Rev" --author "David Braun" --email "github.com/DBraun" --drop-prefix

- name: Make distribution
run: |
mkdir TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
move ${{ github.workspace }}/Plugins/TD-Faust.dll TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
move ${{ github.workspace }}/Plugins/sndfile.dll TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
cp -v -r ${{ github.workspace }}/Plugins/faustlibraries TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
Remove-Item -Recurse -Force "TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}/faustlibraries/.git"
7z a TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}.zip ./TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}/* -r
Remove-Item -Recurse -Force "${{ github.workspace }}/Plugins/faustlibraries/.git"

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
path: TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}.zip
path: Plugins

# build-macos:
# strategy:
Expand All @@ -74,7 +75,7 @@ jobs:
# submodules: true

# - name: Setup Python 3.8
# uses: actions/setup-python@v2
# uses: actions/setup-python@v5
# with:
# python-version: '3.8'

Expand All @@ -91,16 +92,21 @@ jobs:
# python3 --version
# sh -v build_macos.sh

# - name: Build Reverb operator
# shell: cmd
# run: |
# export PATH=$PWD/thirdparty/libfaust/darwin-x64/Release/:$PWD/thirdparty/libfaust/darwin-arm64/Release/:$PATH
# python faust2td.py --dsp reverb.dsp --type "Reverb" --label "Reverb" --icon "Rev" --author "David Braun" --email "github.com/DBraun" --drop-prefix

# - name: Make distribution
# run: |
# rm -rf Plugins/faustlibraries/.git
# zip -r TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}.zip Plugins

# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
# path: TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}.zip
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: TD-Faust-${{ matrix.name }}-Python${{ matrix.python-major }}
# path: Plugins

create-release:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ CrashAutoSave*
Backup/*
Release/
Debug/
build/*
build*
TD-Faust.[0-9]*.toe
SketchSynth.[0-9]*.toe
*dsp.json

# Prerequisites
*.d
Expand Down
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TD-Faust

TD-Faust is an integration of [FAUST](https://faust.grame.fr) (**F**unctional **AU**dio **ST**ream) and [TouchDesigner](https://derivative.ca/). The latest builds are for TouchDesigner 2022.25370 and newer. Older TD-Faust builds can be found in the [Releases](https://github.com/DBraun/TD-Faust/releases).
TD-Faust is an integration of [FAUST](https://faust.grame.fr) (**F**unctional **AU**dio **ST**ream) and [TouchDesigner](https://derivative.ca/). The latest builds are for TouchDesigner 2023.11290 and newer. Older TD-Faust builds can be found in the [Releases](https://github.com/DBraun/TD-Faust/releases).

## Overview

Expand All @@ -23,6 +23,31 @@ Demo / Tutorial:

Examples of projects made with TD-Faust can be found [here](https://github.com/DBraun/TD-Faust/wiki/Made-With-TD-Faust). Contributions are welcome!

## Building a Custom Operator

The previous overview was about using a multi-purpose CHOP to dynamically compile Faust code inside TouchDesigner. Although it's powerful, you have to specify the DSP code, press the `compile` parameter, and then begin modifying the CHOP's parameters. Ordinary CHOPs can be created from the Op Create Dialog and don't require nearly as much setup, but they are narrower in purpose. What if you want to use Faust to create a more single-purpose CHOP such as a dedicated Reverb CHOP? In this case, you should use the `faust2touchdesigner.py` script.

These are the requirements:

* Download libfaust by going to `thirdparty/libfaust` and running either `call download_libfaust.bat` on Windows or `sh download_libfaust.sh` on macOS.
* Pick a Faust DSP file such as `reverb.dsp` that defines a `process = ...;`.
* Python should be installed.
* CMake should be installed.

If on Windows, you should open an x64 Native Tools for Visual Studio command prompt. On macOS, you can use Terminal. Then run a variation of the following script:

```bash
python faust2td.py --dsp reverb.dsp --type "Reverb" --label "Reverb" --icon "Rev" --author "David Braun" --email "github.com/DBraun" --drop-prefix
```

Limitations and Gotchas:
* The example script above overwrites `Faust_Reverb_CHOP.h`, `Faust_Reverb_CHOP.cpp`, and `Reverb.h`, so avoid changing those files later.
* Polyphonic instruments have not been implemented.
* MIDI has not been implemented.
* The `soundfile` primitive has not been implemented (`waveform` is ok!)
* CHOP Parameters are not "smoothed" automatically, so you may want to put `si.smoo` after each `hslider`/`vslider`.
* File a GitHub issue with any other problems or requests. Pull requests are welcome too!

## New to FAUST?

* Browse the suggested [Documentation and Resources](https://github.com/grame-cncm/faust#documentation-and-resources).
Expand All @@ -37,7 +62,7 @@ Examples of projects made with TD-Faust can be found [here](https://github.com/D

Visit TD-Faust's [Releases](https://github.com/DBraun/TD-Faust/releases) page. Download and unzip the latest Windows version. Copy `TD-Faust.dll` and the `faustlibraries` folder to this repository's `Plugins` folder. Open `TD-Faust.toe` and compile a few examples.

If you need to compile `TD-Faust.dll` yourself, you should first install [Python 3.9](https://www.python.org/downloads/release/python-3910/) to `C:/Python39/` and confirm it's in your system PATH. You'll also need Visual Studio 2022 and CMake. Then open a cmd window to `thirdparty/libsndfile` and run `call download_libfaust.bat`. Then you can open a cmd window to this repo's root directory and run `call build_windows.bat`.
If you need to compile `TD-Faust.dll` yourself, you should first install [Python 3.11](https://www.python.org/downloads/release/python-3117/) to `C:/Python311/` and confirm it's in your system PATH. You'll also need Visual Studio 2022 and CMake. Then open a cmd window to `thirdparty/libsndfile` and run `call download_libfaust.bat`. Then you can open a cmd window to this repo's root directory and run `call build_windows.bat`.

### macOS

Expand All @@ -53,7 +78,7 @@ TD-Faust is designed for macOS version 11.0 and later. Also, macOS users need to
4. Install requirements with [brew](http://brew.sh/): `brew install autoconf autogen automake flac libogg libtool libvorbis opus mpg123 pkg-config`
5. In a Terminal window, navigate to `thirdparty/libfaust` and run `sh download_libfaust.sh`.
6. In a Terminal Window, export a variable to the TouchDesigner.app to which you'd like to support. For example: `export TOUCHDESIGNER_APP=/Applications/TouchDesigner.app`, assuming this version is a 2022.22650 build or higher.
7. Optional: depending on the Python version associated with the TouchDesigner you intend to use, run `export PYTHONVER=3.9` or `export PYTHONVER=3.11`.
7. Optional: depending on the Python version associated with the TouchDesigner you intend to use, run `export PYTHONVER=3.11` or `export PYTHONVER=3.9`.
8. In the same Terminal window, navigate to the root of this repository and run `sh build_macos.sh`
9. In a Terminal window, navigate to the root of this repository and run `sh build_macos.sh`.
10. Open `TD-Faust.toe`
Expand Down
2 changes: 1 addition & 1 deletion build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo Assuming TouchDesigner is located at $TOUCHDESIGNER_APP

if [ "$PYTHONVER" == "" ]; then
# Guess which Python version TD uses.
export PYTHONVER=3.9
export PYTHONVER=3.11
fi
echo Building for Python $PYTHONVER

Expand Down
2 changes: 1 addition & 1 deletion build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rem rm Plugins/TD-Faust.dll
rm build/CMakeCache.txt

if "%PYTHONVER%"=="" (
set PYTHONVER=3.9
set PYTHONVER=3.11
)
echo "Using Python version: %PYTHONVER%"

Expand Down
Loading