import 834 Bytes
Newer Older
Mark Hills's avatar
Mark Hills committed
1
2
#!/bin/sh
#
Mark Hills's avatar
Mark Hills committed
3
4
# Audio import handler for xwax
#
5
6
7
# This script takes an output sample rate and filename as arguments,
# and outputs signed, little-endian, 16-bit, 2 channel audio on
# standard output. Errors to standard error.
Mark Hills's avatar
Mark Hills committed
8
9
10
#
# You can adjust this script yourself to customise the support for
# different file formats and codecs.
Mark Hills's avatar
Mark Hills committed
11
#
Mark Hills's avatar
Mark Hills committed
12

13
FILE="$1"
14
RATE="$2"
Mark Hills's avatar
Mark Hills committed
15

16
case "$FILE" in
Mark Hills's avatar
Mark Hills committed
17

18
*.cdaudio)
19
20
21
	echo "Calling CD extract..." >&2
	exec cdparanoia -r `cat "$FILE"` -
	;;
Mark Hills's avatar
Mark Hills committed
22

23
*.mp3)
24
25
26
	echo "Calling MP3 decoder..." >&2
	exec mpg123 -q -s --rate "$RATE" --stereo "$FILE"
	;;
Mark Hills's avatar
Mark Hills committed
27
28

*)
29
	echo "Calling fallback decoder..." >&2
30
31
32
33
34
35
36
37
38

	FFMPEG=$(which ffmpeg 2> /dev/null || which avconv 2> /dev/null)

	if [ -z "$FFMPEG" ]; then
		echo "$0: no ffmpeg or avconv available to decode file" >&2
		exit 1
	fi

	exec "$FFMPEG" -v 0 -i "$FILE" -f s16le -ar "$RATE" -
39
	;;
Mark Hills's avatar
Mark Hills committed
40
41

esac