Go to the source code of this file.
Defines | |
#define | print_type(t) printf("%c%c%c%c\n" , t[0], t[1], t[2], t[3]) |
Functions | |
int | kb_wav_play (snd_t *snd, char *filename, unsigned soundbufsize) |
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) |
wav files handling
Definition in file kb_wav.c.
#define print_type | ( | t | ) | printf("%c%c%c%c\n" , t[0], t[1], t[2], t[3]) |
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_play | ( | snd_t * | snd, | |
char * | filename, | |||
unsigned | soundbufsize | |||
) |
Play a wav file to the given sound interface. The sound interface must be initialized first using kb_sound_init and kb_sound_open. This function does not return until the full wav file is played.
snd | the sound interface | |
filename | the name of wav file to play | |
soundbufsize | the size of the sound buffer |
Definition at line 37 of file kb_wav.c.
References FMT_CHUNK_HEADER::bit_per_sample, buf, WAV::fmt, KB_ERROR, KB_ERROR_BADSOUND, KB_ERROR_FILEOPEN, kb_snd_play(), KB_WARN_SOUNDIO, KB_WARN_SOUNDSAMPLE, kb_warning(), kb_wav_close(), kb_wav_init(), kb_wav_open(), kb_wav_read_data(), and FMT_CHUNK_HEADER::nb_channel.
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().