• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[C#] mp3 decoder

Status
Not open for further replies.
Hi everyone

I'm trying to decode mp3 files in C#. I've searched around for any resources to help me do so and found this: madlldlib.dll. Its my first time trying to import dll files. After a quick visit at msdn I figured that I basically declare a usable function in the dll file. I searched mydlldlib (download from first link) and found this:

Code:
/* 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

So I tried to declare that function in C# as follows:

Code:
    class MP3Decoder
    {
        [DllImport("C:\\Users\\1User\\Documents\\Visual Studio 2012\\Projects\\Sound Wave\\Sound Wave\\madlldlib.dll")]
        private static extern long CbMpegAudioDecoder(string InFN, string OutFN, int WavPad, string StatMsg);

        public void decode()
        {
            string input = "C:\\Users\\1User\\Music\\I Wanna Be.mp3";
            string output = "C:\\Users\\1User\\Music\\out.txt";
            string error = "";
            CbMpegAudioDecoder(input, output, 1, error);
        }
    }

I get an error saying "unable to find an entry point named CbMpegAudioDecoder. What am I doing wrong?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
You have not specified an "EntryPoint" for the DllImport? At least that would make sense. It cannot find the entry point named "CbMpegAudioDecoder" because you never declared an entry point named "CbMpegAudioDecoder".

Try...
Code:
        [DllImport("C:\\Users\\1User\\Documents\\Visual Studio 2012\\Projects\\Sound Wave\\Sound Wave\\madlldlib.dll", EntryPoint = "CbMpegAudioDecoder")]
        private static extern long CbMpegAudioDecoder(string InFN, string OutFN, int WavPad, string StatMsg);
 
Status
Not open for further replies.
Top