Play audio from USB speaker

I want to use a USB speaker.
I succeeded in reproducing the audio from the USB speaker by invalidating the registry value according to the procedure here.

Dll="_libnvwavedev.dll"  ; (was "libnvwavedev.dll")

However, with that, it became impossible to play mp4 movies.
How can I play audio from a USB speaker while still playing mp4 movies?

Dear @kyas

Instead of disabling the libnvwavedev.dll, you can also make the USB speaker your default audio device with a small piece of code.
The device ID is defined by the load order. The internal wave driver is loaded first, making it audio device 0. The USB speaker is loaded later, as audio device 1.

void SwapDefaultAudioDevice()
    DWORD       numDevs;
    MMRESULT    res;
    DWORD       wParam  = 1; //OrigDeviceId
    DWORD       lParam  = 0; //NewDeviceId
    // Swap waveOut device 0 <-> 1
    res  = waveOutMessage(0, DRVM_MAPPER_PREFERRED_SET, wParam, lParam);

    // Query number of audio devices
    numDevs = waveOutGetNumDevs();
    // Get Info about device 0 (the default playback device)
    res = waveOutGetDevCaps(0, &woCaps, sizeof(woCaps)); 

After executing this code once, all system sounds are played on your USB speaker. Running it a second time makes the system sounds play on the analog audio device again.

However, the situation for playing MP3 audio and MP4 videos is more difficult. Our BSP contains Nvidia audio/video decoders which use hardware acceleration and play sounds not through the system audio mapper, but directly to the analog audio output.

There’s two optionsto get around this:

  1. Disable all hardware acceleration and use software codecs.
    This might be acceptable for low-resolution videos.
  2. In our old BSP, we had a special Nvidia audio router that could be used with the hardware-accelerated codecs. It had some drawbacks and did not work properly for all use cases. If you want to play all your sound exclusively through the USB speaker, it should work.

Please let me know some more details about the requirements of your final system, then I can get into more details.

Regards, Andy

Thank you for explaining in detail.
I understood that the sample code is the way to output only the system sound from the USB speaker.
The problem we want to solve is that the noise will be added to the analog output by the combination of Apalis T30 and Ixora so we want to be able to output all sounds such as system sound and movie sound from the USB speaker.

Detailed system requirements are as follows.

· Apalis T30 and Ixora

· LVDS output screen

· Screen resolution is 1366 x 768

· The resolution of the movie is 480p ~ 720p

· Movie shooting with USB camera (It is not directly related to this post · · ·)

We think that it is difficult in terms of performance to disable hardware acceleration and use software codecs.
By using “special Nvidia audio router” that you taught, will you be able to output all sounds from the USB speaker?
Will it also be available on the latest BSP?

Dear @kyas

I created a cab installer for an additional driver “audiorouter”. Just double-click it on your device to install it. The installer will:

  • copy the audiorouter_ce7.dll to the folder \Flashdisk\System\
  • Add the following registry settings
    "Dll"    = "audiorouter_ce7.dll"
    "Prefix" = "BTR"
    "Order"  = 20
    "IClass" ="{A32942B7-920C-486b-B0E6-92A702A99B35}"

    "OutputWaveDevice" = 1

This audiorouter copies all audio samples from the device “WAV1” and outputs them to the
device OutputWaveDevice.
By default, device#0 is the analog audio channel, device#1 is your USB speaker.

I tested it on my desk successfully.

Regards, Andy

Thank you very much for your prompt response.

I installed “audiorouter_ce7.dll” and confirmed that the sound of the MP4 movie is played from the USB speaker.

Please let me ask a few questions.

1: The system sound is still played on analog output as usual, but is it possible to play everything from a USB speaker?

2: The volume control of the sound of the MP4 movie does not seem to be possible with the WEC 7 volume setting, but will it become configurable?

Dear @kyas

  1. MP4 and system sounds should be both be played through USB.
    Please verify that you didn’t do any other registry setting. I did the following steps to assure this:

    • Start → Programs → Colibri Tools → UpdateTool → [Clear]
    • Reboot
    • Run the installer with default settings
    • Reboot
      Already the startup sound is played on the USB speaker.
  2. The volume control affects the default audio device only. You need to execute the SwapDefaultAudioDevice() function from my first answer. After this, the volume control will change the USB speaker volume.

Regards, Andy

Thank you for your response.

With the contents you taught, if you try again carefully, both the system sound and the sound of the MP4 movie will be played from the USB speaker.

You can now set the volume as well with the contents you taught without problems.

I am sorry to have trouble of confirmation.
Thank you very much!