I also had problems using managed directsound, when I added reference to Microsoft.DirectX.DirectSound I can play sound without problems, but there is problem capturing sound. The example in C# works fine but when I do the same in C++ there is a System.Exception:
Message "Object reference not set to an instance of an object."
Source "Microsoft.DirectX.DirectSound"
StackTrace " at Microsoft.DirectX.DirectSound.Notify..ctor(CaptureBuffer lp)
at CaptureVoice.InitNotifications() in c:\my documents\visual studio projects\capturevoice.cpp:line 84"
I'm using MS Visual studio .Net 2003 and DirectX SDK December 2005 and the code is like this:
applicationDevice =
new Capture(); // Caps is setInputFormat = WaveFormat();
InputFormat.FormatTag = WaveFormatTag::Pcm;
InputFormat.BitsPerSample = 8;
InputFormat.SamplesPerSecond = 8000;
InputFormat.Channels = 1;
InputFormat.BlockAlign = (
short)(InputFormat.Channels * (InputFormat.BitsPerSample / 8));InputFormat.AverageBytesPerSecond = InputFormat.BlockAlign * InputFormat.SamplesPerSecond;
NotifySize = (1024 > InputFormat.AverageBytesPerSecond / 8) 1024 : (InputFormat.AverageBytesPerSecond / 8);NotifySize -= NotifySize % InputFormat.BlockAlign;
CaptureBufferSize = NotifySize * NumberRecordNotifications;
CaptureBufferDescription dscheckboxd = CaptureBufferDescription();
dscheckboxd.BufferBytes = CaptureBufferSize;
dscheckboxd.Format = InputFormat;
applicationBuffer =
new CaptureBuffer(&dscheckboxd, applicationDevice); // Caps is NOT setNotifyThread =
new Thread(new ThreadStart(this,&CaptureVoice::WaitThread));NotifyThread->Start();
NotificationEvent =
new AutoResetEvent(false); applicationNotify = new Notify(applicationBuffer); // this throws exceptionCan someone help me please, maybe it's some stupid slip but I can't see it. I also have another question, is it possible to use some codecs with managed directsound thanx

DirectSound Capture problem
Gnomie
That doesn't make sense. Are you saying the DirectSound samples written in C++ in the Sample Browser don't work but the C# samples do What is the specific error your get then
TimHiggison
Dennishx
Mohamed Salah
There are several C++ DirectSound samples found in the Sample Browser in the SDK. Do none of those work