Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: MP3 Decoder

  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question MP3 Decoder

    Hi Everyone,

    Im in need of a little help.

    I am wanting to write a MP3 Decoder in C++ so i can make DLL from it and use it in a C# project.

    The problem is that i havent a clue where to start?

    All im after is the method of how to play a mp3 using APIs/Methods? I know how to create a DLL thats simple.

    Thanks in advance

    Hyder

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Two ways that I know of: the easy way or the hard way
    The easy way: MCIWndXXX functions
    Hard way (not hard but more difficult actaly): DirectShow

    Here's the code with the MCIWnd functions. I can give you the directshow code also but then you have to wait a while because I need to do some cleanup first. This one is just a copy past from a project of mine. This isn't a final version of it. I just don't have the time to finish it. (seek function, see if the file is finished, etc.)
    header std_out.h:
    Code:
    #ifdef __cplusplus
    #define EXPORT extern "C" __declspec (dllexport)
    #else
    #define EXPORT __declspec (dllexport)
    #endif
    
    EXPORT void Play (char filename[MAX_PATH]);
    EXPORT BOOL CleanUp(void);
    EXPORT void Initilize(HWND hwnd, HINSTANCE hInst);
    EXPORT void Pause();
    EXPORT void Resume();
    EXPORT void SetVolume(int volume);
    source:
    Code:
    // Pulsar std_out_module functions
    //
    //////////////////////////////////////////////////////////////////////
    #include <windows.h>
    #include <stdio.h>
    #include <vfw.h>
    
    #include "std_out.h"
    
    #pragma comment(lib, "vfw32.lib") 
    
    HWND g_stream;
    HWND g_hwnd;
    HINSTANCE g_hInst;
    
    //appentry
    BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
    {
    	return TRUE;
    }
    
    //pulsar functions
    EXPORT BOOL CleanUp(void)
    {
    	MCIWndStop(g_stream);
    	if(g_stream !=NULL)
    	{
    		MCIWndDestroy(g_stream);
    	}
    	return true;
    }
    
    EXPORT void Play (char filename[MAX_PATH])
    {
            g_stream=NULL;
    	g_stream = MCIWndCreate(g_hwnd,g_hInst,WS_CHILD,filename);
    	MCIWndPlay(g_stream);
    	return;
    }
    
    EXPORT void Stop()
    {
    	if(g_stream !=NULL)
    	{
    		MCIWndDestroy(g_stream);
    	}
    	return;
    }
    
    EXPORT void Pause()
    {
    	MCIWndPause(g_stream);
    	return;
    }
    
    EXPORT void Resume()
    {
    	MCIWndResume(g_stream);
    	return;
    }
    
    EXPORT void SetVolume(int volume)
    {
    	MCIWndSetVolume(g_hwnd,volume);
    	return;
    }
    
    EXPORT void Initilize(HWND hwnd, HINSTANCE hInst)
    {
    	g_hwnd=hwnd;
    	g_hInst=hInst;
    	return;
    }
    It is posible that there is still an error in that I overlooked (I delete some code that was specific to my app) and the code isn't probably the best out I've ever written but it should work.

    BTW, it also plays WMA and various other formats in case you're intrested
    Last edited by maes; 04-16-2004 at 06:55 PM.
    If you don't succeed at first, redefine succes

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi maes,

    Thanks alot for your help, i really apprentiate it!!!!

    Also I wanted to run different formats so thanks for that as well

    Now i can get started.

    Hyder Ali

  • #4
    New Coder
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These links might be helpful as well...
    http://www.jocsoft.com/vvmp3/mp3dep.htm

    There are some opensource MP3 decoders out there from which you can use the libraries
    Jason B

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks Again

    Thanks alot !



    Hyder Ali


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •