Signal Estimator
================
[](https://github.com/gavv/signal-estimator/actions)
<!-- toc -->
- [Features](#features)
- [Example use cases](#example-use-cases)
- [Supported platforms](#supported-platforms)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Graphical interface](#graphical-interface)
- [Command-line options](#command-line-options)
- [Measuring latency](#measuring-latency)
- [Measuring losses](#measuring-losses)
- [JSON output](#json-output)
- [Dumping streams](#dumping-streams)
- [ALSA parameters](#alsa-parameters)
- [Real-time scheduling policy](#real-time-scheduling-policy)
- [Acknowledgments](#acknowledgments)
- [Authors](#authors)
- [License](#license)
<!-- tocstop -->
Features
--------
`signal-estimator` is a small command-line and GUI tool allowing to measure different characteristics of the signal looped back from audio output to audio input.
Features:
* send test signal to output device and receive looped back signal from input device
* measure signal latency (the shift between output and input signal)
* measure signal loss ratio (number of glitches per second in the input signal)
* measurements output in JSON format for easy parsing
* dump output and input streams to text files and plot them using matplotlib
Example use cases
-----------------
* Measure local hardware latency.
*Example setups:*
* connect computer's audio output to its audio input using a jack cable
* place computer's speakers near the its microphone
* Measure total latency and signal quality of an external hardware + software system.
*Example setups:*
* measure Raspberry Pi hardware + software latency
connect computer's audio output to a Raspberry Pi's input and vice versa, and run a program on Raspberry Pi that loops back signal from input to output
* measure hardware + software + network latency / quality of the two Raspberry Pies connected via a network transport
connect computer's audio output to the first Raspberry Pi's input, and computer's audio input to the second Raspberry Pi's output, and connect the two Raspberry Pies using some network audio transport
* measure the hardware + software + bluetooth latency / quality of a mobile phone with bluetooth microphone and headphones
place computer's speakers near bluetooth microphone connected to a mobile phone, place computer's microphone near bluetooth headphones connected to the phone, and run a mobile app that loops back signal from bluetooth microphone to bluetooth headphones
In these examples, you'll need to measure the latency of your local harware first, and then subtract it from the measurements results, to get the actual latency of the external system being tested.
Supported platforms
-------------------
* Linux / ALSA
Dependencies
------------
* C++17 compiler
* CMake >= 3.0
* libasound (ALSA devel)
* Qt5 and Qwt (for GUI)
Installation
------------
Install dependencies:
```
sudo apt install libasound2-dev qtbase5-dev libqwt-qt5-dev
```
Clone repo:
```
git clone --recurse-submodules https://github.com/gavv/signal-estimator.git
cd signal-estimator
```
Build:
```
make
```
Build without GUI (in this case Qt and Qwt are not needed):
```
make no_gui
```
Install into the system (optionally):
```
sudo make install
```
Graphical interface
-------------------
The tool comes with a simple GUI (`signal-estimator-gui`) that plots the signal in the real-time. It can be especially useful for troubleshooting problems with measurements.
It uses Qt and Qwt libraries. Internally, it invokes the command-line tool (`signal-estimator`) and parses its output.
Here is how it looks like:
<img src="https://github.com/gavv/signal-estimator/blob/main/doc/screenshot.png" width="600" />
Command-line options
--------------------
```
$ ./bin/signal-estimator --help
Measure characteristics of a looped back signal
Usage:
signal-estimator [OPTION...]
General options:
-h, --help Print help message and exit
-f, --format arg Output Format: json|text (default: text)
-m, --mode arg Mode: noop|latency|losses (default: latency)
-o, --output arg Output device name, required
-i, --input arg Input device name, required
-r, --rate arg Sample rate (default: 48000)
-c, --chans arg Number of channels (default: 2)
-v, --volume arg Signal volume, from 0 to 1 (default: 0.500000)
-p, --periods arg Number of periods in ring buffer (default: 2)
-l, --latency arg Ring buffer size, microseconds (default: 8000)
-d, --duration arg Measurement duration, seconds (default: 10.000000)
Reporting options:
--sma arg Simple moving average window in reports (default: 5)
Latency estimation options:
--strike-period arg Strike period, seconds (default: 1.000000)
--strike-length arg Strike length, seconds (default: 0.100000)
--strike-detection-window arg
Strike detection running maximum window, in
samples (default: 96)
--strike-detection-threshold arg
Strike detection threshold, from 0 to 1
(default: 0.400000)
Loss ratio estimation options:
--signal-detection-window arg
Signal detection running maximum window, in
samples (default: 48)
--signal-detection-threshold arg
Signal detection threshold, from 0 to 1
(default: 0.150000)
--glitch-detection-window arg
Glitch detection running maximum window, in
samples (default: 32)
--glitch-detection-threshold arg
Glitch detection threshold, from 0 to 1
(default: 0.050000)
File dumping options:
--dump-output arg File to dump output stream
--dump-input arg File to dump input stream
--dump-frame arg Dump only one maximum value per frame (default:
64)
--dump-rounding arg Round values before dumping and don't dump
duplicates (default: 10)
```
Measuring latency
-----------------
In the latency estimation mode, the tool generates short periodic beeps ("strikes") and calculates the shift between each sent and received strike.
```
$ ./bin/signal-estimator -m latency -o hw:1,0 -i hw:1,0 -d 5
opening alsa writer for device hw:1,0
suggested_latency: 8000 us
suggested_buffer_size: 384 samples
selected_buffer_time: 8000 us
selected_buffer_size: 384 samples
selected_period_time: 4000 us
selected_period_size: 192 samples
opening alsa reader for device hw:1,0
suggested_latency: 8000 us
suggested_buffer_size: 384 samples
selected_buffer_time: 8000 us
selected_buffer_size: 384 samples
selected_period_time: 4000 us
selected_period_size: 192 samples
can't enable real-time scheduling policy
can't enable real-time scheduling policy
latency: sw+hw 13.145ms hw 2.934ms hw_avg5 2.934ms
latency: sw+hw 12.465ms hw 2.924ms hw_avg5 2.929ms
latency: sw+hw 13.171ms hw 2.968ms hw_avg5 2.942ms
latency: sw+hw 12.510ms hw 2.962ms hw_avg5 2.947ms
latency: sw+hw 12.536ms hw 3.008ms hw_avg5 2.959ms
```
Notation:
* `sw+hw` - total software + hardware latency, including ALSA ring buffer
computed as the time interval beginning when the first audio *frame* of the strike was sent to the output ring buffer, and ending when the first frame of the strike was received from the input ring buffer
* `hw` - an estimation of hardware latency, excluding ALSA ring buffer
computed as the time interval beginning when the first audio *sample* of the strike was sent from ring buffer to DAC, and ending when the first sample of the strike was received from ADC and plac
没有合适的资源?快使用搜索试试~ 我知道了~
测量环回信号的特性_C++_代码_相关文件_下载

共75个文件
hpp:30个
cpp:26个
png:3个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
12 浏览量
2022-07-12
01:01:10
上传
评论
收藏 168KB ZIP 举报
特征 signal-estimator是一个小型命令行和 GUI 工具,允许测量从音频输出环回到音频输入的信号的不同特性。 特征: 将测试信号发送到输出设备并从输入设备接收环回信号 测量信号延迟(输出和输入信号之间的偏移) 测量信号丢失率(输入信号中每秒的毛刺数) JSON格式的测量输出,便于解析 将输出和输入流转储到文本文件并使用 matplotlib 绘制它们 示例用例 测量本地硬件延迟。 示例设置: 使用插孔电缆将计算机的音频输出连接到其音频输入 将计算机的扬声器放在麦克风附近 测量外部硬件 + 软件系统的总延迟和信号质量。 示例设置: 测量 Raspberry Pi 硬件 + 软件延迟 将计算机的音频输出连接到 Raspberry Pi 的输入,反之亦然,然后在 Raspberry Pi 上运行一个程序,将信号从输入环回输出到输出 测量通过网络传输连接的两个树莓派的硬件 + 软件 + 网络延迟/质量 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论


















收起资源包目录























































































共 75 条
- 1
资源评论


快撑死的鱼
- 粉丝: 686
- 资源: 3979

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
