00001 00004 #include <bpm/bpm_messages.h> 00005 #include <bpm/bpm_process.h> 00006 00007 int sample_to_time( double fs, int ns, int iS, double *t ) { 00008 /* 00009 @ingroup processing 00010 00011 @param fs sampling frequency 00012 @param ns number of samples 00013 @param t the queried sample 00014 @param iS the returned sample time 00015 00016 @return BPM_SUCCESS upon success, BPM_FAILURE upon failure 00017 */ 00018 00019 if ( iS < 0. ) { 00020 *t = 0.; 00021 return BPM_SUCCESS; 00022 } 00023 00024 if ( iS >= ns ) { 00025 *t = (double) ns / fs; // return time of last sample + 1 00026 return BPM_SUCCESS; 00027 } 00028 00029 *t = (double) iS / fs; 00030 00031 return BPM_SUCCESS; 00032 }