voice modem WaveIn CaptureDevice
- From: "Jeff" <spam.hillman@xxxxxxxxx>
- Date: 12 Oct 2005 17:58:36 -0700
I am developing an answering machine in C# using TAPI 3.0 and
Microsoft's mananged DirectX 9.
I am answering the phone, getting an ITBasicCallControl object from the
ITCallInfo object which I set with the Call property on the
ITCallNotificationEvent object I receive when the call comes in.
I am trying to create a DirectX.DirectSound.CaptureBuffer with my voice
modem's WaveIn device, but it is failing. Below is my code:
ITLegacyCallMediaControl2 mediaControl =
(ITLegacyCallMediaControl2)basicCallControl;
int deviceID = BitConverter.ToInt32( (byte
[])mediaControl.GetIDAsVariant( "wave/in" ), 0 );
Guid waveInGuid = Guid.Empty;
// Get the driver guid for the modem's WaveIn
CaptureDevicesCollection captureDeviceCollection = new
CaptureDevicesCollection();
for ( int i = 0; i < captureDeviceCollection.Count && waveInGuid ==
Guid.Empty; i++ )
{
DeviceInformation deviceInformation = captureDeviceCollection[ i ];
if ( Regex.Match( deviceInformation.ModuleName, "WaveIn 1" ).Success
)
{
waveInGuid = deviceInformation.DriverGuid;
}
}
Microsoft.DirectX.DirectSound.Capture captureDevice = new
Microsoft.DirectX.DirectSound.Capture( waveInGuid );
// Set up the WaveFormat
WaveFormat format = new WaveFormat();
format.SamplesPerSecond = 8000;
format.BitsPerSample = 8;
format.Channels = 1;
format.BlockAlign = (short)( format.Channels * ( format.BitsPerSample /
8 ) );
format.AverageBytesPerSecond = format.BlockAlign *
format.SamplesPerSecond;
format.FormatTag = WaveFormatTag.Pcm;
CaptureBufferDescription captureBufferDescription = new
CaptureBufferDescription();
captureBufferDescription.BufferBytes = format.AverageBytesPerSecond;
captureBufferDescription.Format = format;
CaptureBuffer captureBuffer = new CaptureBuffer(
captureBufferDescription, captureDevice );
On the above line, I get a
Microsoft.DirectX.DirectSound.BadFormatException:
"An unhandled exception of type
'Microsoft.DirectX.DirectSound.BadFormatException' occurred in
microsoft.directx.directsound.dll
Additional information: Error in the application."
I don't have any trouble creating a CaptureBuffer with the "Primary
Sound Capture Driver", so it looks like there is either a problem with
the WaveFormat struct I am using, or something else with the modem's
WaveIn device.
Any help that can be given will be appreciated.
Jeff
.
- Prev by Date: RE: (Solution) Frustum Culling in C# / VB.NET
- Next by Date: Re: sampleFramework.SetKeyboardCallback
- Previous by thread: RE: (Solution) Frustum Culling in C# / VB.NET
- Next by thread: Directx 9 vb.net books
- Index(es):
Relevant Pages
|