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 SWAP_LONG | ( | l | ) |
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 | ) | (((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().
void kb_wav_close | ( | WAV * | wav | ) |
This function closes a wav file.
wav | the wav struct linked to the wav file |
Definition at line 161 of file kb_wav.c.
References COMMON_CHUNK_HEADER::chunk, RIFF_CHUNK_HEADER::chunk_content, WAV::file, WAV::fmt, COMMON_CHUNK_HEADER::fmt, kb_wav_write_hdr(), WAV::length, COMMON_CHUNK_HEADER::length, WAV::modified, COMMON_CHUNK_HEADER::riff, and COMMON_CHUNK_HEADER::type.
Referenced by kb_wav_play(), koa_sound_task(), and main().
void kb_wav_dump_format | ( | WAV * | wav | ) |
This function dumps the wav file header to the standard output.
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.
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
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 |
Definition at line 107 of file kb_wav.c.
References COMMON_CHUNK_HEADER::chunk, RIFF_CHUNK_HEADER::chunk_content, WAV::file, COMMON_CHUNK_HEADER::fmt, WAV::fmt, kb_wav_read_hdr(), kb_wav_write_hdr(), COMMON_CHUNK_HEADER::length, WAV::length, WAV::modified, COMMON_CHUNK_HEADER::riff, and COMMON_CHUNK_HEADER::type.
Referenced by kb_wav_play(), koa_sound_task(), and main().
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.
wav | the wav struct | |
buf | the buffer to store the data | |
size | the length of data to 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 | |||
) |
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.
wav | the wav struct | |
buf | the data to be writen | |
len | the amount of bytes to write |
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 FMT_CHUNK_HEADER::bit_per_sample, FMT_CHUNK_HEADER::byte_per_sample, FMT_CHUNK_HEADER::byte_per_sec, COMMON_CHUNK_HEADER::chunk, WAV::file, COMMON_CHUNK_HEADER::fmt, FMT_CHUNK_HEADER::format, COMMON_CHUNK_HEADER::length, FMT_CHUNK_HEADER::nb_channel, FMT_CHUNK_HEADER::sample_rate, SWAP_LONG, SWAP_WORD, and COMMON_CHUNK_HEADER::type.
Referenced by kb_wav_close(), and kb_wav_open().