|
-
Mar 16th, 2009, 05:37 AM
#1
Thread Starter
Fanatic Member
DirectSound
Where do I go to create a DirectSound file, and how do I use it to play certain audio files in a game?
-
Mar 16th, 2009, 06:37 AM
#2
Re: DirectSound
What do mean by a DirectSound file? DirectSound can play most common audio formats.
There are a few DirectSound wrapper classes around the Web. Better ones raise an event when a sound has finished playing.
-
Mar 16th, 2009, 06:40 AM
#3
Thread Starter
Fanatic Member
Re: DirectSound
Just to clarify, I have retrieved this sample code from another site:
Code:
private DS.Device sounddevice;
private SecondaryBuffer (sound);
using Microsoft.DirectX.DirectSound;
using DS = Microsoft.DirectX.DirectSound;
private void InitializeSound()
{
sounddevice = new DS.Device();
sounddevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
BufferDescription description = new BufferDescription();
description.ControlEffects = false;
(name)sound = new SecondaryBuffer("(soundname).wav", description, sounddevice);
(name)sound.Play(0, BufferPlayFlags.Default);
}
SecondaryBuffer new(name)sound = (name)sound.Clone(sounddevice);
new(name)sound.Play(0, BufferPlayFlags.Default);
private ArrayList soundlist = new ArrayList();
soundlist.Add(new(name)sound);
private void SoundAffairs()
{
if (soundlist.Count > 0)
{
for (int i = soundlist.Count - 1; i > -1; i--)
{
SecondaryBuffer currentsound = (SecondaryBuffer)soundlist[i];
if (!currentsound.Status.Playing)
{
currentsound.Dispose();
soundlist.RemoveAt(i);
}
}
}
}
Is a sound list similiar to the following (taken from my Press Your Luck game that was semi-created by another person):
[events]
# Buzzer sound
buzz
# Buzz-in sound
buzzIn
# Ding sound
ding
# Crowd sound
crowd
# Board sound
board2
# Pass sound
passSpin
# Freeze (during Whammy round)
freeze
# Whammy "boing"
bounce
# Whammy buzzer (only)
endWhammy
# Whammy "boom" (during Whammy round)
bounce
# Lose-1-Whammy sound
loseWhammy
# Null sound
empty
[music]
# Opening theme
openTheme1b
# End Question R1
QR1end
# Start Money R1
MR1start
# End Money R1
MR1end
# Start Question R2
QR2start
# End Question R2
QR2end
# Start Money R2
MR2start
# Win music
win
# Start post-game summary
startSummary
# Prize music
prize
# Closing theme
endTheme1
[prompts]
Press1
Press2
Press3
And do I create an DirectX or ActiveX control file for the DirectSound code?
-
Mar 16th, 2009, 07:14 AM
#4
Re: DirectSound
I guess you could make a ActiveX control but you don't need to. You can interface with DirectSound with pure VB and a reference to DirectX 7 or 8.
This is the first google hit I got.
-
Mar 16th, 2009, 11:10 AM
#5
Thread Starter
Fanatic Member
Re: DirectSound
DirectX control will only allow me to use certain sound quality and other stuff. It will not reference the .wav filename to play it in a form. Unless I overlooked something. What will I reference the sound from if I wish to play it in a form?
Can someone please upload a sample so I can see more clearly?
-
Mar 16th, 2009, 12:15 PM
#6
Re: DirectSound
DirectSound is a part of DirectX. It gives complete control over volume, pitch, balance, samples per second, bitrate etc. It can play up to 64 sounds simultaneously. The sounds themselves might be in a resource or Dll or on disk and can be of multiple formats.
This all can be done in VB with a reference to DirectX.
I'm away from home for the next few days when I get back and if someone does not beat me to it I'll post up an example (which I can test first).
-
Mar 16th, 2009, 12:54 PM
#7
Thread Starter
Fanatic Member
Re: DirectSound
 Originally Posted by Milk
The sounds themselves might be in a resource or Dll or on disk and can be of multiple formats.
This all can be done in VB with a reference to DirectX.
 Originally Posted by Milk
I'm away from home for the next few days when I get back and if someone does not beat me to it I'll post up an example (which I can test first).
That would be great!
-
Mar 16th, 2009, 04:22 PM
#8
Re: DirectSound
Milk 
@JonSea31: If you just want to avoid to diggin into advanced level of audio handling, you can always get a simple wrapper dll that is will play the audio for you. There's i havent found any really cheap solution, but mostly you can use them in your home (just like in freeware products as well), for free. For example, take a look at FMOD, or BASS, those have got built-in codecs to play numerous (both common/uncommon) file formats. You can get equalizer's, and some of the effect capabilities that is would be needed for a game programming. But the solutions are also fit for simple audio player applications as well.
Fmod: http://www.fmod.org/
Bass: http://www.un4seen.com/
Read the licences carefully to avoid any copyright issues.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|