• Advertisement
Sign in to follow this  

sound & music problem

This topic is 4221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi friends I'm going to implement something for sound & music, can I use some form of class for any sound? I mean can I define 4 sound objects and play them together? what about the buffers? when I play the 2nd sound, the 1st one stops playing, how many sounds can I play at the same time? how can I play several files together? any sample? source code? another question, how can I play mp3 files? thanks a lot

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Firstly - what language (C, C++, C#, VB...) and which API (DirectX8, DirectX9...)?

Look into DirectSound in the DirectX SDK - it only plays .WAV files but is pretty good for sound effects and so on. Look into XACT as well (its the preferred tool going forwards).

Playing MP3 files is slightly more involved - the deprecated DirectShow (see the PSDK) is probably your best bet for this. Bare in mind that if you're making a commercial project then MP3 licencing may well apply if you distribute MP3-encoded media. The "OGG" format seems to be highly recommended.

hth
Jack

Share this post


Link to post
Share on other sites
I recommend using OpenAL for audio. I think Direct3D and OpenAL make a great combination for games, as demonstrated by id Software's Quake 4.

The reason I say this is because I was writing a DX game and I wanted 3D positional audio, which DirectSound does support but it's easier in OpenAL. Surprisingly, I finished a whole audio "engine" in a few days because I made the switch (it supports everything a game could ever want, including streaming from .ogg files and loading WAVs, 3D positional audio, etc.). And believe me, I'm not that great of a programmer yet.

In OpenAL, every sound is naturally 3D which is great for games, and for things like backgroun music you just place the source at the listerner position.

Recently i discovered that streaming Ogg Vorbis files (which are great, by the way) is easy with the Ogg Vorbis SDK and OpenAL combined. Ogg Vorbis is an audio format that uses less space than MP3 does, and sounds better (in my opinion). Also, unlike MP3s, Ogg Vorbis has pretty much no restrictions with liscensing and stuff. You can use Vorbis files however you want.

And for a great, free audio editor use Audacity. It natively supports loading/exporting Ogg Vorbis files and it's the best audio editor I've ever seen (and IT'S FREE...yay!).

So OpenAL/Ogg Vorbis/Audacity makes a great combination of audio utilities and libraries.

Edit: It's also easy to play the same sound multiple times simultaneously, even in different positions! Just use different sources for the same buffer. Beats DirectX Audio...but long live Direct3D.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement