This is a command line program implementing granular synthesis . It works by playing many (very many) short, randomized samples from an audio file, called grains. This creates some pretty cool sounds even from very simple inputs.
Here is an example of what it can sound like:
The program uses Jack as a backend and is
primarily controlled through its command line interface. A full list of commands
can be displayed with the help command. There are commands for
importing samples, creating profiles and connecting to audio ports, as well as
for changing attributes that control how the synthesizer works. If you're interested
in trying this program, I've written a brief guide below.
Here are instructions for
building and installing grainman.
import-sample <sample name> <path>
To create a new synthesizer profile:
add-profile <profile name> <sample name>
To start synthesizeing, run:
start
set-attribute <profile name> <attribute name> <value>
num-slots
min-length/max-length
min-gain/max-gain
min-cooldown/max-cooldown
min-multiplier/max-multiplier
reverse-probability
add-midi-device <name> <pattern matching a port name in Jack>
To connect a MIDI control change message to a specific attribute:
map-midi-cc <device name> <CC function> <profile name> <attribute name> <min> <max>
This will map the interval 0-127 to [<min>, <max>].
It is also possible to clamp the multiplier attribute to the nearest pitch played on a MIDI keyboard:
map-midi <device name> <profile name>
set-attribute <profile name> use-pitches yes
Note that it doesn't matter in which octave a note is played, the register
is based on min-multiplier and max-multiplier.
You can map a control change function to "locking" the pitches. I've used this to play a chord on the keyboard, keep it sustained with the middle pedal, and then improvising with the chord in the background. This can be done like this:
map-lock-toggle <device name> <CC function> <profile>
source command
that will read commands from a file:
source <path>
There is a special rule for files with the extension .sh:
in this case, instead of reading commands directly from the file,
a child process running bash interprets the file and the
commands are read from the child processes standard output.
Note: only source scripts that you trust.
Here is an example script:
#! /usr/bin/env bash
min_gain=0.0
max_gain=1.0
min_multiplier=0.2
max_multiplier=4.0
min_length=0.001
max_length=4.0
min_num_slots=1
max_num_slots=512
min_cooldown=0.0
max_cooldown=1.0
cat <<EOF
# Connect to external MIDI devices
# One will be used to control attributes,
# the other one for pitches
add-midi-device control nanoKONTROL2
add-midi-device keyboard Q49
# Import audio sample and create synthesizer profile
import-sample default-sample sample.wav
add-profile default-profile default-sample
# Set initial values for attributes and map
# control change functions to each one.
# I like to set the initial value to the lower
# limit, and start the program with all sliders at zero.
set-attribute default-profile min-multiplier $min_multiplier
set-attribute default-profile max-multiplier $min_multiplier
map-midi-cc control 0 default-profile min-multiplier $min_multiplier $max_multiplier
map-midi-cc control 1 default-profile max-multiplier $min_multiplier $max_multiplier
set-attribute default-profile min-length $min_length
set-attribute default-profile max-length $min_length
map-midi-cc control 2 default-profile min-length $min_length $max_length
map-midi-cc control 3 default-profile max-length $min_length $max_length
set-attribute default-profile num-slots $min_num_slots
map-midi-cc control 17 default-profile num-slots $min_num_slots $max_num_slots
set-attribute default-profile min-gain $min_gain
set-attribute default-profile max-gain $min_gain
map-midi-cc control 16 default-profile max-gain $min_gain $max_gain
# This one is not controlled by MIDI
set-attribute default-profile min-cooldown $min_cooldown
set-attribute default-profile max-cooldown $max_cooldown
# Snap multiplers to pitches played on keyboard
map-midi keyboard default-profile
set-attribute default-profile use-pitches yes
# Use MIDI controller to lock pitches
map-lock-toggle control 45 feedback
# Start grainman!
start
EOF
curl -LO https://ludviggl.duckdns.org/projects/grainman/grainman.tar.gz
tar -xvf grainman.tar.gz
make -C grainman/
make -C grainman/ install PREFIX=<prefix>