libsent/src/adin/adin_sndfile.c File Reference

Audio input from file using libsndfile library. More...

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

Go to the source code of this file.

Functions

static boolean check_format (SF_INFO *s)
 Check if the file format is 16bit, monoral.
static void print_format (SF_INFO *s)
 Output format information to stdout (compliant to libsnd-0.0.23).
boolean adin_sndfile_standby (int freq, void *arg)
 Initialization: if listfile is specified, open it here.
boolean adin_sndfile_begin ()
 Begin reading audio data from a file.
int adin_sndfile_read (SP16 *buf, int sampnum)
 Try to read sampnum samples and returns actual sample num recorded.
boolean adin_sndfile_end ()
 End recording.
char * adin_sndfile_get_current_filename ()
 A tiny function to get current input raw speech file name.

Variables

static int sfreq
 Required sampling frequency in Hz.
static SF_INFO sinfo
 Wavefile information.
static SNDFILE * sp
 File handler.
static boolean from_file
 TRUE if reading filename from listfile.
static FILE * fp_list
 File pointer used for the listfile.
static char speechfilename [MAXPATHLEN]
 Buffer to hold input file name.


Detailed Description

Audio input from file using libsndfile library.

Functions to get input from wave file using libsndfile library. Many file formats are supported, including Microsoft WAVE format, and RAW (no header) format, AU, SND, NIST and so on. The channel number should be 1 (monaural). On RAW file input, the data byte order must be in big endian.

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.

libsndfile should be installed before compilation. The library and header will be automatically detected by configure script. When failed to detect, Julius uses adin_file.c instead for file input.

This file will work on libsndfile version 1.0.x.

See also:
http://www.mega-nerd.com/libsndfile/
Author:
Akinobu LEE
Date:
Mon Feb 14 12:13:27 2005
Revision
1.2

Definition in file adin_sndfile.c.


Function Documentation

boolean adin_sndfile_standby ( int  freq,
void *  arg 
)

Initialization: if listfile is specified, open it here.

Else, just store the required frequency.

Parameters:
freq [in] required sampling frequency
arg [in] file name of listfile, or NULL if not use
Returns:
TRUE on success, FALSE on failure.

Definition at line 199 of file adin_sndfile.c.

Referenced by adin_select().

boolean adin_sndfile_begin (  ) 

Begin reading audio data from a file.

If listfile was specified in adin_sndfile_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.

Returns:
TRUE on success, FALSE on failure.

Definition at line 229 of file adin_sndfile.c.

Referenced by adin_select().

int adin_sndfile_read ( SP16 buf,
int  sampnum 
)

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

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, -1 if EOF, -2 if error.

Definition at line 304 of file adin_sndfile.c.

Referenced by adin_select().

boolean adin_sndfile_end (  ) 

End recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 325 of file adin_sndfile.c.

Referenced by adin_select().

char* adin_sndfile_get_current_filename (  ) 

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

Returns:
string of current input speech file.

Definition at line 344 of file adin_sndfile.c.

Referenced by j_get_current_filename().


Generated on Tue Dec 18 16:01:37 2007 for Julius by  doxygen 1.5.4