bpmprocess/time_to_sample.c

Go to the documentation of this file.
00001 
00005 #include <bpm/bpm_messages.h>
00006 #include <bpm/bpm_process.h>
00007 
00018 int time_to_sample( double fs, int ns, double t, int *iS ) {
00019 
00020   double ti;
00021   int i;
00022 
00023   if ( t < 0 ) {
00024     *iS = 0;
00025     return BPM_SUCCESS;
00026   }
00027   
00028   for ( i=0; i<ns; i++ ) {
00029     ti = ( (double) i + 0.5 ) / fs;
00030     if ( ABS( t - ti ) <  ( 1./fs ) ) break;
00031   }
00032 
00033   *iS = i;
00034 
00035   
00036   return BPM_SUCCESS;
00037 }

Generated on Thu Jan 10 10:18:04 2008 for libbpm by  doxygen 1.5.1