From f485ee1c197bd29727218dbb68b48df47f816dda Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 22 Jul 2014 15:54:56 -0600 Subject: Rename pcm_decode.h to pcm.h since it will hold more than just decoding definitions. Fix some porting errors like idbg should auddbg, etc. Add wav file header and a few low-level wav utilities. --- nuttx/audio/pcm_decode.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'nuttx/audio') diff --git a/nuttx/audio/pcm_decode.c b/nuttx/audio/pcm_decode.c index ba817a313..6cf7327fc 100644 --- a/nuttx/audio/pcm_decode.c +++ b/nuttx/audio/pcm_decode.c @@ -55,7 +55,7 @@ #include #include -#include +#include #if defined(CONFIG_AUDIO) && defined(CONFIG_AUDIO_FORMAT_PCM) @@ -99,6 +99,10 @@ struct pcm_decode_s * Private Function Prototypes ****************************************************************************/ +#ifdef CONFIG_PCM_DEBUG +static void pcm_dump(FAR const struct wav_header_s *wav) +#endif + /* struct audio_lowerhalf_s methods *****************************************/ static int pcm_getcaps(FAR struct audio_lowerhalf_s *dev, int type, @@ -177,6 +181,49 @@ static int pcm_release(FAR struct audio_lowerhalf_s *dev); * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: pcm_dump + * + * Description: + * Dump a WAV file header. + * + ****************************************************************************/ + +#ifdef CONFIG_PCM_DEBUG +static void pcm_dump(FAR const struct wav_header_s *wav) +{ + printf( "Wave file header\n"); + printf( " Chunk ID: 0x%08x\n", wav->chkid); + printf( " Chunk Size: %u\n", wav->chklen); + printf( " Format: 0x%08x\n", wav->format); + printf( " SubChunk ID: 0x%08x\n", wav->subchkid1); + printf( " Subchunk1 Size: %u\n", wav->subchklen1); + printf( " Audio Format: 0x%04x\n", wav->compression); + printf( " Num. Channels: %d\n", wav->nchannels); + printf( " Sample Rate: %u\n", wav->samprate); + printf( " Byte Rate: %u\n", wav->byterate); + printf( " Block Align: %d\n", wav->align); + printf( " Bits Per Sample: %d\n", wav->bpsamp); + printf( " Subchunk2 ID: 0x%08x\n", wav->subchkid2); + printf( " Subchunk2 Size: %u\n", wav->subchklen2); +} +#endif + +/**************************************************************************** + * Name: pcm_validwav + * + * Description: + * Return true if this is a valid WAV file header + * + ****************************************************************************/ + +static inline bool pcm_validwav(FAR const struct wav_header_s *wav) +{ + return (wav->chkid == WAV_CHUNKID && + wav->format == WAV_FORMAT && + wav->subchklen1 == WAV_SUBCHKLEN1); +} + /**************************************************************************** * Name: pcm_getcaps * -- cgit v1.2.3