Main Content

使用UDP在DAW和MATLAB之间进行通信

此示例显示了如何使用用户数据报协议(UDP)在数字音频工作站(DAW)和MATLAB®之间进行通信。DAW和MATLAB之间共享的信息可用于在MATLAB中实时执行有关正在更改DAW的参数的信息。

用户数据报协议(UDP)

UDP是一种互联网协议的核心成员e. It is a simple connectionless transmission that does not employ any methods for error checking. Because it does not check for errors, UDP is a fast but unreliable alternative to the transmission control protocol (TCP) and stream control transmission protocol (SCTP). UDP is widely used in applications that are willing to trade fidelity for high-speed transmission, such as video conferencing and real-time computer games. If you use UDP for communication within a single machine, packets are less likely to drop. The tutorials outlined here work best when executed on a single machine.

UDP和MATLAB

这se System objects enable you to use UDP with MATLAB:

To communicate between a DAW and MATLAB using UDP, place a UDP sender in the plugin used in the DAW, and run a corresponding UDP receiver in MATLAB.

dsp.udpsenderandDSP.UDPRECEIVERSystem objects use prebuilt library files that are included with MATLAB.

Example Plugins

这se Audio Toolbox™ example plugins use UDP:

  • Audiopluginexample.udpsender- Send an audio signal from a DAW to the network. If you generate this plugin and deploy it to a DAW, the plugin sends frames of a stereo signal to the network. The frame size is determined by the DAW. You can modify the example plugin to send any information you want to analyze in MATLAB.

  • AudioplugineXample.ParametricequalizerWithUDP- 将插件的过滤器系数从DAW发送到网络。如果您生成此插件并将其运行DAW,则该插件将发送您在DAW中调整到网络的参数均衡器的系数。这辅助板球群体函数包含一个接收数据报的UDP接收器,并使用它来绘制您在DAW中调整过滤器的幅度响应。

将音频从DAW发送到Matlab

步骤1:生成VST插件

从中生成VST插件Audiopluginexample.udpsender, 使用generateAudioPluginfunction. It is a best practice to move to a directory that can store the generated plugin before executing this command:

generateAudioPluginAudiopluginexample.udpsender
........

生成的插件保存到您当前的文件夹并命名udpsender

步骤2:开放DAW,使用适当的环境变量集

要运行MATLAB外的UDP发件人,您必须从设置适当的环境变量的命令终端打开DAW。设置环境变量使已部署的UDP发件人在MATLAB中使用必要的库文件。要了解如何设置环境变量,请参见系统的特定教程:

设置环境变量后,从同一命令终端打开DAW,例如在Windows系统的示例终端中。

步骤3:接收和处理音频信号

一个。在DAW中,打开生成的udpsender文件。

b。在MATLAB中,运行此功能:辅助pppluginreceiver

音频信号显示在DSP.Spectrumanalyzer用于分析。

将系数从DAW发送到MATLAB

1. Follow steps 1-2 from将音频从DAW发送到Matlab,更换Audiopluginexample.udpsenderAudioplugineXample.ParametricequalizerWithUDP

2.接收和处理过滤系数

一个。在DAW中,打开生成的parameterequalizerwithudp文件。插件显示名称是parametriceq

b。在MATLAB中,运行此命令:辅助板球群体

辅助板球群体功能使用DSP.UDPRECEIVER要接收滤波器系数,然后显示幅度响应60秒。您可以修改代码以延长或减少时间。绘制的幅度响应对应于您在DAW中调整的参数均衡器插件。