Julius 4.2
マクロ定義 | 関数 | 変数
libsent/src/adin/adin_file.c

ファイル入力:WAV/RAWファイルおよび標準入力からの読み込み [詳細]

#include <sent/stddefs.h>
#include <sent/speech.h>
#include <sent/adin.h>

ソースコードを見る。

マクロ定義

#define MYREAD(A, B, C, D)   if (!myread(A, B, C, D)) {jlog("Error: adin_file: file is corrupted\n"); return -1;}
 Abbreviation for header reading.

関数

static boolean myread (void *buf, size_t unitbyte, int unitnum, FILE *fp)
 Read a header value from WAVE file with endian conversion.
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 ()
 Close the input file.
boolean adin_file_standby (int freq, void *arg)
 Initialization: if listfile is specified, open it here.
boolean adin_file_begin (char *filename)
 Begin reading audio data from a file.
int adin_file_read (SP16 *buf, int sampnum)
 Try to read sampnum samples and returns actual sample num recorded.
boolean adin_file_end ()
 End recording.
boolean adin_stdin_standby (int freq, void *arg)
 Initialization for speech input via stdin.
boolean adin_stdin_begin (char *pathname)
 Begin reading audio data from stdin.
int adin_stdin_read (SP16 *buf, int sampnum)
 Try to read sampnum samples and returns actual sample num recorded.
char * adin_file_get_current_filename ()
 A tiny function to get current input raw speech file name.
char * adin_stdin_input_name ()
 A tiny function to get current input raw speech file name.

変数

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]
 When file input, the first 4 bytes of the file are read at first to identify whether it is WAVE file format.
static boolean has_pre
 TRUE if pre_data is available.
static unsigned int sfreq
 Sampling frequency in Hz, specified by adin_standby()
static char speechfilename [MAXPATHLEN]
 Buffer to hold input file name.
static char * stdin_buf = NULL
static boolean from_file
 TRUE if list file is used to read input filename.
static FILE * fp_list
 File pointer used for the listfile.

説明

ファイル入力:WAV/RAWファイルおよび標準入力からの読み込み

音声ファイルからの入力を行なう関数です.サポートしているファイル形式は Microsoft WAVE形式の音声ファイル,およびヘッダ無し(RAW)ファイルです. オーディオ形式は,無圧縮PCM,16bit,モノラルに限られています. RAWファイルの場合,データのバイトオーダーが big endian であることを 前提としていますので,注意してください.

ファイルのサンプリングレートはシステムの要求するサンプリングレート (adin_standby() で指定される値)と一致する必要があります. WAVE形式のファイルの場合は, ファイルのサンプリングレートがこの指定値と一致しなければエラーとなります. RAWファイル入力の場合は,ファイルにヘッダ情報が無く録音時の サンプリングレートが不明なため,チェック無しでファイルの サンプリングレートが adin_standby() で指定された値である と仮定して処理されます.

入力ファイル名は,標準入力から読み込まれます. ファイル名を列挙したファイルリストファイルが指定された場合, そのファイルから入力ファイル名が順次読み込まれます.

libsndfile を使用する場合,adin_sndfile.c 内の関数が使用されます. この場合,このファイルの関数は使用されません.

このファイル内では int を 4byte, short を 2byte と仮定しています.

作者:
Akinobu LEE
日付:
Sun Feb 13 13:31:20 2005
Revision:
1.9

adin_file.c で定義されています。


関数

static boolean myread ( void *  buf,
size_t  unitbyte,
int  unitnum,
FILE *  fp 
) [static]

Read a header value from WAVE file with endian conversion.

If required number of data has not been read, it produces error.

引数:
buf[out] Pointer to store read data
unitbyte[in] Unit size
unitnum[in] Required number of units to read
fp[in] File pointer
戻り値:
TRUE on success, FALSE if required number of data has not been read.

adin_file.c106 行で定義されています。

参照元 setup_wav().

static boolean setup_wav ( FILE *  fp) [static]

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 .

引数:
fp[in] File pointer
戻り値:
TRUE if check successfully passed, FALSE if an error occured.

adin_file.c134 行で定義されています。

参照元 adin_file_open().

static boolean adin_file_open ( char *  filename) [static]

Open input file.

Open the file, check the file format, and set the file pointer to gfp .

引数:
filename[in] file name, or NULL for standard input
戻り値:
TRUE on success, FALSE on failure.

adin_file.c243 行で定義されています。

参照元 adin_file_begin(), と adin_stdin_begin().

static boolean adin_file_close ( ) [static]

Close the input file.

戻り値:
TRUE on success, FALSE on failure.

adin_file.c302 行で定義されています。

参照元 adin_file_end(), と adin_file_read().

boolean adin_file_standby ( int  freq,
void *  arg 
)

Initialization: if listfile is specified, open it here.

引数:
freq[in] required sampling frequency.
arg[in] file name of listfile, or NULL if not use
戻り値:
TRUE on success, FALSE on failure.

adin_file.c326 行で定義されています。

参照元 adin_select().

boolean adin_file_begin ( char *  filename)

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.

引数:
filename[in] file name to open or NULL for prompt
戻り値:
TRUE on success, FALSE on failure.

adin_file.c358 行で定義されています。

参照元 adin_select().

int adin_file_read ( SP16 buf,
int  sampnum 
)

Try to read sampnum samples and returns actual sample num recorded.

引数:
buf[out] samples obtained in this function
sampnum[in] wanted number of samples to be read
戻り値:
actural number of read samples, -1 if EOF, -2 if error.

adin_file.c410 行で定義されています。

参照元 adin_select().

boolean adin_file_end ( )

End recording.

戻り値:
TRUE on success, FALSE on failure.

adin_file.c473 行で定義されています。

参照元 adin_select().

boolean adin_stdin_standby ( int  freq,
void *  arg 
)

Initialization for speech input via stdin.

引数:
freq[in] required sampling frequency.
argdummy, ignored
戻り値:
TRUE on success, FALSE on failure.

adin_file.c489 行で定義されています。

参照元 adin_select().

boolean adin_stdin_begin ( char *  pathname)

Begin reading audio data from stdin.

引数:
pathname[in] dummy
戻り値:
TRUE on success, FALSE on failure.

adin_file.c504 行で定義されています。

参照元 adin_select().

int adin_stdin_read ( SP16 buf,
int  sampnum 
)

Try to read sampnum samples and returns actual sample num recorded.

引数:
buf[out] samples obtained in this function
sampnum[in] wanted number of samples to be read
戻り値:
actural number of read samples, -1 if EOF, -2 if error.

adin_file.c529 行で定義されています。

参照元 adin_select().

char* adin_file_get_current_filename ( )

A tiny function to get current input raw speech file name.

戻り値:
string of current input speech file.

adin_file.c585 行で定義されています。

参照元 adin_select().

char* adin_stdin_input_name ( )

A tiny function to get current input raw speech file name.

戻り値:
string of current input speech file.

adin_file.c597 行で定義されています。

参照元 adin_select().


変数

SP16 pre_data[2] [static]

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.

adin_file.c83 行で定義されています。

参照元 adin_file_open(), adin_file_read(), と adin_stdin_read().