Sign in to follow this  
RoyChen204

Ogg on DirectSound

Recommended Posts

hi, I am new to DirectSound, and just got to know how to create 3D audio and simple sounds with DirectSound, but I find wav files too big and is trying to do for ogg. I seen one of the topics regarding this, but I do have various questions. One would be, so far, I am most familar with IDirectMusicSegment, so is it possible to convert the ogg during play and place it in the segment, or must I fit it to a sound buffer? I only used IDirectMusicPerformance8 IDirectMusicLoader8 IDirectSound3DListener8 IDirectMusicSegment8 IDirectMusicAudioPath8 IDirectSound3DBuffer8 though and not much experience in really creating a sound buffer.

Share this post


Link to post
Share on other sites
There comes a point at which sound files become too big for preloaded samples to be a good idea. When this happens, you should use streaming. You don't need to touch DirectMusic interfaces at all. What you should do in this case is have a smallish DirectSound buffer (I found that a 64k buffer works well) and use this to stream directly from the ogg file.

Instructions for how to do this are in the DirectX9 documentation at
DirectSound->Using DirectSound->DirectSound Buffers->Using Streaming Buffers

Naturally, the DirectX docs don't tell you how to read ogg files. If it's ogg vorbis that you want then I recommend using the vorbisfile library for reading.

Share this post


Link to post
Share on other sites
if I want 3D sound, how do I go about doing it?

For 3D sounds, I used to have an Audiopath, a 3D sound buffer and a listener.

However, these come into effect as the Performance->PlaySegmentEX takes in the segment and the AudioPath required to play.However, with the buffer it just plays.

When creating the buffer with DSBUFFERDESC , I could change the flag to DSBCAPS_CTRL3D, but how do I manipulate? if I used a 3D sound buffer, it doesnt have the play in it, so how do I can impose the 3D position onto the 2D buffer to play?

Now if I dont use Audio Path, will the listener be affected?

Share this post


Link to post
Share on other sites
I should mention that I personally don't use any DirectMusic interfaces at all, so I can't comment on how AudioPath and Performance behave.

For 3D sound with only DirectSound all you really need is a listener and a regular IDirectSoundBuffer buffer. The buffer must be created with DSBCAPS_CTRL3D and should also be mono (as far as I know, non-mono sounds can't use DSBCAPS_CTRL3D).

You can then use the IDirectSoundBuffer::QueryInterface with an interface ID of IID_IDirectSound3DBuffer8 to retrieve a IDirectSound3DBuffer interface. These are actually two different interfaces to the same buffer - you need to use both together to to 3D sound. The IDirectSoundBuffer has playback methods and the IDirectSound3DBuffer has methods to set position and velocity.

Share this post


Link to post
Share on other sites
I really wouldn't use DirectMusic for this. I don't know if DirectMusic can play .ogg files directly, I suspect it can't, meaning you'll need to fall back to DirectSound for this anyway.

Vorbis streaming is pretty simple to do with DirectSound though.

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