Jump to content
  • Advertisement
Sign in to follow this  
partaire

slimDX simple play sound example needed

This topic is 2864 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

Very new to game development... first time. Using VB2010 because I was familiar with VB6 once upon a blue moon and the VB 2010 Express was a free download. Graphically got the game done in no time, 5 days. My only hurtle is now playing sound. Originally just for purposes of getting game running I used Computer.Audio.Play, but this does not allow me to play out of a secondary sound device which is a necessity. After surfing forums I saw that the "best" way to do this was through the use of DirectX. I ended up downloading SlimDX because I couldn't figure out how to add DirectX as a reference. I installed it, but it did not show up in my .Net reference list. So my question is this:

How can I use slimDX to play an audio file in VB?

I can find about 1000000000000000 examples of how to do every "advanced" trick in the book with it, but I cannot find a single example in VB of how to simply create a buffer, populate it, and play it. I have found some examples in C#, but when I converted them to VB (via online converters) not a single one of the 13 examples would compile. Each one was hundreds of lines of code so it was a little much for me to debug since I don't know C# very well. I feel like there should be a way to play a simple wave file using slimDX under 200kb in under ten lines of code. I have been working on the sound for 8 days now, which is sad considering the "hard part" of the game was finished in five and I haven't taken a single step forward in over a week.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by partaire
this does not allow me to play out of a secondary sound device
I don't really do sound programming and for my personal use I just have one 2-speaker set.

Is this even a remotely common thing to do in games? I really don't know.

Share this post


Link to post
Share on other sites
No it is not very common. But what is more common is to control channels of sound output. I.e. output a sound to the left speaker only, which would/could be done via use of the same tools.

Share this post


Link to post
Share on other sites
Then two suggestions. First, go to the #gamedev IRC chat room. Many of the SlimDX authors hang out there. Second, if SlimDX isn't cutting it, have you checked out NAudio? I can only access the main page so I'm not sure it even supports what you want, but it looks fairly popular and there is a discussion forum just for NAudio so it might give you better help than you're getting here.

Share this post


Link to post
Share on other sites
Found it! I did look a bit at nAudio and then I found what I was looking for in C# at this link.

http://code.google.com/p/slimdx/source/browse/trunk/samples/XAudio2/BasicSound/Program.cs?r=1485

Exactly what I was after :-D I used an online C# to VB converter to change it to Visual Basic and then all I did was replace the line:
MasteringVoice masteringVoice = new MasteringVoice(device);
with the line:
MasteringVoice masteringVoice = new MasteringVoice(device, 0, 0, 3);
to select the proper sound device. Well, I did it in VB but for the forum I put the code change in C# because that is what the link's example is written in. You have to download, install and add reference to SlimDX for it to work, but that is way easy to find on the net.

Thanks for helping look.

For the sake of forum searching I'm adding a few key words:
.wav wavestream buffer user32.dll alternate sound device file stream

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!