MP3

Started by
4 comments, last by temo 22 years, 9 months ago
Where can I find source code and possibly documentation on the mp3 format so that I might write a program to play them. Are mp3''s used in games a lot now? Just thought I''d ask that...
Advertisement
yes, mp3's are pretty widely used in games today. If you think you're a pro, then you can find the format at Wotsit.org. I would recomend using DirectShow to load it. here's all code to play an mp3 with directshow, (this doesn't include other features, just a basic sample)
    #include <dshow.h>void main(void){    IGraphBuilder *pGraph;    IMediaControl *pMediaControl;    IMediaEvent   *pEvent;    CoInitialize(NULL);        // Create the filter graph manager and query for interfaces.    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,                         IID_IGraphBuilder, (void **)&pGraph);    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);    pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);    // Build the graph. IMPORTANT: Change string to a file on your system.    pGraph->RenderFile(L"C:\\Hello_World.avi", NULL);    // Run the graph.    pMediaControl->Run();    // Wait for completion.     long evCode;    pEvent->WaitForCompletion(INFINITE, &evCode);    // Clean up.    pMediaControl->Release();    pEvent->Release();    pGraph->Release();    CoUninitialize();}    

that's strait from msdn online. some people use fmod, gaudio, bass, or similar libraries. they are free for non-comercial use.

HHSDrum@yahoo.com
Polarisoft Home Page

Edited by - Julio on July 18, 2001 1:28:52 PM
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
IN your code you have "HelloWorld.avi" would you just replace that with an mp3 file to play a mp3?

Lo Man,

This is prolly not what you want but just in case.......

I''m making an MP3 player for a project in college and I''ve found quite a bit of stuff on ''em, but only for Visual Basic. Making a player in Visual Basic is simple if you use the media player OCX.

Here are a few links which might help:

http://home12.inet.tele.dk/mkaratha/
http://www.elementkjournals.com/ivb/0011/ivb00b1.htm
www.vbweb.co.uk (Search for MP3''s).

Heres one for C/C++ which I''ve not got around to trying:

www.xaudio.com

It''s not a player, it''s and API.

For things like graphic equalisers, visual equalisers, etc. Just search on places like www.planetsourcecode.com and www.programmersheaven.com.

Cya

CoiN

Hello, i am using DirectSound. is Direct Show better to play sounds? Should i switch over to direct show?
yes temo, you just replace the file names. DirectSound is better for sound effects, mainly wave files. directshow was intended for video stuff, but works well with mp3''s and many sound type. I would recomending learning both.

HHSDrum@yahoo.com
Polarisoft Home Page
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

This topic is closed to new replies.

Advertisement