File: soxeffect

package info (click to toggle)
sox 12.16-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,180 kB
  • ctags: 1,466
  • sloc: ansic: 16,658; sh: 2,071; makefile: 126
file content (82 lines) | stat: -rwxr-xr-x 1,970 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
#
# soxeffect - When this script is ran using a different name then soxeffect
# it will run sox using that name as the effect.  It uses stdin/stdout
# to grab data and output data.
#
# TODO: It would be nice to specify different output parameters then
# the input format.
#

# Some people prefer to rename sox to something like sox.bin, then use this
# script to always run sox, using "ln -s soxeffect sox".

SOX=/usr/local/bin/sox
# SOX=/usr/local/bin/sox.bin

help()
{
  echo "soxeffect v1.0 - effects front end to Sox"
  echo ""
  echo "Usage: [effectname] [ fopts ] [effectopts]"
  echo
  echo "When ran as the name of an effect that Sox supports, it will take"
  echo "audio data from stdin, apply the effect, and write the output back"
  echo "to stdout.  This means that [ fopts ] need to be given so that"
  echo "sox will know what format the audio data is in."
  echo
  echo "effectname: avg/band/chorus/copy/cut/deemph/echo/echos/flanger/highp/lowp/map/mask/phaser/pick/polyphase/rate/resample/reverb/reverse/split/stat/vibro"
  echo
  echo "fopts: -c channels -h -r rate -t type -v volume -s/-u/-U/-A -b/-w/-l/-f/-d/-D -x"
  echo ""
  echo "See sox man page for more info on required effects options."
}

NAME=$0
case $NAME in
	*/*)
		NAME=`echo $NAME | sed "s'^.*/''"`
	;;
esac

while [ $# -ne 0 ] # loop over arguments
do case $1 in
   -c)
     shift
     fopts="$fopts -c $1"
     ;;
   -h)
     help;
     exit 1;
     ;;
   -r)
     shift
     fopts="$fopts -r $1"
     ;;
   -t)
     shift
     fopts="$fopts -t $1"
     ;;
   -v)
     shift
     volume="-v $1"
     ;;
   -*)
     fopts="$fopts $1"
     ;;
   *)
     effectopts="$@"
     break;
     ;;
   esac
   shift
done

case $NAME in
	*sox)
		exec $SOX $*
	;;
	*avg|*band|*chorus|*copy|*cut|*deemph|*echo|*echos|*flanger|*Highp|*lowp|*map|*mask|*Phaser|*pick|*polyphase|*rate|*resample|*reverb|*reverse|*split|*stat|*vibro)
		$SOX $volume $fopts - $fopts - $NAME $effectopts
	;;
esac