Click here to Skip to main content
15,885,141 members
Articles / Desktop Programming / MFC

DLL To Decode MP3 To WAV/PCM

Rate me:
Please Sign up or sign in to vote.
4.56/5 (19 votes)
12 Jul 20043 min read 381.7K   9.2K   83  
Source code to produce a DLL that converts MP3 files to WAV or PCM. It is based on the open source library libmad.
/****************************************************************************
 * madlldlib                                        (c) 2004 J. A. Robson   *
 *																			*
 * Definitions file. See inline comments for details. See comments in       *
 * source files 'madlldlib.cpp' and 'test.cpp' for information on           *
 * programming madlldlib. To compile, see Makefile comments.                *
 *																			*
 ****************************************************************************/

#ifndef _MADLLDLIB_H_
#define _MADLLDLIB_H_

/* program includes */
#include <mad.h> /* must include this path in compile */


/* WAV structure 
 * Used in CbMpegAudioDecoder when instructed to write a
 * WAV header to the output file.
 */
typedef struct tag_wavhdr {	
		int RIFF;                // 'R','I','F','F'                
		int size;                   // size of wave file from here on
		int WAVE;             // 'W','A','V','E'
		int fmt;			 //'f','m','t',' '
		int   wFormatLength;          // The length of the TAG format    
		short    wFormatTag;             // should be 1 for PCM type data  
		short    nChannels;              // should be 1 for MONO type data
		int   nSamplesPerSec;         // should be 11025, 22050, 44100  
		int   nAvgBytesPerSec;        // Average Data Rate              
		short    nBlockAlign;            // 1 for 8 bit data, 2 for 16 bit
		short    wBitsPerSample;         // 8 for 8 bit data, 16 for 16 bit
		int data;                // 'd','a','t','a'                        
		int   datasize;               // size of data from here on              
} wavhdr;


/* function export */

/* callback decoder function (based on MpegAudioDecoder) */
extern "C" __declspec(dllexport) int __stdcall CbMpegAudioDecoder(
		const char *InFN, 		/* input filename */
		const char *OutFN, 		/* output filename */
		int WavPad, 			/* 1=WAV file output, other = PCM */
		char *StatMsg, 			/* status/error reporting */
		/* Callback definition below 
		 * The callback is used by this function to send
		 * reporting information back to the calling code
		 * while it is decoding.
		 */
		void (__stdcall *CbFunc)(unsigned long FrameCnt, unsigned long InByteTot, struct mad_header *Header)
		);


#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions