Sound Question

Started by
5 comments, last by johnnyBravo 19 years, 6 months ago
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.
Advertisement
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
Whatsoever you do, do it heartily as to the Lord, and not unto men.
and what about direct Show, id prefer that since the rest of my game is running on directX
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.
Screw mp3s, use ogg.

Also, a good, free, easy to use, open source audio library can be found at: http://audiere.sourceforge.net

Its called Audiere.
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
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?

This topic is closed to new replies.

Advertisement