Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

kb_wav.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  RIFF_CHUNK_HEADER
struct  FMT_CHUNK_HEADER
struct  COMMON_CHUNK_HEADER
struct  WAV

Defines

#define SWAP_WORD(w)   (((w>>8)&0xff)|((w<<8)&0xff00))
#define SWAP_LONG(l)
#define WAV_State_Hdr   0
#define WAV_State_Data   1

Functions

void kb_wav_init (WAV *wav)
int kb_wav_open (WAV *wav, const char *file, int read)
void kb_wav_close (WAV *wav)
int kb_wav_read_data (WAV *wav, void *buf, unsigned int size)
int kb_wav_write_data (WAV *wav, void *buf, unsigned int len)
void kb_wav_set_format (WAV *wav, unsigned short format, unsigned short nb_channel, unsigned long sample_rate, unsigned short bit_per_sample)
int kb_wav_read_hdr (WAV *wav, COMMON_CHUNK_HEADER *hdr)
int kb_wav_write_hdr (WAV *wav, COMMON_CHUNK_HEADER *hdr)
void kb_wav_dump_format (WAV *wav)


Define Documentation

#define SWAP_LONG  ) 
 

Value:

(((l>>24)&0xff)|((l>>8)&0xff00)|\ ((l<<8)&0xff0000)|((l<<24)&0xff000000))

Definition at line 9 of file kb_wav.h.

Referenced by kb_wav_read_data(), kb_wav_read_hdr(), kb_wav_write_data(), and kb_wav_write_hdr().

#define SWAP_WORD  )     (((w>>8)&0xff)|((w<<8)&0xff00))
 

Definition at line 8 of file kb_wav.h.

Referenced by kb_wav_read_data(), kb_wav_read_hdr(), kb_wav_write_data(), and kb_wav_write_hdr().

#define WAV_State_Data   1
 

Definition at line 13 of file kb_wav.h.

#define WAV_State_Hdr   0
 

Definition at line 12 of file kb_wav.h.


Function Documentation

void kb_wav_close WAV wav  ) 
 

This function closes a wav file.

Parameters:
wav the wav struct linked to the wav file

Definition at line 161 of file kb_wav.c.

References COMMON_CHUNK_HEADER::chunk, WAV::file, WAV::fmt, kb_wav_write_hdr(), WAV::length, COMMON_CHUNK_HEADER::length, WAV::modified, and COMMON_CHUNK_HEADER::type.

Referenced by kb_wav_play(), koa_sound_task(), and main().

Here is the call graph for this function:

void kb_wav_dump_format WAV wav  ) 
 

This function dumps the wav file header to the standard output.

Parameters:
wav the wav struct

Definition at line 411 of file kb_wav.c.

References FMT_CHUNK_HEADER::bit_per_sample, FMT_CHUNK_HEADER::byte_per_sample, FMT_CHUNK_HEADER::byte_per_sec, WAV::fmt, FMT_CHUNK_HEADER::format, FMT_CHUNK_HEADER::nb_channel, and FMT_CHUNK_HEADER::sample_rate.

void kb_wav_init WAV wav  ) 
 

This function initializes the wav struct, it must be called before calling other wav functions.

Parameters:
wav the wav struct to initialize

Definition at line 91 of file kb_wav.c.

References WAV::file, WAV::length, and WAV::modified.

Referenced by kb_wav_play(), koa_sound_task(), and main().

int kb_wav_open WAV wav,
const char *  file,
int  read
 

This function opens a wav file for reading or writing

Parameters:
wav the wav struct to use with the given file
file the file to read or write
read set to 1 for reading or to 0 for writing
Returns:
  • the data length on success
  • -1 if the file cannot be opened

Definition at line 107 of file kb_wav.c.

References COMMON_CHUNK_HEADER::chunk, WAV::file, WAV::fmt, kb_wav_read_hdr(), kb_wav_write_hdr(), COMMON_CHUNK_HEADER::length, WAV::length, WAV::modified, and COMMON_CHUNK_HEADER::type.

Referenced by kb_wav_play(), koa_sound_task(), and main().

Here is the call graph for this function:

int kb_wav_read_data WAV wav,
void *  buf,
unsigned int  size
 

This function reads a given number of data from a file opened with kb_wav_open. The resulting data are placed in buf and can be played using kb_snd_play.

Parameters:
wav the wav struct
buf the buffer to store the data
size the length of data to read
Returns:
the number of bytes read

Definition at line 197 of file kb_wav.c.

References FMT_CHUNK_HEADER::byte_per_sample, WAV::file, WAV::fmt, SWAP_LONG, and SWAP_WORD.

Referenced by kb_wav_play(), koa_sound_task(), and main().

int kb_wav_read_hdr WAV wav,
COMMON_CHUNK_HEADER hdr
 

This function reads Wave File header.

Definition at line 306 of file kb_wav.c.

References WAV::file, SWAP_LONG, and SWAP_WORD.

Referenced by kb_wav_open().

void kb_wav_set_format WAV wav,
unsigned short  format,
unsigned short  nb_channel,
unsigned long  sample_rate,
unsigned short  bit_per_sample
 

Set the format for the given wav struct. The format is usually read from the wav file header using kb_wav_open.

Definition at line 281 of file kb_wav.c.

References FMT_CHUNK_HEADER::bit_per_sample, FMT_CHUNK_HEADER::byte_per_sample, FMT_CHUNK_HEADER::byte_per_sec, WAV::fmt, FMT_CHUNK_HEADER::format, WAV::modified, FMT_CHUNK_HEADER::nb_channel, and FMT_CHUNK_HEADER::sample_rate.

int kb_wav_write_data WAV wav,
void *  buf,
unsigned int  len
 

This function writes some data into the file.

Parameters:
wav the wav struct
buf the data to be writen
len the amount of bytes to write
Returns:
the number of bytes writen

Definition at line 238 of file kb_wav.c.

References FMT_CHUNK_HEADER::byte_per_sample, WAV::file, WAV::fmt, WAV::length, WAV::modified, SWAP_LONG, and SWAP_WORD.

int kb_wav_write_hdr WAV wav,
COMMON_CHUNK_HEADER hdr
 

This function writes a header into a Wave File.

Definition at line 360 of file kb_wav.c.

References COMMON_CHUNK_HEADER::chunk, WAV::file, COMMON_CHUNK_HEADER::length, SWAP_LONG, SWAP_WORD, and COMMON_CHUNK_HEADER::type.

Referenced by kb_wav_close(), and kb_wav_open().


Generated on Thu Nov 17 15:34:38 2005 for KoreBot Library by doxygen 1.3.7