• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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,198
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