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); } } }
private void initMasterPeakRetrieval() { Microsoft.DirectX.DirectSound.CaptureDevicesCollection audioDevices = new Microsoft.DirectX.DirectSound.CaptureDevicesCollection(); Microsoft.DirectX.DirectSound.DeviceInformation deviceInformation = audioDevices[captureMixer.DeviceId]; initMasterPeakRetrieval(deviceInformation); }
private void initMasterPeakRetrieval(string deviceName) { Microsoft.DirectX.DirectSound.CaptureDevicesCollection audioDevices = new Microsoft.DirectX.DirectSound.CaptureDevicesCollection(); for (int deviceId = 0; deviceId < audioDevices.Count; deviceId++) { if (audioDevices[deviceId].Description == deviceName) { initMasterPeakRetrieval(audioDevices[deviceId]); break; } } }
private string getDeviceFriendlyName(Guid deviceGuid, bool trimAtLengthLimit) { // Retrieve the available DirectSound capture devices Microsoft.DirectX.DirectSound.CaptureDevicesCollection audioDevices = new Microsoft.DirectX.DirectSound.CaptureDevicesCollection(); for (int deviceId = 0; deviceId < audioDevices.Count; deviceId++) { if (audioDevices[deviceId].DriverGuid == deviceGuid) { if (!String.IsNullOrEmpty(audioDevices[deviceId].Description)) { if (trimAtLengthLimit && audioDevices[deviceId].Description.Length > DEVICE_FRIENDLY_NAME_MAX_LENGTH) { return audioDevices[deviceId].Description.Substring(0, DEVICE_FRIENDLY_NAME_MAX_LENGTH); } else { return audioDevices[deviceId].Description; } } else { return null; } } } return null; }