libsent/include/sent/adin.h File Reference

Definitions for A/D-in processing and sound detection. More...

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

Go to the source code of this file.

Data Structures

struct  DS_FILTER
 down sampling filter More...
struct  DS_BUFFER
 down sampling data More...
struct  ZEROCROSS
 Work area for zero-cross computation. More...

Defines

#define DEFAULT_WSTEP   1000
 Default unit size of speech input segment in bytes.
#define SUPPORTED_WAVEFILE_FORMAT   "RAW(BE),WAV,AU,SND,NIST,ADPCM and more"
 String describing the list of supported wave file formats.
#define ZMEANSAMPLES   48000
 Number of samples from beggining of input to be used for computing the zero mean of source channel (for microphone/network input).
#define DS_RBSIZE   512
 Filter size.
#define DS_BUFSIZE   256
 Work area buffer size for x[].
#define DS_BUFSIZE_Y   512
 Work area buffer size for y[].
#define ZC_UNDEF   2
 Undefined mark for zerocross.
#define ZC_POSITIVE   1
 Positive mark used for zerocross.
#define ZC_NEGATIVE   -1
 Negative mark used for zerocross.

Enumerations

enum  {
  SP_RAWFILE, SP_MIC, SP_ADINNET, SP_MFCFILE,
  SP_NETAUDIO, SP_STDIN
}
 To select speech input source. More...

Functions

boolean adin_mic_standby (int freq, void *arg)
 Connection initialization: check connectivity and open for recording.
boolean adin_mic_begin ()
 Start recording.
boolean adin_mic_end ()
 Stop recording.
int adin_mic_read (SP16 *buf, int sampnum)
 Read samples from the daemon.
boolean adin_netaudio_standby (int freq, void *arg)
 Connection initialization: check connectivity and open for recording.
boolean adin_netaudio_begin ()
 Start recording.
boolean adin_netaudio_end ()
 Stop recording.
int adin_netaudio_read (SP16 *buf, int sampnum)
 Read samples from the daemon.
int NA_standby (int, char *)
 Initialize NetAudio device.
void NA_start ()
 Begin recording.
void NA_stop ()
 Pause the recording.
int NA_read (SP16 *buf, int sampnum)
 Read samples from NetAudio port.
boolean adin_file_standby (int freq, void *arg)
 Initialization: if listfile is specified, open it here.
boolean adin_file_begin ()
 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 ()
 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.
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.
boolean adin_tcpip_standby (int freq, void *arg)
 Initialize as adinnet server: prepare to become server.
boolean adin_tcpip_begin ()
 Wait for connection from adinnet client and begin audio input stream.
boolean adin_tcpip_end ()
 End recording.
int adin_tcpip_read (SP16 *buf, int sampnum)
 Try to read sampnum samples and returns actual sample num recorded.
boolean adin_tcpip_send_pause ()
 Tell the adinnet client to pause transfer.
boolean adin_tcpip_send_terminate ()
 Tell the adinnet client to terminate transfer.
boolean adin_tcpip_send_resume ()
 Tell the adinnet client to resume the paused transfer.
void init_count_zc_e (ZEROCROSS *zc, int length)
 Allocate buffers for zerocross counting.
void reset_count_zc_e (ZEROCROSS *zc, int c_trigger, int c_length, int c_offset)
 Initialize all parameters and buffers for zero-cross counting.
void free_count_zc_e (ZEROCROSS *zc)
 End procedure: free all buffers.
