Skip to content

Instantly share code, notes, and snippets.

@rodri042

rodri042/play-and-shift.sh

Last active Feb 10, 2017
Embed
What would you like to do?
#!/bin/bash
SONG=$1
VALUE=$2
PARAMETER=$3 # "speed" or "pitch" (default)
if [ $VALUE ">" 0 ] ; then
FACTOR=1.059463094352953
else
FACTOR=0.9438743126816935
fi
SEMITONES=$(echo $VALUE | awk '{ print ($1 >= 0) ? $1 : 0 - $1}')
if [ $PARAMETER == "speed" ] ; then
SPEED=$VALUE
else
SPEED=$(awk "BEGIN{printf(\"%0.25f\", $FACTOR ^ $SEMITONES)}")
MODIFIER=":speed=pitch"
fi
mplayer -af scaletempo=scale=1.0$MODIFIER -speed "$SPEED" "$SONG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment