1 /**************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 Thom Johansen
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ***************************************************************************/
27 "Usage: rbspeexenc [options] infile outfile\n"\
29 " -q x Quality, floating point number in the range [0-10], default 8.0\n"\
30 " -c x Complexity, increases quality for a given bitrate, but encodes\n"\
31 " slower, range [0-10], default 3\n"\
32 " -n Enable narrowband mode, will resample input to 8 kHz\n"\
33 " -v x Volume, amplitude multiplier, default 1.0\n\n"\
34 "rbspeexenc expects a mono 16 bit WAV file as input. Files will be resampled\n"\
35 "to either 16 kHz by default, or 8 kHz if narrowband mode is enabled.\n"\
36 "WARNING: This tool will create files that are only usable by Rockbox!\n"
39 int main(int argc
, char **argv
)
41 char *inname
, *outname
;
45 float quality
= 8.f
, volume
= 1.0f
;
46 bool narrowband
= false;
56 while (i
< argc
- 2) {
57 if (strncmp(argv
[i
], "-q", 2) == 0)
58 quality
= atof(argv
[++i
]);
59 else if (strncmp(argv
[i
], "-c", 2) == 0)
60 complexity
= atoi(argv
[++i
]);
61 else if (strncmp(argv
[i
], "-v", 2) == 0)
62 volume
= atof(argv
[++i
]);
63 else if (strncmp(argv
[i
], "-n", 2) == 0)
66 printf("Error: unrecognized option '%s'\n", argv
[i
]);
71 inname
= argv
[argc
- 2];
72 outname
= argv
[argc
- 1];
74 if ((fin
= fopen(inname
, "rb")) == NULL
) {
75 printf("Error: could not open input file\n");
78 if ((fout
= fopen(outname
, "wb")) == NULL
) {
79 printf("Error: could not open output file\n");
83 ret
= encode_file(fin
, fout
, quality
, complexity
, narrowband
, volume
,
84 errstr
, sizeof(errstr
));
88 /* Attempt to delete unfinished output */
89 printf("Error: %s\n", errstr
);