- C 69%
- Haskell 9.9%
- C++ 9.3%
- Makefile 6.5%
- Shell 2.6%
- Other 2.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
needed because the config struct has an array instead of a pointer, so passing NULL is not possible any more |
||
| app.in | ||
| hs | ||
| lua | ||
| py | ||
| rs | ||
| windows | ||
| .gitignore | ||
| Android.mk | ||
| android.sh | ||
| audio.c | ||
| audio.h | ||
| AUTHORS | ||
| common.c | ||
| common.h | ||
| config.h | ||
| COPYING | ||
| dirt-gui.cc | ||
| dirt-imconfig.h | ||
| dirt-test.c | ||
| dirt.c | ||
| dirt.h | ||
| dirt.i | ||
| file.c | ||
| file.h | ||
| jack.c | ||
| jack.h | ||
| jobqueue.c | ||
| jobqueue.h | ||
| libdirt-example.c | ||
| libdirt.c | ||
| log-imgui.cc | ||
| log-imgui.h | ||
| log.c | ||
| log.h | ||
| logo.svg | ||
| Makefile | ||
| pitch.c | ||
| pitch.h | ||
| portaudio.c | ||
| portaudio.h | ||
| pulse.c | ||
| pulse.h | ||
| README.md | ||
| sdl2.c | ||
| sdl2.h | ||
| segment.c | ||
| segment.h | ||
| server.c | ||
| server.h | ||
| signals.dot | ||
| signals.png | ||
| thpool.c | ||
| thpool.h | ||
| zmqserv.c | ||
An unimpressive thingie for playing bits of samples with some level of accuracy.
(c) Alex McLean and contributors, 2005-2026
Released under the GNU Public Licence version 3
Based on MSG (2001) by Adrian Ward
Using Dirt
See below for how to get Dirt running on various platforms.
Once Dirt is running, send it OSC messages to trigger sounds.
See the dirt-test program and its source code for an example.
New OSC Format
Timing information is taken from OSC bundle timestamp (sent ahead of time for accurate scheduling without jitter).
Dirt listens on port 7771 by default
for messages with selector /dirt/play.
The message body contains pairs of values in sequence:
- a string containing the field name
- the corresponding value (its type depends on the field)
OSC Fields
cps
float, default 0
Cycles per second (tempo).
Used to calculate timings with unit "c".
s
string, default "" (silence)
Sound.
Name of the sample directory.
offset
float, default 0
Unused.
begin
float, default 0
Where in the sample to start playinng (0 to 1).
end
float, default 1
Where in the sample to stop playing (0 to 1).
speed
float, default 1
How fast to play the sample.
Negative plays backwards.
Affected by unit.
pan
float, default 0.5 (center)
Stereo panning (0 left to right 1).
velocity
float, default 0.5
Unused.
vowel
string, default "" (off)
Formant filter shape.
One of a e i o u.
cutoff
float, default 0 (diabled)
Low pass filter frequency in Hz.
resonance
float, default 0
Low pass filter resonance (0 to 1).
accelerate
float, default 0
Changes speed while sample is playing.
shape
float, default 0
Wave-shaping distortion.
kriole
int, default 0
Unused.
gain
float, default 1
Volume control (at the end of the effect chain).
cut
int, default 0 (off)
Triggering another sound wilh the same cut group value stops playback of currently playing sounds with that cut group.
If negative, the sample must match too for the sound to be cut.
delay
float, default 0
How much to send to the global delay effect.
delaytime
float, default -1 (off)
Set global delay effect delay time.
delayfeedback
float, default -1 (off)
Set global delay effect feedback amount (strictly betwen -1 and 1).
crush
float, default 0 (off)
Bit depth reduction. Negative uses a power 8 mapping curve.
coarse
int, default 0 (off)
Sample rate reduction. Negative uses moving average filter.
hcutoff
float, default 0 (off)
High pass filter frequency in Hz.
hresonance
float, default 0
High pass filter resonance.
bandf
float, default 0 (off)
Band pass filter frequency.
bandq
float, default 0
Band pass filter Q factor (resonance).
unit
string, default "rate"
Affects some things that depend on time.
One of rate cycle seconds.
Only the first character is significant.
loop
float, default 0 (off)
How many times to repeat playback.
n
float, default 0
Which sample file in the sound directory to play.
attack
float, default -1 (off)
Duration of attack phase of volume envelope in seconds.
hold
float, default 0
Duration of hold phase of volume envelope in seconds.
release
float, default -1 (off)
Duration of release phase of volume envelope in seconds.
orbit
int, default 0
Unused.
Old OSC Format
Dirt listens on port 7771 by default
for messages with selector /play.
The massage body starts with two ints encoding a timestamp.
The message body then contains the values for the fields
in the order listed in the source code file server.c.
This is much more awkward so the new OSC format is recommended.
Audio Signal Flow
Here is a diagram showing how the effects are organized inside Dirt's audio engine:
Samples
Dirt no longer comes with bundled audio samples.
You can get 200MB of audio samples from https://github.com/tidalcycles/Dirt-Samples/archive/refs/heads/master.zip
Unzip and rename Dirt-Samples-master/ to dirt/samples/.
The samples directory is expected to follow a certain layout:
- samples/
- that/
- sample-one.wav
- sample-two.wav
- ...
- this/
- nothing.wav
- something.wav`
- ...
- that/
Then sending /dirt/play s that n 0 will play samples/that/sample-one.wav,
and sending /dirt/play s that n 1 will play samples/this/something.wav,
because s corresponds to the folder name and n corresponds to the
zero-based index of the files inside the folder in alphabetical order.
You can change the samples root path with the -s command line
argument to dirt, or with a browser in dirt-gui.
Dirt as a Library
The programs dirt and dirt-gui are small wrappers around libdirt.
The library is modular with components that can be disabled if you want
to do those parts yourself. See libdirt-example.c for a DIY approach
to using Dirt for non-realtime rendering.
At the moment, the recommended way is to link with static libdirt.a;
the shared libraries are somewhat experimental.
Optional Dirt Library Features
Sample Loader and Cache
Dirt library supports loading samples from disk.
make LOADER=0to disable at compile timeconfig->sampleroot = NULLto disable at runtime
OSC Server
Dirt library supports listening for OSC messages.
make SERVER=0to disable at compile timeconfig->osc_port = NULLto disable at runtime
Audio Output
Dirt library supports sending audio to sound output device.
make OUTPUT=0to disable at compile timeconfig->audio_output = NULLto disable at runtime
Locking
If you disable all of the above, then you can also disable locking,
which is safe as long as you call all libdirt functions from a single
thread.
make NOLOCK=1to disable at compile time- cannot be dis/enabled at runtime
Dirt Bindings for Various Languages
C
#include <dirt.h>- link with
-ldirt
C++
#include <dirt.h>- link with
-ldirt
Haskell
See the hs/ subdirectory of the dirt repository,
which provides bare FFI bindings in Sound.Dirt.Raw,
and a more idiomatic interface in Sound.Dirt.
Lua
See the lua/ subdirectory of the dirt repository,
which provides SWIG-generated FFI bindings in dirt.
Python
See the py/ subdirectory of the dirt repository,
which provides SWIG-generated FFI bindings in dirt.
Rust
See the rs/ subdirectory of the dirt repository,
which provides FFI bindings in dirt-sys.
Other
Other languages supported by SWIG should be easy to get working, see Lua and Python for examples.
Linux
Here's how to build dirt under Debian, Ubuntu or a similar distribution:
sudo apt-get install \
build-essential git \
libsndfile1-dev libsamplerate0-dev liblo-dev \
libpulse-dev portaudio19-dev libsdl2-dev libjack-jackd2-dev \
qjackctl jackd
git clone https://github.com/ocornut/imgui.git
git clone https://github.com/AirGuanZ/imgui-filebrowser.git
git clone https://codeberg.org/uzu/dirt.git
cd dirt
make clean; make
To disable a subset of audio backends at build time:
make clean; make JACK=0 SDL2=0 PULSE=0 PORTAUDIO=0
You can run dirt directly without installing:
./dirt
To install into ~/.local/:
make clean; make; make install
To install system-wide into /usr/local/:
make clean; make; sudo make install PREFIX=/usr/local/
Starting Dirt under Linux
The history of Linux audio is complicated. Therefore there are several ways to get Dirt to talk to your hardware.
SDL2 backend
SDL2 is a cross-platform framework for realtime multimedia applications (for example, games).
The SDL2 backend is new in Dirt version 1.1, so it is not as well-tested as the JACK backend, but it is usually a lot easier to get started with:
cd ~/dirt
./dirt -o sdl2
JACK backend
JACK is a sound server designed for professional live and studio use.
First of all, start the "jack" audio layer. The easier way to do this is with the "qjackctl" app, which you should find in your program menus under "Sound & Video" or similar. If you have trouble with qjackctl, you can also try starting jack directly from the commandline:
jackd -d alsa &
If that doesn't work, you might well have something called "pulseaudio" in control of your sound. In that case, this should work:
/usr/bin/pasuspender -- jackd -d alsa &
And finally you should be able to start dirt with this:
cd ~/dirt
./dirt -o jack &
If you have problems with jack, try enabling realtime audio, and adjusting the settings by installing and using the "qjackctl" software. Some more info can be found in the Ubuntu Community page for JACK configuration
PulseAudio backend
PulseAudio is a sound server designed for desktop use.
cd ~/dirt
./dirt -o pulse
PortAudio backend
PortAudio is a cross-platform compatibility layer for audio applications.
cd ~/dirt
./dirt -o portaudio
MacOS
(These instructions haven't been tested for a while, hopefully they still work.)
Installing Dirt's dependencies on Mac OS X can be done via homebrew or MacPorts, but choose only one to avoid conflicts with duplicate system libraries.
Unless otherwise specified, the below commands should be typed or pasted into a terminal window.
Installing dependencies via Homebrew
Homebrew is a package manager for OS X. It lives side by side with the native libraries and tools that ship with the operating system.
To install homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Initialise homebrew:
brew doctor
Install Dirt, a synth (well, more of a sampler) made to work with Tidal. A homebrew 'recipe' for dirt does exist, but that doesn't come with any sounds to play with, so for now it's probably easiest just download it all from github and compile it as follows.
Install some libraries which the Dirt synth needs to compile:
brew install liblo libsndfile libsamplerate
Install the 'jack audio connection kit' which Dirt also needs:
brew install jack
If Homebrew's installation of Jack fails with a make error, you can
use the JackOSX Installer
instead. This will, however, add an additional step when installing
Dirt (see below).
Alternative: Installing dependencies via Mac Ports
MacPorts is another package manager for OS X.
If you already installed dependencies via homebrew, skip ahead to build Dirt. Otherwise if you happen to already use MacPorts, here's a list of steps in order to get all dependencies:
sudo port install liblo libsndfile libsamplerate
Download and install jack2 Jack Download Page. Jack 2 has better OS X integration Jack Comparison.
Building Dirt from source
Get the source code for the Dirt synth:
cd ~
git clone https://codeberg.org/uzu/dirt.git
Compile dirt:
cd ~/dirt
make clean; make SDL2=0 PULSE=0 PORTAUDIO=0
If Dirt fails to compile after using the JackOSX installer as above, you may need to add flags to the Makefile to specify the appropriate paths:
CFLAGS += -g -I/usr/local/include -Wall -O3 -std=gnu99 -DCHANNELS=2
LDFLAGS += -lm -L/usr/local/lib -llo -lsndfile -lsamplerate -ljack
Homebrew users
As MacPorts installs all libs on /opt/local/
edit the Makefile to point the right direction of libsndfile and libsamplerate
CFLAGS += -g -I/opt/local/include -Wall -O3 -std=gnu99
LDFLAGS += -lm -L/opt/local/lib -llo -lsndfile -lsamplerate
Starting Dirt under MacOS
To start Dirt, back in a terminal window, first start jack:
jackd -d coreaudio &
Or, if you downloaded Jack 2, then start the JackPilot at: /Applications/Jack/JackPilot.app
Click start button.
Then start dirt:
cd ~/dirt
./dirt &
Windows
Building for Windows from Linux
These instructions are for x86_64 (aka x64, amd64)
target CPU architecture, which is most Windows PCs (64bit).
ARM is starting to appear on some new laptops, and
some old systems might still be 32bit (aka x86, i686).
Adapting these instructions to other architectures is possible,
see https://mathr.co.uk/web/build-scripts.html#Prerequisites
for inspiration.
Tested on Debian Trixie, other distributions may differ.
Windows Toolchain
You need the MINGW toolchain to cross-compile for Windows,
and build-scripts needs wget.
You might also want to get Wine to test Windows programs on Linux.
sudo apt install mingw-w64 wget wine
Windows Dependencies
You need imgui, imgui-filebrowser and dirent_h
cloned next to the dirt folder:
git clone https://github.com/ocornut/imgui.git
git clone https://github.com/AirGuanZ/imgui-filebrowser.git
git clone https://github.com/win32ports/dirent_h.git
git clone https://codeberg.org/uzu/dirt.git
Use build-scripts to install
lo, samplerate, sndfile, portaudio and sdl2
for Windows:
git clone https://code.mathr.co.uk/build-scripts.git
cd build-scripts
./BUILD.sh download "lo samplerate sndfile portaudio sdl2"
./BUILD.sh x86_64-w64-mingw32 "lo samplerate sndfile portaudio sdl2"
cd ..
The sources are downloaded to ${HOME}/opt/src
and compiled output will be in ${HOME}/opt/windows/posix.
Building Dirt for Windows
cd dirt
make WINDOWS=1
You need to run make clean between non-Windows and Windows builds,
and when changing build options.
You can omit portaudio dependency if you build with:
make WINDOWS=1 PORTAUDIO=0
You can omit sdl2, imgui and imgui-filebrowser dependencies
if you build only command line Dirt:
make WINDOWS=1 SDL2=0 dirt.exe
Testing Windows Dirt on Linux with Wine
wine dirt.exe
wine dirt-gui.exe
Some versions of Wine show console output, some don't (matching Microsoft Windows). The GUI version displays messages in a window.
The EXEs should work on Microsoft Windows without needing any extra DLLs.
Building on Windows using Cygwin
(These instructions haven't been tested for a while, hopefully they still work.)
Cygwin
First, install Cygwin. In Cygwin, make sure the following packages are installed:
git
gcc-core
make
gcc-g++
libsndfile
libsndfile-devel
libsamplerate
libsamplerate-devel
Portaudio
Download Portaudio from http://www.portaudio.com. In Cygwin, Unpack
the download with tar fxvz. After unpacking, from Cygwin, go to the directory
where you unpacked Portaudio and then run:
./configure && make && make install
Liblo
Download Liblo.
In Cygwin, unpack Liblo with tar fxvz, then in Cygwin go to the directory where you
unpacked Liblo and then run:
./configure && make && make install
Dirt
In Cygwin:
git clone https://codeberg.org/uzu/dirt.git
Then:
cd dirt
make dirt-pa
Then you get a dirt-pa.exe that works. Maybe this even works on any
windows system without having to compile. You'd need cygwin1.dll at
least though.
Android
Building for Android fom Linux
If you're not hacking on Dirt's code, you can skip this section and follow the next one.
Android SDK + NDK
You need Android SDK + NDK in ${ANDROID_HOME} and ${ANDROID_NDK_HOME},
for setup on Debian Linux see:
https://mathr.co.uk/web/build-scripts.html#SDK-and-NDK.
You also need a fair amount of free disk space.
Android Dependencies
Use build-scripts to install lo, samplerate, and sndfile for Android:
git clone https://code.mathr.co.uk/build-scripts.git
cd build-scripts
for arch in download aarch64-linux-android21 armv7a-linux-androideabi21 i686-linux-android21 x86_64-linux-android21
do
./BUILD.sh "${arch}" "lo samplerate sndfile"
done
The sources are downloaded to ${HOME}/opt/src
and compiled output will be in ${HOME}/opt/android/21.
Dirt for Android uses Dear ImGui and imgui-filebrowser for user interface, the cloned respositories are expected to be next to the Dirt folder. For example:
git clone https://github.com/ocornut/imgui.git
git clone https://github.com/AirGuanZ/imgui-filebrowser.git
git clone https://codeberg.org/uzu/dirt.git
Building Dirt for Android
First you need to choose the package name of the app:
export DIRT_PACKAGE=name.domain.your.dirt.v1
A good choice is your own domain name with components in reverse order, plus the name of the app, and a version tag. It isn't preset, so that different developers can make (and sign!) their own unofficial versions that can be installed in parallel.
Dirt for Android uses SDL2 as application wrapper, to download SDL2 and set up the app do:
cd dirt
./android.sh prepare ${DIRT_PACKAGE}
Then to do a debug build and install on a connected device:
./android.sh debug ${DIRT_PACKAGE}
To do a release build (faster, requires signing):
./android.sh release ${DIRT_PACKAGE}
It will be installed on a connected device and
you should also end up with a
${DIRT_PACKAGE}-${VERSION}.apk
file in the main Dirt directory.
Installing on Android
If you're hacking on Dirt's code, you can skip this section and follow the previous one.
There is no official Dirt APK yet.
You can get an unofficial one from
https://mathr.co.uk/web/dirt.html#Android
and sideload it in the normal way.
Samples on Android
Dirt for Android doesn't come with any samples. You need to install them separately. Depending on Android version, permissions, etc, you might have to put them internal storage, and external SD card won't be recognized.
Samples are expected to be in
Storage / Android / data / ${DIRT_PACKAGE} / files / ${SAMPLES} / ${SAMPLE_NAME} / ${SAMPLE_FILE}.wav.
You can check you have the right place: starting Dirt creates
a file called README-samples-go-here.html in the relevant files folder.
To get the default Dirt samples follow these steps using your usual Android file manager (maybe you are lucky and you can replace Internal Storage with SD):
-
On your Android device, download
Dirt-Samplesas a zip archive: https://github.com/tidalcycles/Dirt-Samples/archive/refs/heads/master.zip (170MB). -
Move the zip to
Internal Storage/Android/data/${DIRT_PACKAGE}/files. -
Unzip the zip (this will take up another 225MB).
-
You can now delete the zip archive to save space.
On Dirt startup, activate the Samples Root Path button
and choose the samples folder in the file dialog:
choose the parent directory, Dirt-Samples-master,
of the folders containing the WAV files.
To avoid having to choose on every Dirt startup, you can rename
the folder to the default, ... / files / samples
using your usual Android file manager:
-
If your unzipper helpfully made an extra directory, like
master/Dirt-Samples-master, move theDirt-Samples-masterdirectory to be inside the parent directoryfiles. -
Rename the
Dirt-Samples-masterdirectory tosamples. -
You should end up
.../${DIRT_PACKAGE}/files/samples, with many folders inside, each containing WAV sample files.
Android Tips
Launch Dirt as you would any other app. You will see a configuration screen that lets you choose some settings, defaults are usually fine. Then activate the checkbox to the left of the start button to unlock it, and press the start button to start the Dirt engine.
There is no elegant way to stop or restart the Dirt engine yet, use normal Android method force stop for now (e.g. on the open apps list, swipe the Dirt app off the screen).
If the log gets too full, you can clear it: activate the checkbox to the left of the clear button to unlock it, and press the clear button to clear the log.
Dirt for Android tries to keep running in the background, but it can sometimes be stopped by the system if you open other apps that demand too many resources.
Send OSC to Dirt from your favourite tools as usual, perhaps some commmand line magic running in Debian inside the UserLAnd app installed from f-Droid.
Android Termux
Command-line Dirt can be built in Termux for Android:
pkg install \
git build-essential make portaudio \
liblo libsamplerate libsndfile
git clone https://codeberg.org/uzu/dirt.git
cd dirt
make clean
make JACK=0 SDL2=0 PULSE=0 PORTAUDIOALSA=0 dirt
./dirt
