naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.55k stars 1.1k forks source link

Mimo HDMI Capture device not creating audio device laptop #718

Open dc-ucw opened 3 years ago

dc-ucw commented 3 years ago

We use HDMI capture devices (such as Magewell, Innogenni or Logitech) to capture video and audio from a laptop and display/play on a desktop system. When the laptop is plugged into capture device and the capture device is plugged into the desktop, A new "playback device" appears on the Control Panel -> Playback and Sound -> Manage Audio devices -> Playback tab. On the desktop computer we see a HDMI capture device under recording devices.

This all works fine with our custom app using the NAudio library.

However, one capture device - the Mimo HDMI Capture device - no audio playback device shows on the laptop at all and we cannot get audio. We can see on the desktop a "Plankton HDMI Capture Audio" device under recording devices. When we try using the MS Camera app or VLC media player, somehow these cause an audio playback device to appear on the laptop and we can then hear audio through these apps.

We have talked to the Mimo manufacturer and they do not know why our software with NAudio is not causing an audio playback device to appear on the laptop.

Below is our code. When debugging it all works OK - no errors. But no audio is present (probably because there is no audio device present on the laptop). Is there another call we can/should make that would trigger the audio device to appear on the laptop?

` WaveInCapabilities waveInCapabilities = NAudio.Wave.WaveIn.GetCapabilities(waveInDeviceNumber);

            //Input
            WaveIn = new WaveInEvent();
            WaveIn.BufferMilliseconds = 50;
            WaveIn.DeviceNumber = waveInDeviceNumber;

            if (waveInCapabilities.SupportsWaveFormat(SupportedWaveFormat.WAVE_FORMAT_96S16))
            {
                WaveIn.WaveFormat = new WaveFormat(96000, 2);
            }
            else if (waveInCapabilities.SupportsWaveFormat(SupportedWaveFormat.WAVE_FORMAT_44S16))
            {
                WaveIn.WaveFormat = new WaveFormat(48000, 2);
            }
            else if (waveInCapabilities.SupportsWaveFormat(SupportedWaveFormat.WAVE_FORMAT_4S16))
            {
                WaveIn.WaveFormat = new WaveFormat(44100, 2);
            }
            else if (waveInCapabilities.SupportsWaveFormat(SupportedWaveFormat.WAVE_FORMAT_2S16))
            {
                WaveIn.WaveFormat = new WaveFormat(22050, 2);
            }
            else if (waveInCapabilities.SupportsWaveFormat(SupportedWaveFormat.WAVE_FORMAT_1S16))
            {
                WaveIn.WaveFormat = new WaveFormat(11025, 2);
            }
            else
            {
                WaveIn.WaveFormat = new WaveFormat(11025, 1);
            }

            //Output
            WaveProvider = new BufferedWaveProvider(WaveIn.WaveFormat);
            WaveOut = new WaveOut();
            WaveOut.Init(WaveProvider);
            WaveOut.DesiredLatency = 50;
            WaveOut.Volume = (float)0.01;

            WaveIn.StartRecording();
            WaveOut.Play();`
ghost commented 3 years ago

You use in code " WaveIn" recording interface - IT IS VERY OLD (Win 95) audio recording interface, and it DEMANDS that audio capture devices output ONLY RAW WAVE stream. If Mimo Vue Capture outputs ONLY COMPRESSED audio stream (MP3, AAC, Dolby Surround) - then on interface " WaveIn" you have got NOTHING: there IS NOT any devices with output RAW WAVE stream.

Could you change NAudio.Wave.WaveIn on WASAPI ?

dc-ucw commented 3 years ago

Thanks for the info. We are testing with the NAudio "NAudioWpfDemo" Sample, using the WASAPI capture. It shows our device on the desktop, but does not cause an audio playback device to appear on laptop. Do we need to make a specific WASAPI call to trigger the laptop to show the playback device? Any other suggestions?

thanks!

ghost commented 3 years ago

So, it looks like problem with USB Audio Class driver on laptop - driver must redirect audio stream from USB class to WASAPI, but it does not. I previously said - " If Mimo Vue Capture outputs ONLY COMPRESSED audio stream (MP3, AAC, Dolby Surround)" - could you check what is format of output audio stream?

You can download project CaptureManager-SDK-Demos and compile and launch CaptureManager-SDK-Demos/CSharpDemos/WPFDeviceInfoViewer for getting all media devices streams formats info.

dc-ucw commented 3 years ago

Great, thanks for the help. Here is the info from the MIMO. We also tried the NAudio WASAPI capture example, but it did not work to capture the audio on the MIMO.

