Sign in to follow this  
_Phalanx_

Sound Question

Recommended Posts

Hey, i have two task that i want to do in my game: Play Mp3s for music, i know this can be dont with DirectShow but could somone plz give me a link to a good, simple, yet explained tutorial for doing this? Also i want to adjust the Pan, Volume and Pitch of each of my sounds individually, i heard this can be done using audiopaths, but again, i need a good tutorial to learn how to set them up and use them, thanks.

Share this post


Link to post
Share on other sites
look up FMOD & openAL. I think they both support mp3 now & you can do lots of real low level details with the sound. You might have to write a few classes (or some other kind of code) that you can call your "sound package" that uses the capabilities of either of these APIs. For example:
fadeSoundLoudness(soundID,toSilent,mSeconds);
fadeSoundLoudness(soundID,toMax,mSeconds);
fadeSoundSpeed(soundID,toDoubleFreq,mSeconds);
fadeSoundSpeed(soundID,toHalfFreq,mSeconds);

there is a decent (not extraordinary) amount of documentation about either of these sound APIs online. good luck

Share this post


Link to post
Share on other sites
You shouldn't use MP3 in your games. Click here to see why. The "No license fees are due if less than 5 000 copies of a particular game title are distributed" line can become a double-edged sword if your homebrew game is downloadable.

Use something else. OGG works quite well, it was used in DOOM3 and Unreal Tournament 2004, as example.

Share this post


Link to post
Share on other sites
My dshow music class. it basically loads the mp3 or whatever then u play it using the:
getMediaControl()->Run();


#define _WIN32_DCOM
#include <dshow.h>

class ADX_API Music {
private:
IGraphBuilder *g_pGraphBuilder;
IMediaControl *g_pMediaControl;
IMediaSeeking *g_pMediaSeeking;
IBasicAudio *g_pBasicAudio;
public:
Music();
~Music();
bool create();
bool load(const char filename[]);
IMediaControl * getMediaControl(){return g_pMediaControl;}
IMediaSeeking * getMediaSeeking(){return g_pMediaSeeking;}
IBasicAudio * getBasicAudio(){return g_pBasicAudio;}
};

Music::Music()
{
g_pMediaControl = NULL;
g_pMediaSeeking = NULL;
g_pBasicAudio = NULL;
g_pGraphBuilder = NULL;
}
Music::~Music()
{
if(g_pMediaControl)
{
g_pMediaControl->Release();
g_pMediaControl = NULL;
}
if(g_pMediaSeeking)
{
g_pMediaSeeking->Release();
g_pMediaSeeking = NULL;
}
if(g_pBasicAudio)
{
g_pBasicAudio->Release();
g_pBasicAudio = NULL;
}
if(g_pGraphBuilder)
{
g_pGraphBuilder->Release();
g_pGraphBuilder = NULL;
}
}
bool Music::create()
{
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
return false;

if(FAILED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, reinterpret_cast<void **>(&g_pGraphBuilder))))
return false;

if(FAILED(g_pGraphBuilder->QueryInterface(IID_IMediaControl,reinterpret_cast<void **>(&g_pMediaControl))))
return false;

if(FAILED(g_pGraphBuilder->QueryInterface(IID_IMediaSeeking,reinterpret_cast<void **>(&g_pMediaSeeking))))
return false;

if(FAILED(g_pGraphBuilder->QueryInterface(IID_IBasicAudio,reinterpret_cast<void **>(&g_pBasicAudio))))
return false;

return true;
}
bool Music::load(const char filename[])
{
WCHAR wFilename[MAX_PATH];
MultiByteToWideChar(CP_ACP,0,filename,-1,wFilename,MAX_PATH);
LPCWSTR lwFilename= wFilename;
if(FAILED(g_pGraphBuilder->RenderFile(lwFilename,NULL)))
return false;

return true;
}





eg an example
[soure]
Music m;
m.load("c:\song.mp3");
m.create();
m.getMediaControl()->Run();
[/source]

You can change volume etc using the other gets. Just check the directx help file for info on the interfaces

Share this post


Link to post
Share on other sites
Quote:
Original post by M3d10n
You shouldn't use MP3 in your games. Click here to see why. The "No license fees are due if less than 5 000 copies of a particular game title are distributed" line can become a double-edged sword if your homebrew game is downloadable.


what so if im using direct show to play mp3s , and more than 5000 copies of the program are distributed, technically i could get sued?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this