void process_print (void)
{
- /* output times in seconds and extracted mfccs */
- outmsg("%f\t",blocks*hop_size/(float)samplerate);
- fvec_print(mfcc_out);
+ /* output times in selected format */
+ print_time (blocks * hop_size);
+ outmsg ("\t");
+ /* output extracted mfcc */
+ fvec_print (mfcc_out);
}
int main(int argc, char **argv) {
void process_print (void)
{
if ( is_onset ) {
- outmsg ("%f\n", aubio_onset_get_last_s (o) );
+ if (strcmp (time_format, "samples") == 0) {
+ outmsg ("%d\n", aubio_onset_get_last (o) );
+ } else if (strcmp (time_format, "ms") == 0) {
+ outmsg ("%f\n", aubio_onset_get_last_ms (o) );
+ } else {
+ outmsg ("%f\n", aubio_onset_get_last_s (o) );
+ }
}
}
void process_print (void)
{
smpl_t pitch_found = fvec_get_sample(pitch, 0);
- outmsg("%f %f\n",(blocks)
- *hop_size/(float)samplerate, pitch_found);
+ print_time(blocks * hop_size);
+ outmsg(" %f\n", pitch_found);
}
int main(int argc, char **argv) {
void process_print (void) {
int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0;
- if (issilence == -1) {
- outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate);
- } else if (issilence == 2) {
- outmsg("QUIET: %f\n",curblocks*hop_size/(float)samplerate);
+ if (issilence == -1 || issilence == 2) {
+ if (issilence == -1) {
+ outmsg ("NOISY: ");
+ } else { // if (issilence == 2) {
+ outmsg ("QUIET: ");
+ }
+ print_time (curblocks * hop_size);
+ outmsg ("\n");
}
}
void process_print (void) {
if ( is_beat && !is_silence ) {
- outmsg("%f\n", aubio_tempo_get_last_s(tempo) );
+ print_time (aubio_tempo_get_last (tempo));
+ outmsg ("\n");
}
}
extern char_t * pitch_method;
extern char_t * pitch_unit;
extern smpl_t pitch_tolerance;
+// time stuff
+extern char_t * time_format;
// tempo stuff
extern char_t * tempo_method;
// more general stuff
#endif /* PROG_HAS_PITCH */
" -s --silence select silence threshold\n"
" a value in dB, for instance -70, or -100; default=-90\n"
+ " -T --time-format select time values output format\n"
+ " (samples, ms, seconds) default=seconds\n"
#ifdef PROG_HAS_OUTPUT
" -m --mix-input mix input signal with output signal\n"
" input signal will be added to output synthesis\n"
#ifdef PROG_HAS_PITCH
"p:u:l:"
#endif /* PROG_HAS_PITCH */
+ "T:"
"s:mf";
int next_option;
struct option long_options[] = {
{"pitch-tolerance", 1, NULL, 'l'},
#endif /* PROG_HAS_PITCH */
{"silence", 1, NULL, 's'},
+ {"time-format", 1, NULL, 'T'},
{"mix-input", 0, NULL, 'm'},
{"force-overwrite", 0, NULL, 'f'},
{NULL, 0, NULL, 0}
case 'l':
pitch_tolerance = (smpl_t) atof (optarg);
break;
+ case 'T':
+ time_format = optarg;
+ break;
case 's': /* silence threshold */
silence_threshold = (smpl_t) atof (optarg);
break;
char_t * pitch_unit = "default";
char_t * pitch_method = "default";
smpl_t pitch_tolerance = 0.0; // will be set if != 0.
+// time stuff
+char_t * time_format = "seconds";
// tempo stuff
char_t * tempo_method = "default";
// more general stuff
} else
#endif
if (velo == 0) {
- outmsg ("%f\n", blocks * hop_size / (float) samplerate);
+ print_time (blocks * hop_size);
+ outmsg ("\n");
} else {
- outmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate);
+ outmsg ("%f\t", mpitch);
+ print_time (blocks * hop_size);
+ outmsg ("\t");
}
}
+void print_time (uint_t time_in_samples) {
+ /* output times in selected format */
+ if (strcmp (time_format, "samples") == 0) {
+ outmsg ("%d", time_in_samples);
+ } else if (strcmp (time_format, "ms") == 0) {
+ outmsg ("%f", 1000. * time_in_samples / (float) samplerate);
+ } else {
+ outmsg ("%f", time_in_samples / (float) samplerate);
+ }
+}
void process_block (fvec_t *ibuf, fvec_t *obuf);
void process_print (void);
+
+void print_time (uint_t samples);