Play input microphone audio to ausio output

127 Views Asked by At

I have a capture card and I ant to display the Video and play the input Sound. I got the video input by using the CaptureElement and MediaCapture

Capturemanager = new MediaCapture();

        DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            device = devices[0];

       

        var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = device.Id };

        await Capturemanager.InitializeAsync(mediaInitSettings);

        CamCaptureElement.Source = Capturemanager;
        await Capturemanager.StartPreviewAsync();

But this does not work for the input microphone. I tried it tis way:

            AudioCapturemanager = new MediaCapture();

        DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture);

            audioDevice = devices[0];

        var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = audioDevice.Id };
        mediaInitSettings.StreamingCaptureMode = StreamingCaptureMode.Audio;
        await AudioCapturemanager.InitializeAsync(mediaInitSettings);

        CamCaptureElement.Source = AudioCapturemanager;
        await AudioCapturemanager.StartPreviewAsync();

How can I get the audio and play it instantly?

Thanks

1

There are 1 best solutions below

2
dear_vv On

When capturing audio, you used VideoDeviceId. You could try to use AudioDeviceId instead.