How can you play Ogg files in DirectSound?  
Author Message
Brandon Amoroso





PostPosted: Game Technologies: DirectX 101, How can you play Ogg files in DirectSound? Top

Okay, as suggested, I'm going to try using "Ogg" files instead of MP3 files. I've already found a free app that converts mp3 to ogg, so all I really need now is a way to play them! This is for background music, so ideally I would like to create a class with the following interface:

public class OggPlayer()
{
public void Load( string filename );
public void Play( bool playLooped );
public void Stop();
public void SetVolume( int volume );
}

Because this is background music, it obviously needs to loop automatically. And because I don't want it cutting off rudely mid-note, I would like to be able to fade it out as well (thus the "SetVolume" method).

So I know exactly what I want; my main difficulty is that I've never worked with ogg files in my life, and I'd never worked with DirectSound until about two weeks ago!

Can anyone post some code examples that would be helpful, or perhaps even a link to a tutorial or class that already does this I'm working with C# and managed DirectX, if that helps narrow the field at all...




Game Technologies: DirectX, XNA, XACT, etc.16  
 
 
The ZMan





PostPosted: Game Technologies: DirectX 101, How can you play Ogg files in DirectSound? Top

http://www.thezbuffer.com/articles/252.aspx



 
 
Brandon Amoroso





PostPosted: Game Technologies: DirectX 101, How can you play Ogg files in DirectSound? Top

That's pretty cool! Is there any way to have the ogg automatically loop, or control volume (This is for background music, after all...)

 
 
The ZMan





PostPosted: Game Technologies: DirectX 101, How can you play Ogg files in DirectSound? Top

I beleive that sample uses DirectSound to actually play - since DirectSound can change volume (see the erffects) and loop I imagine you could make it do that if it doesn't do it by default.

 
 
Ralph Trickey





PostPosted: Game Technologies: DirectX 101, How can you play Ogg files in DirectSound? Top

How can you play them through DirectSound from a C++ Win32 application