1 /**************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 Thom Johansen
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ***************************************************************************/
29 "Usage: rbspeexenc [options] infile outfile\n"\
31 " -q x Quality, floating point number in the range [0-10], default 8.0\n"\
32 " -c x Complexity, increases quality for a given bitrate, but encodes\n"\
33 " slower, range [0-10], default 3\n"\
34 " -n Enable narrowband mode, will resample input to 8 kHz\n"\
35 " -v x Volume, amplitude multiplier, default 1.0\n\n"\
36 "rbspeexenc expects a mono 16 bit WAV file as input. Files will be resampled\n"\
37 "to either 16 kHz by default, or 8 kHz if narrowband mode is enabled.\n"\
38 "WARNING: This tool will create files that are only usable by Rockbox!\n"
41 int main(int argc
, char **argv
)
43 char *inname
, *outname
;
47 float quality
= 8.f
, volume
= 1.0f
;
48 bool narrowband
= false;
58 while (i
< argc
- 2) {
59 if (strncmp(argv
[i
], "-q", 2) == 0)
60 quality
= atof(argv
[++i
]);
61 else if (strncmp(argv
[i
], "-c", 2) == 0)
62 complexity
= atoi(argv
[++i
]);
63 else if (strncmp(argv
[i
], "-v", 2) == 0)
64 volume
= atof(argv
[++i
]);
65 else if (strncmp(argv
[i
], "-n", 2) == 0)
68 printf("Error: unrecognized option '%s'\n", argv
[i
]);
73 inname
= argv
[argc
- 2];
74 outname
= argv
[argc
- 1];
76 if ((fin
= fopen(inname
, "rb")) == NULL
) {
77 printf("Error: could not open input file\n");
80 if ((fout
= fopen(outname
, "wb")) == NULL
) {
81 printf("Error: could not open output file\n");
85 ret
= encode_file(fin
, fout
, quality
, complexity
, narrowband
, volume
,
86 errstr
, sizeof(errstr
));
90 /* Attempt to delete unfinished output */
91 printf("Error: %s\n", errstr
);