Changeset 340cb93 for examples/utils.c


Ignore:
Timestamp:
Aug 12, 2015, 4:15:39 PM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
df7be43
Parents:
a90e9d4
Message:

examples/: add time format option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    ra90e9d4 r340cb93  
    4848char_t * pitch_method = "default";
    4949smpl_t pitch_tolerance = 0.0; // will be set if != 0.
     50// time stuff
     51char_t * time_format = "seconds";
    5052// tempo stuff
    5153char_t * tempo_method = "default";
     
    197199#endif
    198200  if (velo == 0) {
    199     outmsg ("%f\n", blocks * hop_size / (float) samplerate);
    200   } else {
    201     outmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate);
    202   }
    203 }
    204 
     201    print_time (blocks * hop_size);
     202    outmsg ("\n");
     203  } else {
     204    outmsg ("%f\t", mpitch);
     205    print_time (blocks * hop_size);
     206    outmsg ("\t");
     207  }
     208}
     209
     210void print_time (uint_t time_in_samples) {
     211  /* output times in selected format */
     212  if (strcmp (time_format, "samples") == 0) {
     213    outmsg ("%d", time_in_samples);
     214  } else if (strcmp (time_format, "ms") == 0) {
     215    outmsg ("%f", 1000. * time_in_samples / (float) samplerate);
     216  } else {
     217    outmsg ("%f", time_in_samples / (float) samplerate);
     218  }
     219}
Note: See TracChangeset for help on using the changeset viewer.