private void terminateMasterPeakRetrieval() { if (buffer != null) { if (buffer.Capturing) { buffer.Stop(); } buffer.Dispose(); buffer = null; } }
private void initMasterPeakRetrieval(Microsoft.DirectX.DirectSound.DeviceInformation deviceInformation) { Microsoft.DirectX.DirectSound.CaptureDevicesCollection audioDevices = new Microsoft.DirectX.DirectSound.CaptureDevicesCollection(); for (int deviceIndex = 0; deviceIndex < audioDevices.Count; deviceIndex++) { if (captureMixer.DeviceDetail.MixerName == audioDevices[deviceIndex].Description) { // captureMixer.DeviceDetail.MixerName // initialize the capture buffer on the defaut device Microsoft.DirectX.DirectSound.Capture cap = new Microsoft.DirectX.DirectSound.Capture(audioDevices[deviceIndex].DriverGuid); Microsoft.DirectX.DirectSound.CaptureBufferDescription desc = new Microsoft.DirectX.DirectSound.CaptureBufferDescription(); Microsoft.DirectX.DirectSound.WaveFormat wf = new Microsoft.DirectX.DirectSound.WaveFormat(); wf.BitsPerSample = 16; wf.SamplesPerSecond = SAMPLE_FREQUENCY; wf.Channels = 2; wf.BlockAlign = (short)(wf.Channels * wf.BitsPerSample / 8); wf.AverageBytesPerSecond = wf.BlockAlign * wf.SamplesPerSecond; wf.FormatTag = Microsoft.DirectX.DirectSound.WaveFormatTag.Pcm; desc.Format = wf; desc.BufferBytes = SAMPLES * wf.BlockAlign; buffer = new Microsoft.DirectX.DirectSound.CaptureBuffer(desc, cap); buffer.Start(true); } } }