libsent/src/adin/adin.c

Go to the documentation of this file.
00001 
00084 /*
00085  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
00086  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00087  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology
00088  * All rights reserved
00089  */
00090 
00091 #include <sent/stddefs.h>
00092 #include <sent/speech.h>
00093 #include <sent/adin.h>
00094 
00095 /* device handling functions out side of the speech detection functions */
00097 static boolean (*ad_standby)(int, void *);
00099 static boolean (*ad_begin)();
00101 static boolean (*ad_end)();
00102 
00107 static void
00108 adin_register_func(boolean (*cad_standby)(int, void *),
00109                    boolean (*cad_begin)(),
00110                    int (*cad_read)(SP16 *, int),
00111                    boolean (*cad_end)(), 
00112                    boolean (*cad_resume)(),
00113                    boolean (*cad_pause)(),
00114                    boolean segmentation_default,
00115                    boolean need_threaded) 
00116 {
00117   ad_standby = cad_standby;
00118   ad_begin = cad_begin;
00119   ad_end = cad_end;
00120   adin_setup_func(cad_read, cad_pause, cad_resume,
00121                   segmentation_default, 
00122                   need_threaded);
00123 }
00124 
00125 
00133 boolean
00134 adin_select(int source)
00135 {
00136   switch(source) {
00137   case SP_RAWFILE:
00138 #ifdef HAVE_LIBSNDFILE
00139     /* libsndfile interface */
00140     adin_register_func(adin_sndfile_standby, /* standby (called once on startup) */
00141                        adin_sndfile_begin, /* start (called for each stream) */
00142                        adin_sndfile_read, /* read (read sample) */
00143                        adin_sndfile_end, /* stop (called for each stream) */
00144                        NULL,    /* pause (called between each segment) */
00145                        NULL,    /* resume (called between each segment) */
00146                        FALSE,   /* default of pause segmentation */
00147                        FALSE);  /* TRUE if need threaded */
00148 #else  /* ~HAVE_LIBSNDFILE */
00149     /* built-in RAW/WAV reader */
00150     adin_register_func(adin_file_standby, /* standby (called once on startup) */
00151                        adin_file_begin, /* start (called for each stream) */
00152                        adin_file_read, /* read (read sample) */
00153                        adin_file_end, /* stop (called for each stream) */
00154                        NULL,    /* pause (called between each segment) */
00155                        NULL,    /* resume (called between each segment) */
00156                        FALSE,   /* default of pause segmentation */
00157                        FALSE);  /* TRUE if need threaded */
00158 #endif
00159     break;
00160 #ifdef USE_MIC
00161   case SP_MIC:
00162     /* microphone input */
00163     adin_register_func(adin_mic_standby,
00164                        NULL,
00165                        adin_mic_read,
00166                        NULL,
00167                        adin_mic_start,
00168                        adin_mic_stop,
00169                        TRUE,
00170                        TRUE);
00171     break;
00172 #endif
00173 #ifdef USE_NETAUDIO
00174   case SP_NETAUDIO:
00175     /* DatLink/NetAudio input */
00176     adin_register_func(adin_netaudio_standby,
00177                        NULL,
00178                        adin_netaudio_read,
00179                        NULL,
00180                        adin_netaudio_start,
00181                        adin_netaudio_stop,
00182                        TRUE,
00183                        TRUE);
00184     break;
00185 #endif
00186   case SP_ADINNET:
00187     /* adinnet network input */
00188     adin_register_func(adin_tcpip_standby,
00189                        adin_tcpip_begin,
00190                        adin_tcpip_read,
00191                        adin_tcpip_end,
00192                        NULL,
00193                        NULL,
00194                        FALSE,
00195                        FALSE);
00196 
00197     break;
00198   case SP_STDIN:
00199     /* standard input */
00200     adin_register_func(adin_stdin_standby,
00201                        adin_stdin_begin,
00202                        adin_stdin_read,
00203                        NULL,
00204                        NULL,
00205                        NULL,
00206                        FALSE,
00207                        FALSE);
00208     break;
00209   case SP_MFCFILE:
00210     /* MFC_FILE is not waveform, so special handling on main routine should be done */
00211     break;
00212   default:
00213     return FALSE;
00214   }
00215   return TRUE;
00216 }
00217 
00226 boolean
00227 adin_standby(int freq, void *arg)
00228 {
00229   adin_reset_zmean();           /* reset zmean at beginning of stream */
00230   if (ad_standby != NULL) return(ad_standby(freq, arg));
00231   else return TRUE;
00232 }
00238 boolean
00239 adin_begin()
00240 {
00241   adin_reset_zmean();           /* reset zmean at beginning of stream */
00242   if (ad_begin != NULL) return(ad_begin());
00243   else return TRUE;
00244 }
00250 boolean
00251 adin_end()
00252 {
00253   if (ad_end != NULL) return(ad_end());
00254   else return TRUE;
00255 }

Generated on Tue Dec 26 12:53:22 2006 for Julian by  doxygen 1.5.0