> \\usb#vid_266e8pid_50028&35d6fdc6
> Microphone (3- Plankton Captured HDMI Audio)
> Attributes of source
> The endpoint ID for an audio capture device.
{0.0.1.00000000}.{ff513b05-c504-480b-8962-5947 1b093cd5}
> The type of audio capture source.
Hardware device
> The display name for a device.
Microphone (3- Plankton Captured HDM! Audio)
> The symbolic link for a audio capture driver.
\VAASWD#MMDEVAPEHO.0. 100000000} .{ff5 1 3b05-c504-480b-8962-5947 1b093cd5}#(2eef81 be-33fa-4800-9670-10d474972c3f}
> The type of device.
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID
> The link for a capture device.
\\\usb4vid_266e&pid_50028&35d6fdc6
> Presentation - Stream count: 1
> Stream - Index: 0; StreamType: MFMediaType_Audio
> Attributes of Stream
> The name of a stream.
Audio stream
> MediaTypes - MediaTypes count: 1
> MediaType - Index: 0
> Average number of bytes per second.
384000
> Block alignment, in bytes.
8
> Number of audio channels.
2
> Major type GUID for a media type.
MFMediaType_Audio
> Specifies the assignment of audio channels to speaker positions.
| Values
> Number of audio samples per second (integer value).
48000
> Independent of samples.
True
> Number of bits per audio sample.
32
> Subtype GUID for a media type.
MFAudioFormat_Float
ghost commented 3 years ago

So, CaptureManager SDK recognize the target audio capture correct. It means that USB audio class works correct and produces Raw WAVE format in Float 32 bit format. In WasapiCaptureDemo/WasapiCaptureViewModel.cs there is the next code line: CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();

Could you check 'CaptureDevices' with DeviceState.All on presenting Plankton Captured HDMI Audio.

In desktop there is not default microphone, and code: var defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console); can return Plankton Captured HDMI Audio as default, However, laptop HAS default microphone, and it can skip Plankton Captured HDMI Audio

dc-ucw commented 3 years ago

Hi Xirexel, thanks for the help we really appreciate it.

We tested the WasapiCaptureDemo with 'CaptureDevices' with DeviceState.All it does display the Plankton Captured HDMI Audio (as before) but still no audio device shows up on the laptop.

We are unsure of what you mean by "...However, laptop HAS default microphone, and it can skip Plankton Captured HDMI Audio".

We looked closely at the VLC code and ran it with debugger to try an find out what it is sending to the Mimo HDMI capture device to cause it to create an audio playback device on the laptop. No such luck.

I need to restate - that we do not have this issues with other HDMI capture devices: Magewell, Innogeni or Logitech.

thanks again

dc-ucw commented 3 years ago

Hi Evgeny, we were away for the Christmas break. We responded to the note on Github NAudio about the Mimo capture device - still no luck.

If you could please take a look we would really appreciate it. We are happy to pay you for your time as well. Please let me know.


From: Evgeny Pereguda notifications@github.com Sent: Tuesday, December 22, 2020 7:15 PM To: naudio/NAudio NAudio@noreply.github.com Cc: Don Cameron Don@ucworkspace.com; Author author@noreply.github.com Subject: Re: [naudio/NAudio] Mimo HDMI Capture device not creating audio device laptop (#718)

You use in code " WaveIn" recording interface - IT IS VERY OLD (Win 95) audio recording interface, and it DEMANDS that audio capture devices output RAW WAVE stream. If Mimo Vue Capture outputs ONLY COMPRESSED audio stream (MP3, AAC, Dolby Surround) - then on interface " WaveIn" you have got NOTHING: there IS NOT any devices with output RAW WAVE stream.

Could you change NAudio.Wave.WaveIn on WASAPI ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/naudio/NAudio/issues/718#issuecomment-749903233, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIWPS6H7WH47NQFICRYYRLSWFOG3ANCNFSM4VGCZXPQ.

ghost commented 3 years ago

Hi, you wrote that you have very unique problem ("that we do not have this issues with other HDMI capture devices: Magewell, Innogeni or Logitech") with combination unique capture device and laptop ("It shows our device on the desktop, but does not cause an audio playback device to appear on laptop"). I had marked Plankton Captured HDMI Audio as USB Audio Class - looks like the target laptop cannot route USB Audio Class to WASAPI. It could be problem with drivers on the laptop, or problem with USB Hub of the laptop. So, I can spend couple days on you task - but I need a remote access to the target laptop the Visual Studio by TeamViewer. You can send access key by email.