Skip to content

Instantly share code, notes, and snippets.

@plugnburn
Last active June 23, 2017 08:16
Show Gist options
  • Save plugnburn/19e75cf0a3b67c6eae8889f3d5552475 to your computer and use it in GitHub Desktop.
Save plugnburn/19e75cf0a3b67c6eae8889f3d5552475 to your computer and use it in GitHub Desktop.
FibSynth - experimental Fibonacci based synth/sequencer based on Bash and SoX
#!/bin/bash
# Fibonacci Synth
# Usage: ./fibsynth.sh [a] [b] [modulo base] [scale] [interval] [tone shift]
# Example: fibsynth.sh 1 1 10 mixlyd 0.2 0
i=$1
j=$2
base=$3
interval=$5
basetone=$6
maj_scale=(0 2 4 5 7 9 11 12 14 16 17 19 21 23 24) #ionian (major)
min_scale=(0 2 3 5 7 8 10 12 14 15 17 19 20 22 24) #aeolian (minor)
dor_scale=(0 2 3 5 7 9 10 12 14 15 17 19 21 22 24) #dorian
loc_scale=(0 1 3 5 6 8 10 12 13 15 17 18 20 22 24) #locrian
lyd_scale=(0 2 4 6 7 9 11 12 14 16 18 19 21 23 24) #lydian
mixlyd_scale=(0 2 4 5 7 9 10 12 14 16 17 19 21 22 24) #mixolydian
phr_scale=(0 1 3 5 7 8 10 12 13 15 17 19 20 22 24) #phrygian
pmaj_scale=(0 2 4 7 9 12 14 16 19 21) #pentatonic major
pmin_scale=(0 3 5 7 10 12 15 17 19 22) #pentatonic minor
scalename="$4_scale"
eval scale=\( \${${scalename}[@]} \)
while true;do
play -q -n synth 3 pluck %$((basetone+scale[i]-12)) &
n=$(((i+j)%base))
i=$j
j=$n
sleep $interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment