-
Notifications
You must be signed in to change notification settings - Fork 28
/
gen_setformat_c.sh
85 lines (81 loc) · 1.73 KB
/
gen_setformat_c.sh
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
83
84
85
#This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
ai="
WAV
AIFF
AU
RAW
PAF
SVX
NIST
VOC
IRCAM
W64
MAT4
MAT5
PVF
XI
HTK
SDS
AVR
WAVEX
SD2
FLAC
CAF
WVE
OGG
OPUS
MPC2K
RF64
MP3
MP2
SPEEX
WMA
AAC
VQF
RA
ALAC
AIFC
"
echo "static int setformat_base(char *soundfile_format){"
echo " return("
for a in $ai;do
echo "#include <sndfile.h>" >temp.c
case "$a" in
OGG) format="SF_FORMAT_OGG | SF_FORMAT_VORBIS" ;;
OPUS) format="SF_FORMAT_OGG | SF_FORMAT_OPUS" ;;
*) format="SF_FORMAT_$a" ;;
esac
echo "int main(void){return $format;}" >>temp.c
echo >>temp.c
if gcc temp.c 2>/dev/null; then
echo " (!strcasecmp(\""$a"\",soundfile_format)) ? $format :"
fi
done
echo " -1);"
echo "}"
echo
echo "int getformat(char *soundfile_format){"
echo " return setformat_base(soundfile_format);"
echo "}"
echo
echo "void print_all_formats(void){"
#echo " printf(\"Supported formats: \\n\");"
echo
for a in $ai;do
echo " if(setformat_base(\""$a"\")!=-1)"
echo " printf(\""`echo $a|tr '[:upper:]' '[:lower:]'`" \");"
done
echo ' printf("\n");'
echo "}"