RTG (Rhythm, Time and Geometry) is a Haskell library for the creation and manipulation of rhythmic patterns implementing a creative interface exploring
- The two way relation between musical rhythm and geometric structure
- Computational abstractions and implementations of musical time.
It is part of my doctoral research project on the affordances of programming language abstractions in music language design and implementation, particularly in the context of live coding. It addresses the following question: how programming language expressiveness translates to musical expressiveness for composition and live performance.
Alternative implementations and options:
- FRP implementations.
- MUIs from "The Haskell School of Music"
- Tidal Cycles
- AFRP: Yampa
- API design
- Parsing: parsec library
- Audio
- OSC: hosc
- MIDI: Euterpea
Current implementation:
- Asynchronous evaluation of patterns
- Homogenize rhythmic pattern types show function. Each type should be tagged appropriately
- Scheduling options for event streams: homogeneous using the binary representation (congruent with the rhythmic pattern abstraction) or heterogeneous using a rationals (to avoid sending silence messages)
- Implement pattern sync
- Make patterns addressable so they can be stopped (¿in global state?)
- A switch to make new scheduled patterns affect current playing patterns
- Implement well-formed rhythms (¿3 parameters?)
- Continuous morphing of well-formed rhythms using ratio parameter
- Have signals for parameter control (for morphing)
- Geometrically informed continuous morphing between two arbitrary rhythms
This project uses the Nix package manager to achieve a reproducible cross-platform development environment, necessary for interacting with the library. Another advantage of this method is that it abstracts away the installation of Haskell and reduces dependency compilation thanks to the Nix binary cache, which covers a large part of the packages in its repository. Below are the steps to install the required components.
- Install Nix Package Manager. Nix provides installation scripts that can be run with the following commands:
- On Linux:
sh <(curl -L https://nixos.org/nix/install) --daemon
. - On MacOS:
sh <(curl -L https://nixos.org/nix/install)
. - On Windows, you need WSL with systemd enabled:
sh <(curl -L https://nixos.org/nix/install) --daemon
.
- On Linux:
- Install SuperDirt (audio engine).
- Install SuperCollider and, to have all the predefined synths, the sc3-plugins. Both are accessible through the package manager in various Linux distributions.
- With the SuperCollider interpreter (
sclang
) running, executeQuarks.checkForUpdates({Quarks.install("SuperDirt", "v1.7.3"); thisProcess.recompile()})
.
- Clone this repository.
- From the root of the repository, run
nix-shell --run 'cabal repl'
. Nix will proceed to download (and, if necessary, compile) the library dependencies. This process may take some time, but subsequent invocations will be almost immediate as long as the Nix store is not cleaned (withnix-collect-garbage
ornix-store --gc
for example). If the process completes successfully, a shell environment will start with the necessary tools and dependencies for RTG, it will compile the library and open a Haskell interpreter (ghci
) session with the library loaded.- In case of error, please open an issue with the output.
- Follow the usage instructions to test the functions exported by each of the modules.
- To exit the session, run
:quit
in the command line.
Start the SuperDirt: Open SuperCollider (or run sclang
from a terminal) and runt (Ctrl+Enter) SuperDirt.start
.
This will load the audio engine and load its standard samples.
Alternatively, or in case of SuperCollider error messages regarding the buffer or late messages, run the following SuperDirt configuration file containing optimization options:
archivo
Open a terminal at the repository root (where this
file is located) and run nix-shell --run 'cabal repl'
to open an interpreter loaded with the library.
The project is being developed with GHC 9.4.8
Use nix-shell
to load a development environment using nix.
The current shell.nix
has depends on the files created by the following sequence of commands
cabal2nix . > project.nix
REV = nix-instantiate --eval --expr 'builtins.readFile <nixpkgs/.git-revision>'
nix-prefetch-git https://github.com/NixOS/nixpkgs.git $REV > nixpkgs.json
For comparison, a default shell.nix
file can be created with
cabal2nix . --shell > shell.nix
To build the project using nix:
nix-build --attr project release.nix
The compiler can be given as an argument for the build:
nix-build --argstr compiler ghc965 --attr project release.nix