2023-09-20 04:32:58 +08:00
|
|
|
##ALSA Plugin
|
|
|
|
|
|
|
|
The SOF ALSA plugin allows SOF topologies to be run on the host. The plugin
|
|
|
|
is still WIP with many rough edges that need refined before production
|
|
|
|
deployment, however the plugin is usable today as a rapid development
|
|
|
|
framework for SOF infrastructure and processing.
|
|
|
|
|
|
|
|
#Features
|
|
|
|
* aplay & arecord usage working today
|
|
|
|
* alsamixer & amixer usage not working today
|
|
|
|
* modules are loaded as SO shared libraries.
|
|
|
|
* topology is parsed by the plugin and pipelines associated with the requested PCM ID are loaded
|
|
|
|
* pipelines run as individual userspace threads
|
|
|
|
* pipelines can be pinned to efficency cores
|
|
|
|
* pipelines can use realtime priority.
|
|
|
|
* alsa sink and alsa source modules available.
|
|
|
|
* pipelines can block (non blocking and mmap todo)
|
|
|
|
|
|
|
|
#License
|
|
|
|
Code is a mixture of LGPL and BSD 3c.
|
|
|
|
|
|
|
|
#Usage
|
|
|
|
Please build as cmake project, for IPC4 (functional)
|
|
|
|
IPC3 is not functional and not supported
|
|
|
|
|
|
|
|
```
|
|
|
|
cd sof
|
2023-12-01 04:56:56 +08:00
|
|
|
cmake -GNinja -B build-plugin/ -S tools/plugin/
|
|
|
|
# Build external projects first to avoid build race condition
|
|
|
|
# Dropping -GNinja is another (very slow) option.
|
|
|
|
cmake --build build-plugin/ -- sof_ep parser_ep
|
|
|
|
cmake --build build-plugin/
|
2023-09-20 04:32:58 +08:00
|
|
|
```
|
|
|
|
then (use default ALSA prefix atm)
|
|
|
|
|
|
|
|
```
|
2024-02-09 08:48:41 +08:00
|
|
|
sudo cmake --install build-plugin/
|
2023-09-20 04:32:58 +08:00
|
|
|
|
|
|
|
Make sure to set the LD_LIBRARY_PATH to include directory where the SOF modules are installed
|
|
|
|
Ex: "~/work/sof/sof/build_plugin/sof_ep/install/lib:~/work/sof/sof/build_plugin/modules/"
|
|
|
|
And set the environment variable SOF_PLUGIN_TOPOLOGY_PATH to point to the directory containing the topology binary
|
|
|
|
```
|
|
|
|
|
2024-01-30 02:37:36 +08:00
|
|
|
Code can then be run by starting sof-pipe with your desired topology (Ex: sof-plugin.tplg)
|
2023-09-20 04:32:58 +08:00
|
|
|
|
|
|
|
```
|
2024-01-30 02:37:36 +08:00
|
|
|
./sof-pipe -T sof-plugin.tplg
|
2023-09-20 04:32:58 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
At this point the sof-pipe daemon is waiting for IPC. Audio applications can now invoke sof-pipe processing via
|
|
|
|
|
|
|
|
```
|
2024-01-30 02:37:36 +08:00
|
|
|
aplay -Dsof:plugin:1:default:default:48k2c16b -f dat some48kHz.wav
|
2023-09-20 04:32:58 +08:00
|
|
|
```
|
|
|
|
The command line is parsed as follows:
|
|
|
|
- "sof" is the plugin name
|
|
|
|
- "tgl-nocodec" is the topology name. The "sof-" prefix and ".tplg" suffix will be appended by the plugin
|
|
|
|
- "1" is the PCM ID for render/capture
|
|
|
|
- "default": The first default is the card name
|
|
|
|
- "default": The second default is the device name
|
|
|
|
- "48k2c16b" is the config name for 48K, stereo, 16bit
|
|
|
|
|
|
|
|
This renders audio to the sof-pipe daemon using the tgl-nocodec topology playback PCM ID 1.
|
|
|
|
The above example needs to be 48k as example pipe has no SRC/ASRC.
|
|
|
|
|
|
|
|
Likewise
|
|
|
|
|
|
|
|
```
|
2024-01-30 02:37:36 +08:00
|
|
|
arecord -Dsof:plugin:1:default:default:48k2c16b -f dat file.wav
|
2023-09-20 04:32:58 +08:00
|
|
|
```
|
2024-01-30 02:37:36 +08:00
|
|
|
Will record audio using the plugin topology and PCM ID 1.
|
2023-09-20 04:32:58 +08:00
|
|
|
|
|
|
|
Mixer settings can be adjusted for bdw-nocodec by (Not functional yet)
|
|
|
|
|
|
|
|
```
|
|
|
|
alsamixer -Dsof:tgl-nocodec:1
|
|
|
|
```
|
|
|
|
|
2024-02-09 08:48:41 +08:00
|
|
|
# Instructions for testing OpenVino noise suppression model with the SOF plugin:
|
|
|
|
1. Fetch the model from the Open Model zoo repository ex: noise-suppression-poconetlike-0001.xml
|
|
|
|
|
|
|
|
https://docs.openvino.ai/archive/2023.0/omz_demos.html#build-the-demo-applications-on-linux
|
|
|
|
|
|
|
|
2. Source OpenVino environment and get OpenCV
|
|
|
|
https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit-download.html
|
|
|
|
|
|
|
|
3. Worth building and running the demo noise suppression application in the open model zoo
|
|
|
|
repository to make sure OpenVino and OpenCV are configured properly.
|
|
|
|
|
|
|
|
4. Set environment variable NOISE_SUPPRESSION_MODEL_NAME to point to the model file
|
|
|
|
```
|
|
|
|
export NOISE_SUPPRESSION_MODEL_NAME="~/open_model_zoo/demos/noise_suppression_demo/cpp/intel/noise-suppression-poconetlike-0001/FP16/noise-suppression-poconetlike-0001.xml"
|
|
|
|
|
|
|
|
```
|
|
|
|
5. Enable noise suppression by setting NOISE_SUPPRESSION=true in the tplg-targets for the sof-plugin topology
|
|
|
|
|
|
|
|
6. Start capture using the following command. This uses the 16K capture from the DMIC from
|
|
|
|
PCM hw device 0,7. Currently, only 16K capture is supported but in the future this will be expanded
|
|
|
|
to work with 48K capture.
|
|
|
|
```
|
|
|
|
arecord -Dsof:plugin:1:0:7:16k2c16b -f dat -r 16000 --period-size=2048 file_ns_16k.wa
|
|
|
|
```
|
|
|
|
|
2023-09-20 04:32:58 +08:00
|
|
|
#TODO Items (and T-shirt size) for single pipeline E2E audio
|
|
|
|
* IPC4 support in tplg parser (M)
|
|
|
|
* IPC4 support in plugin (pipe/ipc4.c) (M)
|
|
|
|
* Fix ALSA -Dhw: device support (S), currently only default ALSA device works
|
|
|
|
* Deprecate POSIX message queues for IPC and use UNIX sockets.(S)
|
|
|
|
* Make better build system for modules i.e. remove hack-install.sh (S)
|
|
|
|
* Need a simpler aplay/arecord cmd line.
|