1 /* -*- c-basic-offset: 4 -*- */
6 #include "test_macros.h"
10 #ifndef WORDS_BIGENDIAN
11 #define WORDS_BIGENDIAN 0
17 file_ad_read(ad_rec_t * r, int16 * buf, int32 max)
21 k = fread(buf, sizeof(int16), max, infp);
22 if (WORDS_BIGENDIAN) {
23 for (i = 0; i < k; i++) {
28 return ((k > 0) ? k : -1);
32 main(int argc, char *argv[])
42 TEST_ASSERT(infp = fopen(TESTDATADIR "/chan3.raw", "rb"));
43 TEST_ASSERT(cont = cont_ad_init(&ad, file_ad_read));
45 printf("Calibrating ...");
47 if (cont_ad_calib(cont) < 0)
48 printf(" failed; file too short?\n");
50 printf(" done after %ld samples\n", ftell(infp) / 2);
55 int k = cont_ad_read(cont, buf, 512);
59 printf("End of file at %.3f seconds\n",
60 (double)(cont->read_ts - k) / 16000);
65 if (cont->state == CONT_AD_STATE_SIL) {
66 /* Has there been enough silence to cut the utterance? */
67 if (listening && cont->seglen > 8000) {
68 printf("End of utterance at %.3f seconds\n",
69 (double)(cont->read_ts - k - cont->seglen) / 16000);
75 printf("Start of utterance at %.3f seconds\n",
76 (double)(cont->read_ts - k) / 16000);