音频系统的快速设计 验证与实现 徐正高 MathWorks 2016 The MathWorks, Inc. 1
MATLAB for Real-Time Audio key use cases For research and product development: Desktop prototyping Custom measurements For project-based learning: Audio for teaching DSP >> quick_preview 2
产品开发的原型 MATLAB 算法 早期验证 ( 听觉测试 ) 先进的原型 或产品 3
产品开发的原型 MATLAB 算法 早期验证 ( 听觉测试 ) 先进的原型 或产品 为什么? : 从算法开发者到其他相关人员 人在环路 听起来怎么样? 互动式的调整 如果我们改变了这个? 4
产品开发的原型 MATLAB 算法 早期验证 ( 听觉测试 ) 先进的原型 或产品 面临的挑战 算法 或者 DSP 工程师负责 C/C++ 相对困难, 并且费时 在 MATLAB 里调用外部的库有时不能正常工作 学习 Plugin API 具有挑战性 代码不能在产品里重复使用 浪费 5
Agenda Prototype with real-time audio streaming and live-tuning in MATLAB Run custom algorithm on DAWs with VST plugin generation 6
Audio System Toolbox 设计和测试音频处理系统 音频处理算法库和示例 到标准音频接口的低延时音频流, ( 如 :ASIO, CoreAudio, ALSA) 通过 UI 和 MIDI 设备在 MATLAB 和 Simulink 里实时调参 产生 VST 插件, 可以在 DAW 里运行 7
Time for a bit of MATLAB How does it work? How hard is it to achieve? 8
Audio System Toolbox 产品生态圈 需要产品 MATLAB Signal Processing Toolbox DSP System Toolbox Audio System Toolbox DSP System Toolbox Signal Processing Toolbox MATLAB Simulink 支持产品 MATLAB Simulink C/C++ Code Generation 9
生成 VST 插件和源代码 MATLAB 代码 Audio System Toolbox C/C++ MATLAB Coder Simulink Coder Simulink Real Time PC 平台应用程序 自定义插件 自定义原型基础构架 Speedgoat 音频 real-time target 嵌入式原型 VST 插件 设计 & 验证 原型 & 代码输出 10
11
主要内容 嵌入式系统 浮点模型转化为定点模型的工作流程 自动收集数据并建议数据类型 推导数据类型 将定点模型自动转换为嵌入式 C 代码 代码生成与优化 调试 验证 Polyspace 硬件连接 国内典型用户案例分析 - TI DSP 系统的实现 12
基于模型的设计 MATLAB / Simulink 系统和算法设计 Fixed-Point Designer MATLAB coder / Simulink Coder Embedded Coder 代码产生 证验 算法测试与验证 C / C++ MCU TI DSP 13
快速原型的意义 14
Processor TI TMS320C6748 DSP 456-MHz C674x Fixed/Floating Point DSP Memory 128 MByte DDR2 SDRAM running at 150MHz 128 MByte 16-bit wide NAND FLASH Interfaces One mini-usb Serial Port (on-board serial to USB) One Fast Ethernet Port (10/100 Mbps) with status LEDs One VGA Port (15 pin D-SUB) One Composite Video Input (RCA Jack) Three AUDIO Ports (1 LINE IN & 1 LINE OUT & 1 MIC IN) 14-pin JTAG header (No onboard emulator; external emulator is required) 15
自动代码产生 C 语言 : DSP 标准 C 语言 (ANSI C / ISO C) MATLAB coder Simulink coder 优化的目标代码 Embedded coder 16
MATLAB Coder \ Simulink Coder 自动产生 C 代码 从视频和图像处理模型产生 ANSI-C 代码 建立算法和系统的快速原型 在目标硬件上进行测试和验证 方便移植到不同的目标处理器 17
Embedded coder 产生产品级代码 专用处理器, 优化代码 Simulink 模块和优化库 (FIR, FFT, ) 工程自动化 自动产生整个工程 CCS 编译器 连接器的 API 函数 快速原型 特定目标和集成环境 Simulink 硬件模块, 支持设备驱动 (ADC, DAC, RTDX, 子卡 ) 支持 开发板 : TI 6713 DSK, C6416DSK, DM642 EVM,C6455EVM, DM6437EVM, DM648EVM, C6747EVM, DSPs: TI DM64x, C64x, C62x, and C67x families 18
基于模型的设计应用于 TI DSPs 及产品 Model and Simulate in Floating- and Fixed-Point Generate embeddable C-code from Simulink and / or Embedded MATLAB Rapidly Prototype and Implement on TI processors and boards MATLAB Simulink Stateflow Link for use with Code Composer Studio Embedded Coder Targets on TI C6000 (DM6437), C2000 Texas Instruments Code Composer Studio Environment C/ASM Code Compile & Link Debug Down load TI DSP 19
产生代码实例 Rapid Prototype Code (grt.tlc) Production code (ert.tlc) 20
自动代码可靠性 效率 Our team at Honeywell Flight Controls has generated 1.6 million lines of code automatically using MathWorks products for the Joint Strike Fighter. We manually verified 1.2 million lines of code so far. We found 1 line of code that we are not sure where it came from or what it s purpose is. Everything works fine, though. These days everyone is talking about doing 6-sigma design. One questionable line of code out of 1.2 million lines of code that s better than 6.5 sigma. And we are not talking about it we actually did it. 21
产品级代码 22
项目案例 : 从 MATLAB 算法到 DSP 产品化 基于模型的设计,MBD Coaching; 1. MATLAB 算法 2. Simulink 模型仿真基于帧的转换定点化 3. 自动代码产生快速原型面向特定芯片的优化自定义模块 4. 验证仿真验证实验室验证外场验证 23
ABS 项目系统构架图 上位机 : 控制字 核心专利算法 : 编码, 调制 RS232 音频输出发射机 核心专利算法 : 滤波, 解调, 译码 接收电路音频输出 RS232 下位机 : 控制字 24
自定义模块 : 示例 25
自定义模块 : 模块库 26
自定义模块 : 修改 TLC 27
自定义模块 : 验证模型 28
自定义模块 : 生成代码 29
正确性和性能 : The following code calculates the same FFT in the workspace. The output from this calculation, y2, is displayed side-by-side with the output from the model, c. The outputs match, showing that the Bit Reverse block reorders the Radix-2 FFT output to natural order: k = 4; n = 2^k; xr = zeros(n, 1); xr(2) = 0.5; xi = zeros(n, 1); x2 = complex(xr, xi); y2 = fft(x2); 30
正确性 : [y2, c] 0.5000 0.5000 0.4619-0.1913i 0.4619-0.1913i 0.3536-0.3536i 0.3535-0.3535i 0.1913-0.4619i 0.1913-0.4619i 0-0.5000i 0-0.5000i -0.1913-0.4619i -0.1913-0.4619i -0.3536-0.3536i -0.3535-0.3535i -0.4619-0.1913i -0.4619-0.1913i -0.5000-0.5000-0.4619 + 0.1913i -0.4619 + 0.1913i -0.3536 + 0.3536i -0.3535 + 0.3535i -0.1913 + 0.4619i -0.1913 + 0.4619i 0 + 0.5000i 0 + 0.5000i 0.1913 + 0.4619i 0.1913 + 0.4619i 0.3536 + 0.3536i 0.3535 + 0.3535i 0.4619 + 0.1913i 0.4619 + 0.1913i 31
正确性和性能 : 代码 32
实时性 : 33
发射端 : 34
接收端 1: 35
用户案例 : Doheny Eye Institute Develops Next-Generation of Retinal Prosthesis with MathWorks Tools Challenge Develop next-generation, higher-resolution retinal prostheses Solution Use MathWorks tools to develop, simulate, and automatically generate code for real-time image processing algorithms Results Development time reduced from months to weeks DSP deployment streamlined Patient testing improved Illustration of a retinal prosthesis prototype. With Computer Vision System Toolbox and Embedded Coder, we rapidly prototype our image and video processing algorithms on the DM642 board. This can save me days or weeks of time. Neha Parikh Doheny Eye Institute Link to user story 36
Demo Booth:DSP model 37
Workflow of Code generation 38
Demo Booth:Control FM Frequency 39
Radio on MBD 40
谢谢! 41
Summary Real-Time Audio in MATLAB Desktop prototyping and listening tests Pain: Traditional prototyping is costly and time-consuming Solution: Audio streaming in MATLAB and VST plugin generation Custom real-time measurements Pain: Audio test & measurement equipment can be expensive and inflexible Solution: Audio acquisition and unlimited custom analysis Real-time audio for teaching DSP Pain: C/C++ and hardware kits take away time from putting signal processing into practice Solution: Real-time audio without C/C++ or embedded kits 42