int count_zc_e (ZEROCROSS *zc, SP16 *buf, int step)
 Adding buf[0.
void zc_copy_buffer (ZEROCROSS *zc, SP16 *newbuf, int *len)
 Flush samples in the current cycle buffer.
void zmean_reset ()
 Reset status.
void sub_zmean (SP16 *speech, int samplenum)
 Remove DC offset.
DS_BUFFERds48to16_new ()
 Setup for down sampling.
void ds48to16_free (DS_BUFFER *ds)
 Free the down sampling buffer.
int ds48to16 (SP16 *dst, SP16 *src, int srclen, int maxdstlen, DS_BUFFER *ds)
 Perform down sampling of input samples to 1/3.


Detailed Description

Definitions for A/D-in processing and sound detection.

This file has some definitions relating audio input processing from various devices, and start/end of speech detection.

See also:
speech.h
Author:
Akinobu LEE
Date:
Thu Feb 10 17:22:36 2005
Revision
1.1.1.1

Definition in file adin.h.


Define Documentation

#define SUPPORTED_WAVEFILE_FORMAT   "RAW(BE),WAV,AU,SND,NIST,ADPCM and more"

String describing the list of supported wave file formats.

It depends on HAVE_LIBSNDFILE.

Definition at line 56 of file adin.h.

Referenced by j_output_argument_help().


Enumeration Type Documentation

anonymous enum

To select speech input source.

Enumerator:
SP_RAWFILE  Wavefile.
SP_MIC  Live microphone device.
SP_ADINNET  Network client (adintool etc.).
SP_MFCFILE  HTK parameter file.
SP_NETAUDIO  Live NetAudio/DatLink input.
SP_STDIN  Standard input.

Definition at line 38 of file adin.h.


Function Documentation

boolean adin_mic_standby ( int  sfreq,
void *  dummy 
)

Connection initialization: check connectivity and open for recording.

Parameters:
sfreq [in] required sampling frequency
dummy [in] a dummy data
Returns:
TRUE on success, FALSE on failure.
Connection initialization: check connectivity and open for recording.

Parameters:
sfreq [in] required sampling frequency.
arg [in] a dummy data
Returns:
TRUE on success, FALSE on failure.
Connection initialization: check connectivity and open for recording.

Parameters:
sfreq [in] required sampling frequency.
dummy [in] a dummy data
Returns:
TRUE on success, FALSE on failure.

Definition at line 52 of file adin_esd.c.

Referenced by adin_select().

boolean adin_mic_begin (  ) 

Start recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 76 of file adin_esd.c.

Referenced by adin_select().

boolean adin_mic_end (  ) 

Stop recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 87 of file adin_esd.c.

Referenced by adin_select().

int adin_mic_read ( SP16 buf,
int  sampnum 
)

Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least one sample can be obtained.

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, -2 if an error occured.
Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least one sample can be obtained.

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

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least one sample can be obtained.

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, -2 if an error occured.
Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block at most MAXPOLLINTERVAL msec, until at least one sample can be obtained. If no data has been obtained after waiting for MAXPOLLINTERVAL msec, returns 0.

When stereo input, only left channel will be used.

Parameters:
buf [out] samples obtained in this function
sampnum [in] wanted number of samples to be read
Returns:
actural number of read samples, 0 of no sample has been captured in MAXPOLLINTERVAL msec, -2 if error.
Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least some samples are obtained.

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

Definition at line 105 of file adin_esd.c.

Referenced by adin_select().

boolean adin_netaudio_standby ( int  sfreq,
void *  arg 
)

Connection initialization: check connectivity and open for recording.

Parameters:
sfreq [in] required sampling frequency
arg [in] server device name string to connect
Returns:
TRUE on success, FALSE on failure.

Definition at line 58 of file adin_netaudio.c.

Referenced by adin_select().

boolean adin_netaudio_begin (  ) 

Start recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 72 of file adin_netaudio.c.

Referenced by adin_select().

boolean adin_netaudio_end (  ) 

Stop recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 84 of file adin_netaudio.c.

Referenced by adin_select().

int adin_netaudio_read ( SP16 buf,
int  sampnum 
)

Read samples from the daemon.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least one sample can be obtained.

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

Definition at line 103 of file adin_netaudio.c.

Referenced by adin_select().

int NA_standby ( int  sfreq,
char *  server_devname 
)

Initialize NetAudio device.

Parameters:
sfreq [in] sampling frequency
server_devname [in] server host name
Returns:
1 on success, 0 on failure.

Definition at line 60 of file adin_na.c.

Referenced by adin_netaudio_standby().

int NA_read ( SP16 buf,
int  sampnum 
)

Read samples from NetAudio port.

Try to read sampnum samples and returns actual number of recorded samples currently available. This function will block until at least some samples are obtained.

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 an error occured.

Definition at line 156 of file adin_na.c.

Referenced by adin_netaudio_read().

boolean adin_file_standby ( int  freq,
void *  arg 
)

Initialization: if listfile is specified, open it here.

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 322 of file adin_file.c.

Referenced by adin_select().

boolean adin_file_begin (  ) 

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.

Returns:
TRUE on success, FALSE on failure.

Definition at line 352 of file adin_file.c.

Referenced by adin_select().

int adin_file_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 393 of file adin_file.c.

Referenced by adin_select().

boolean adin_file_end (  ) 

End recording.

Returns:
TRUE on success, FALSE on failure.

Definition at line 440 of file adin_file.c.

Referenced by adin_select().

boolean adin_stdin_standby ( int  freq,
void *  arg 
)

Initialization for speech input via stdin.

Parameters:
freq [in] required sampling frequency.
arg dummy, ignored
Returns:
TRUE on success, FALSE on failure.

Definition at line 456 of file adin_file.c.

Referenced by adin_select().

boolean adin_stdin_begin (  ) 

Begin reading audio data from stdin.

Returns:
TRUE on success, FALSE on failure.

Definition at line 469 of file adin_file.c.

Referenced by adin_select().

int adin_stdin_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 493 of file adin_file.c.

Referenced by adin_select().

char* adin_file_get_current_filename (  ) 

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

Returns:
string of current input speech file.

Definition at line 534 of file adin_file.c.

Referenced by j_get_current_filename().

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().

boolean adin_tcpip_standby ( int  freq,
void *  port_str 
)

Initialize as adinnet server: prepare to become server.

Parameters:
freq [in] required sampling frequency
port_str [in] port number in string
Returns:
TRUE on success, FALSE on failure.

Definition at line 79 of file adin_tcpip.c.

Referenced by adin_select().

boolean adin_tcpip_begin (  ) 

Wait for connection from adinnet client and begin audio input stream.

Returns:
TRUE on success, FALSE on failure.

Definition at line 103 of file adin_tcpip.c.

Referenced by adin_select().

boolean adin_tcpip_end (  ) 

End recording.

If last input segment was segmented by end of connection, close socket and wait for next connection. Otherwise, it means that the last input segment was segmented by either end-of-segment signal from client side or speech detection function in server side, so just wait for a next input in the current socket.

Returns:
TRUE on success, FALSE on failure.

Definition at line 156 of file adin_tcpip.c.

Referenced by adin_select().

int adin_tcpip_read ( SP16 buf,
int  sampnum 
)

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

This function will not block.

If data of zero length has been received, it is treated as a end-of-segment marker from the client. If data below zero length has been received, it means the client has finished the overall input stream transmission and want to disconnect.

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 188 of file adin_tcpip.c.

Referenced by adin_select().

boolean adin_tcpip_send_pause (  ) 

Tell the adinnet client to pause transfer.

Returns:
TRUE on success, FALSE on failure.

Definition at line 234 of file adin_tcpip.c.

Referenced by j_request_pause().

boolean adin_tcpip_send_terminate (  ) 

Tell the adinnet client to terminate transfer.

Returns:
TRUE on success, FALSE on failure.

Definition at line 270 of file adin_tcpip.c.

Referenced by j_request_terminate().

boolean adin_tcpip_send_resume (  ) 

Tell the adinnet client to resume the paused transfer.

Returns:
TRUE on success, FALSE on failure.

Definition at line 252 of file adin_tcpip.c.

Referenced by j_request_resume().

void init_count_zc_e ( ZEROCROSS zc,
int  length 
)

Allocate buffers for zerocross counting.

Parameters:
zc [i/o] zerocross work area
length [in] Cycle buffer size = Number of samples to hold

Definition at line 49 of file zc-e.c.

Referenced by adin_setup_param(), and reset_count_zc_e().

void reset_count_zc_e ( ZEROCROSS zc,
int  c_trigger,
int  c_length,
int  c_offset 
)

Initialize all parameters and buffers for zero-cross counting.

Parameters:
zc [i/o] zerocross work area
c_trigger [in] Tgigger level threshold
c_length [in] Cycle buffer size = Number of samples to hold
c_offset [in] Static DC offset of input data

Definition at line 68 of file zc-e.c.

Referenced by adin_cut().

void free_count_zc_e ( ZEROCROSS zc  ) 

End procedure: free all buffers.

Parameters:
zc [i/o] zerocross work area

Definition at line 98 of file zc-e.c.

Referenced by reset_count_zc_e().

int count_zc_e ( ZEROCROSS zc,
SP16 buf,
int  step 
)

Adding buf[0.

.step-1] to the cycle buffer and update the count of zero cross. Also swap them with the oldest ones in the cycle buffer. Also get the maximum level in the cycle buffer.

Parameters:
zc [i/o] zerocross work area
buf [I/O] new samples, will be swapped by old samples when returned.
step [in] length of above.
Returns:
zero-cross count of the samples in the cycle buffer.

Definition at line 116 of file zc-e.c.

Referenced by adin_cut().

void zc_copy_buffer ( ZEROCROSS zc,
SP16 newbuf,
int *  len 
)

Flush samples in the current cycle buffer.

Parameters:
zc [i/o] zerocross work area
newbuf [out] the samples in teh cycle buffer will be written here.
len [out] length of above.

Definition at line 165 of file zc-e.c.

Referenced by adin_cut().

void sub_zmean ( SP16 speech,
int  samplenum 
)

Remove DC offset.

The DC offset is estimated by the first samples after zmean_reset() was called. If the first input segment is longer than ZMEANSAMPLES, the whole input is used to estimate the zero mean. Otherwise, the zero mean will continue to be updated until the read length exceed ZMEANSAMPLES.

Parameters:
speech [I/O] input speech data, will be subtracted by DC offset.
samplenum [in] length of above.

Definition at line 70 of file zmean.c.

Referenced by adin_cut().

DS_BUFFER* ds48to16_new (  ) 

Setup for down sampling.

Returns:
newly allocated buffer for down sampling

Definition at line 267 of file ds48to16.c.

Referenced by adin_setup_all().

void ds48to16_free ( DS_BUFFER ds  ) 

Free the down sampling buffer.

Parameters:
ds [i/o] down sampling buffer to free

Definition at line 304 of file ds48to16.c.

int ds48to16 ( SP16 dst,
SP16 src,
int  srclen,
int  maxdstlen,
DS_BUFFER ds 
)

Perform down sampling of input samples to 1/3.

Parameters:
dst [out] store the resulting samples
src [in] input samples
srclen [in] number of input samples
maxdstlen [in] maximum length of dst
ds [i/o] down sampling buffer
Returns:
the number of samples written to dst, or -1 on errror.

Definition at line 329 of file ds48to16.c.

Referenced by adin_cut().


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