extern smpl_t silence_threshold;
extern uint_t mix_input;
+extern uint_t force_overwrite;
+
// functions defined in utils.c
extern void examples_common_init (int argc, char **argv);
extern void examples_common_del (void);
" -s --silence select silence threshold\n"
#ifdef PROG_HAS_OUTPUT
" -m --mix-input mix input signal with output signal\n"
+ " -f --force-overwrite overwrite output file if\n"
#endif
#ifdef PROG_HAS_JACK
" -j --jack use Jack\n"
#ifdef PROG_HAS_PITCH
"p:u:l:"
#endif /* PROG_HAS_PITCH */
- "s:m";
+ "s:mf";
int next_option;
struct option long_options[] = {
{"help", 0, NULL, 'h'},
#endif /* PROG_HAS_PITCH */
{"silence", 1, NULL, 's'},
{"mix-input", 0, NULL, 'm'},
+ {"force-overwrite", 0, NULL, 'f'},
{NULL, 0, NULL, 0}
};
prog_name = argv[0];
case 'o':
sink_uri = optarg;
break;
+ case 'f': /* force_overwrite flag */
+ force_overwrite = 1;
+ break;
case 'r':
samplerate = atoi (optarg);
break;
smpl_t silence_threshold = -90.;
uint_t mix_input = 0;
+uint_t force_overwrite = 0;
+
//
// internal memory stuff
aubio_source_t *this_source = NULL;
samplerate = aubio_source_get_samplerate(this_source);
}
if (sink_uri != NULL) {
+ uint_t sink_exists = (access(sink_uri, F_OK) == 0 );
+ if (!force_overwrite && sink_exists) {
+ outmsg ("Output file %s already exists, use -f to overwrite.\n",
+ sink_uri);
+ exit (1);
+ }
this_sink = new_aubio_sink ((char_t*)sink_uri, samplerate);
if (this_sink == NULL) {
outmsg ("Could not open output file %s\n", sink_uri);