#include <sent/stddefs.h>
#include <sent/speech.h>
#include <sent/adin.h>
Include dependency graph for adin_file.c:
Go to the source code of this file.
Defines | |
#define | MYREAD(A, B, C, D) if (!myread(A, B, C, D)) {j_printerr("adin_file: file is corrupted\n"); return -1;} |
Abbreviation for header reading. | |
Functions | |
static boolean | myread (void *buf, size_t unitbyte, int unitnum, FILE *fp) |
static boolean | setup_wav (FILE *fp) |
Parse header part of a WAVE file to prepare for data reading. | |
static boolean | adin_file_open (char *filename) |
Open input file. | |
static boolean | adin_file_close () |
char * | get_line (char *prompt) |
boolean | adin_file_standby (int freq, void *arg) |
boolean | adin_file_begin () |
Begin reading audio data from a file. | |
int | adin_file_read (SP16 *buf, int sampnum) |
boolean | adin_file_end () |
boolean | adin_stdin_standby (int freq, void *arg) |
boolean | adin_stdin_begin () |
Begin reading audio data from stdin. | |
int | adin_stdin_read (SP16 *buf, int sampnum) |
Variables | |
static FILE * | gfp |
File pointer of current input file. | |
static boolean | wav_p |
TRUE if input is WAVE file, FALSE if RAW file. | |
static int | maxlen |
Number of samples, described in the header of WAVE file. | |
static int | nowlen |
Current number of read samples. | |
static SP16 | pre_data [2] |
static boolean | has_pre |
TRUE if pre_data is available. | |
static unsigned int | sfreq |
Sampling frequency in Hz, specified by adin_standby(). | |
static boolean | from_file |
TRUE if list file is used to read input filename. | |
static FILE * | fp_list |
File pointer used for the listfile. |
The sampling rate of input file must be equal to the system requirement value which is specified by adin_standby() . For WAVE format file, the sampling rate of the input file described in its header is checked against the system value, and rejected if not matched. But for RAW format file, no check will be applied since it has no header information about the recording sampling rate, so be careful of the sampling rate setting.
When file input mode, the file name will be read from standard input. If a filelist file is specified, the file names are read from the file sequencially instead.
When compiled with libsndfile support, the functions in adin_sndfile.c is used for file input instead of functions below.
In this file, assume sizeof(int)=4, sizeof(short)=2
Definition in file adin_file.c.
|
Read a header value from WAVE file with endian conversion. If required number of data has not been read, it produces error.
Definition at line 102 of file adin_file.c. Referenced by CMN_load_from_file(), new_SS_load_from_file(), read_param(), and setup_wav(). |
|
Parse header part of a WAVE file to prepare for data reading. The audio format will be checked here, and data length is also read from the header. Then the pointer is moved to the start point of data part. When called, the file pointer should be located just after the first 4 bytes, "RIFF". It also sets maxlen and nowlen .
Definition at line 130 of file adin_file.c. Referenced by adin_file_open(). |
|
Open input file. Open the file, check the file format, and set the file pointer to gfp .
Definition at line 239 of file adin_file.c. Referenced by adin_file_begin(), and adin_stdin_begin(). |
|
Close the input file
Definition at line 288 of file adin_file.c. Referenced by adin_file_end(), and adin_file_read(). |
|
Get one file name from stdin with a prompt . Blank line is omitted.
Definition at line 314 of file adin_file.c. Referenced by adin_file_begin(), adin_sndfile_begin(), and main_recognition_loop(). |
|
Initialization: if listfile is specified, open it here.
Definition at line 355 of file adin_file.c. Referenced by adin_select(). |
|
Begin reading audio data from a file. If listfile was specified in adin_file_standby(), the next filename will be read from the listfile. Otherwise, the filename will be obtained from stdin. Then the file will be opened here.
Definition at line 385 of file adin_file.c. Referenced by adin_select(). |
|
Try to read sampnum samples and returns actual sample num recorded.
Definition at line 429 of file adin_file.c. Referenced by adin_select(). |
|
End recording.
Definition at line 476 of file adin_file.c. Referenced by adin_select(). |
|
Initialization for speech input via stdin.
Definition at line 492 of file adin_file.c. Referenced by adin_select(). |
|
Begin reading audio data from stdin.
Definition at line 505 of file adin_file.c. Referenced by adin_select(). |
|
Try to read sampnum samples and returns actual sample num recorded.
Definition at line 528 of file adin_file.c. Referenced by adin_select(). |
|
When file input, the first 4 bytes of the file are read at first to identify whether it is WAVE file format. This work area is used to keep back the 4 bytes if the input is actually a RAW format. Definition at line 82 of file adin_file.c. Referenced by adin_file_open(), adin_file_read(), and adin_stdin_read(). |