id3: fix COMM frame handling
[sox.git] / src / tremolo.c
blobed827ade14babd8aa20c29d01910cf6f4dc040cc
1 /* libSoX effect: tremolo (c) 2007 robs@users.sourceforge.net
3 * This library is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or (at
6 * your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11 * General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "sox_i.h"
20 static int getopts(sox_effect_t * effp, int argc, char * * argv)
22 double speed, depth = 40;
23 char dummy; /* To check for extraneous chars. */
24 char offset[100];
25 char * args[] = {0, "sine", "fmod", 0, 0, "25"};
27 if (argc < 2 || argc > 3 ||
28 sscanf(argv[1], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
29 (argc > 2 && sscanf(argv[2], "%lf %c", &depth, &dummy) != 1) ||
30 depth <= 0 || depth > 100)
31 return lsx_usage(effp);
32 args[0] = argv[0];
33 args[3] = argv[1];
34 sprintf(offset, "%g", 100 - depth / 2);
35 args[4] = offset;
36 return lsx_synth_effect_fn()->getopts(effp, (int)array_length(args), args);
39 sox_effect_handler_t const * lsx_tremolo_effect_fn(void)
41 static sox_effect_handler_t handler;
42 handler = *lsx_synth_effect_fn();
43 handler.name = "tremolo";
44 handler.usage = "speed_Hz [depth_percent]";
45 handler.getopts = getopts;
46 return &handler;