Skip to content

Instantly share code, notes, and snippets.

@Alexander-0x80
Last active December 24, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alexander-0x80/6791647 to your computer and use it in GitHub Desktop.
Save Alexander-0x80/6791647 to your computer and use it in GitHub Desktop.
Bash script to convert base note sound to full octave .
#!/bin/bash
# Using: Sox
#
# If not installed :
# sudo apt-get install sox libsox-fmt-mp3
#
if [ ! -f $1 ]
then
echo "Bad filename."
exit
fi
# There are 12 semitones to an octave,
# Measured in 100ths of a semitone.
# so that would mean +/- 1200 for one octave.
# Info :
# http://en.wikipedia.org/wiki/Semitone
declare -A notes=(
[c]=0 [cs]=76 [d]=193 [ds]=310
[e]=386 [f]=503 [fs]=579 [g]=696
[gs]=772 [a]=889 [as]=1006 [b]=1082 )
for note in ${!notes[@]};
do
# sox <infile> <outfile> pitch <shift>
sox $1 ${note}$2.mp3 pitch ${notes[${note}]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment