Micrium provides a demo application that lets you test and evaluate the class implementation. Source template files are provided.
Note that the demo application provided by Micriµm is only an example and is intended to be used as a starting point to develop your own application. |
The audio class provides two demos:
The demo application files offering the two audio demos are provided for µC/OS-II and µC/OS-III and should be considered as example that you can modify. The files composing the demo application are:
File | Description | Location |
---|---|---|
app_cfg.h | Contains a few constants to configure its internal tasks. | Not provided in package. |
app_usbd_cfg.h | Contains constants related to audio class demos. | \Micrium\Software\uC-USB-Device-V4\App\Device\ |
app_usbd_audio.c | Allows to initialize audio class. Refer to section Audio Class Instance Configuration for more details. | \Micrium\Software\uC-USB-Device-V4\App\Device\ |
usbd_audio_drv_simulation.c usbd_audio_drv_simulation.h
| Simulates a microphone and a headset used as a loopback. | \Micrium\Software\uC-USB-Device-V4\App\Device\ |
usbd_audio_drv_simulation_data.c | Defines audio data waveforms samples used by the microphone demo. | \Micrium\Software\uC-USB-Device-V4\App\Device\ |
The use of these constants usually defined in app_cfg.h
or app_usbd_cfg.h
allow you to use one of the audio demos.
|
It is possible to enable the stream correction for the microphone and loopback demos, that is constants |
For demos explanation purpose, we will consider the operating system Microsoft Windows 7 or later.
The microphone demo requires the following components on the host PC side:
The microphone demo is built using an audio function topology defined in the file usbd_audio_dev_cfg.c
and composed of:
Refer to Figure - usbd_audio_dev_cfg.c - Typical Topologies Example for a visual representation of this audio function.
Figure - Microphone Demo shows the principle of the microphone demo.
(1) The Windows audio driver opens the record stream by selecting the first operational AudioStreaming interface. This step is done automatically when the audio device is connected to the PC. (2) The microphone task detects that the stream is open and starts sending pre-defined record data to the host. The record data corresponds to the waveform selected with the constant (3) The Windows audio driver closes the stream by selecting the default AudioStreaming interface. This action is done only if you decide to disable the microphone from the Sound Manager. |
Upon connection of your audio device, the simulated microphone device should appear in the recording devices list of the Sound Manager as shown in Figure - Sound Manager - Microphone in Recording Devices List. In this example, the recording device is identified as "Micrium Audio Product" (ProductStrPtr
field of USBD_DEV_CFG
set to this string).
In order to listen to the waveform signal, you need to ensure that:
The loopback demo requires the following components on the host PC side:
The loopback demo is built using an audio function topology defined in the file usbd_audio_dev_cfg.c
and composed of:
Refer to Figure - usbd_audio_dev_cfg.c - Typical Topologies Example for a visual representation of this audio function.
Figure - Loopback Demo shows the principle of the loopback demo which can be seen as a simulated headset.
(1) The Windows audio driver opens the record and playback streams by selecting the first operational interface of each AudioStreaming (AS) interface. This step is done automatically for the microphone AS interface when the audio device is connected to the PC. For the speaker AS, you will have to ensure that it is enabled in the Sound Manager (cf. below). (2) Both streams must be open in order to start the streams communication. The loopback task will basically perform two sequential operations seamlessly: processing playback stream and processing record stream. The loopback task detects that the playback stream is open and retrieves one of the isochronous OUT data buffers stored in the audio class. The playback buffer is stored in a circular buffer. Playback data comes from a music player playing songs. I f the host sends some requests to change the volume or to mute/unmute the playback stream, the loopback task will apply the volume or mute change on the playback data accordingly. (3) The loopback task continues its execution by processing the record stream. If the record stream is open, it obtains a playback buffer from the circular buffer. This one becomes a record buffer. The loopback task passes the record buffer to the audio class which will take care of submitting record data via isochronous IN transfers . The host will forward record data to a headphone for instance. You should hear the song from the music player (if some settings explained below for the microphone are correct). If the host sends some requests to change the volume or to mute/unmute the record stream, the loopback task will apply the volume or mute change on the record data accordingly. (4) The Windows audio driver closes streams by selecting the default AudioStreaming interface for the microphone and speaker. This action is done only if you decide to disable the microphone and speaker from the Sound Manager. |
Upon connection of your audio device, the simulated headset device should appear in two lists. The microphone should be listed in the recording devices list of the Sound Manager as shown in Figure - Sound Manager - Microphone in Recording Devices List, whereas the speaker part should be listed in the playback devices list as shown in Figure - Sound Manager - Speaker in Playback Devices List. In this example, the playback and recording device are identified as "Micrium Audio Product" (ProductStrPtr
field of USBD_DEV_CFG
set to this string).
In order to listen to the song played by the music player, you need to ensure that: