ADSP-21479的开发详解五(AD1939 C Block-Based Talkthru 48 or 96 kHz)音频直通

news2024/9/20 2:45:43

硬件准备

ADSP-21479EVB开发板:

产品链接:https://item.taobao.com/item.htm?id=555500952801&spm=a1z10.5-c.w4002-5192690539.11.151441a3Z16RLU

在这里插入图片描述

AD-HP530ICE仿真器:

产品链接:https://item.taobao.com/item.htm?id=38007242820&spm=a1z10.5-c.w4002-5192690539.11.59ae4901jeWaOn

软件准备

Visual DSP++5.1.2
CCES2.11.1

音频开发: 21479 AD1939 C Block-Based Talkthru 48 or 96 kHz(4 进 8 出)

这个程序,我们将会在开发板上实现 48Khz 或 96Khz 采样率的音频直通程序。原理上来 讲,手机或者 PC 的音源通过 1 分 2 音频线接入 21479 开发板的模拟输入接插件,将模拟音 频导入,通过 AD1938 进行模拟转数字,数字音频信号进入 21479 数字音频 DSP 中,不做任何处理,交给 AD1938 再进行数字转模拟,将模拟的音频信号送到对应的通道,实现多 通道输出。

硬件连接如下图:

在这里插入图片描述

在这里插入图片描述

为什么输入接 2/3 通道,输出接 2/3 通道(通道号在板子的背面的丝印),这是因为 程序就是这么写的的,我们来看看程序是怎么写的: 把工程拖入 VDSP 中,编译,运行,手机播放音源,输出到音响听到音乐,完成这个例程。

在这里插入图片描述

看看这个程序的 Readme,代码实现了 ADC 从 2/3 进,DAC 从 0/1 和 2/3 出。ADC 从 0/1 进,DAC 从 4/5 和 6/7 出。用户可以换一下输入输出接口,听一下效果。至于板子上哪个接 口是 0/1,哪个是 2/3?请看下图,红色的接插件是输入,2 个黑色的接插件是输出:

在这里插入图片描述

这个工程里,音频处理都在 DSP Audio Processing Routines 里,想要了解如何实现这种 直通,可以看里面的程序去理解。 程序里都有备注,比较容易看得懂,这里说的就是 4 进 8 出,1 左右声道进对应 12 左 右声道出,2 左右声道进对应 34 左右声道出。而 1 左右声道 IN 就是板子上的 0/1 IN,2 左右声道 IN 就是板子上的 2/3 IN。

核心代码分析

DSP

///
// //
// NAME: blockProcess_audio.c (Block-based Talkthrough) //
// DATE: 02/06/10 //
// PURPOSE: Process incoming AD1939 ADC data and prepare outgoing blocks for DAC. //
// //
// USAGE: This file contains the subroutines that float and fix the serial data, //
// and copy from the inputs to the outputs. //
// //
///

#include “ADDS_21479_EzKit.h”

// Define a structure to represent buffers for all 12 floating-point data channels of the AD1939
typedef struct{
float Rx_L1[NUM_SAMPLES];
float Rx_R1[NUM_SAMPLES];
float Rx_L2[NUM_SAMPLES];
float Rx_R2[NUM_SAMPLES];

float Tx_L1[NUM_SAMPLES];
float Tx_R1[NUM_SAMPLES];
float Tx_L2[NUM_SAMPLES];
float Tx_R2[NUM_SAMPLES];
float Tx_L3[NUM_SAMPLES];
float Tx_R3[NUM_SAMPLES];
float Tx_L4[NUM_SAMPLES];
float Tx_R4[NUM_SAMPLES];

} ad1939_float_data;

// SPORT Ping/Pong Data buffers
extern int TxBlock_A0[];
extern int TxBlock_A1[];

extern int RxBlock_A0[];
extern int RxBlock_A1[];

//Pointer to the blocks
int *rx_block_pointer[2] = {RxBlock_A0, RxBlock_A1};
int *tx_block_pointer[2] = {TxBlock_A0, TxBlock_A1};

// Structures to hold floating point data for each AD1939
ad1939_float_data fBlockA;

void process_audioBlocks(void);

// Unoptimized function to convert the incoming fixed-point data to 32-bit floating-point format.
// This function assumes that the incoming fixed point data is in 1.31 format
void floatData(float *output, int *input, unsigned int instep, unsigned int length)
{
int i;

for(i = 0; i < length; i++)
{
    output[i] = __builtin_conv_RtoF(input[instep*i]);
}

}

// Unoptimized function to convert the outgoing floating-point data to 1.31 fixed-point format.
void fixData(int *output, float *input, unsigned int outstep, unsigned int length)
{
int i;

for(i = 0; i < length; i++)
{
    output[outstep*i] = __builtin_conv_FtoR(input[i]);
}

}

// Unoptimized function to copy from one floating-point buffer to another
void memcopy(float *input, float *output, unsigned int number)
{
int i;

for(i = 0; i < number; i++)
{
    output[i] = input[i];
}

}

/
// Audio Block Processing Algorithm for 4 IN x 8 OUT Audio System

// The inputs and outputs are held in a structure for the AD1939
// fBlockA holds stereo input (AIN) channels 0-3 and stereo output (AOUT) channels 0-7

// This function copys the data without any processing as follows
// AOUT1L <- AIN1L
// AOUT1R <- AIN1R
// AOUT2L <- AIN1L
// AOUT2R <- AIN1R

// AOUT3L <- AIN2L
// AOUT3R <- AIN2R
// AOUT4L <- AIN2L
// AOUT4R <- AIN2R
/

void process_audioBlocks()
{
memcopy(fBlockA.Rx_L1, fBlockA.Tx_L1, NUM_SAMPLES);
memcopy(fBlockA.Rx_R1, fBlockA.Tx_R1, NUM_SAMPLES);
memcopy(fBlockA.Rx_L1, fBlockA.Tx_L2, NUM_SAMPLES);
memcopy(fBlockA.Rx_R1, fBlockA.Tx_R2, NUM_SAMPLES);
memcopy(fBlockA.Rx_L2, fBlockA.Tx_R3, NUM_SAMPLES);
memcopy(fBlockA.Rx_R2, fBlockA.Tx_L3, NUM_SAMPLES);
memcopy(fBlockA.Rx_L2, fBlockA.Tx_L4, NUM_SAMPLES);
memcopy(fBlockA.Rx_R2, fBlockA.Tx_R4, NUM_SAMPLES);
}

/
// This function handles the Codec data in the following 3 steps…
// 1. Converts all ADC data to 32-bit floating-point, and copies this
// from the current RX DMA buffer into fBlockA & fBlockB
// 2. Calls the audio processing function (processBlocks)
// 3. Converts all DAC to 1.31 fixed point, and copies this from
// fBlockA & fBlockB into the current TX DMA buffer
/

void handleCodecData(unsigned int blockIndex)
{
//Clear the Block Ready Semaphore
inputReady = 0;

//Set the Processing Active Semaphore before starting processing
isProcessing = 1;

// Float ADC data from AD1939
floatData(fBlockA.Rx_L1, rx_block_pointer[blockIndex]+0, NUM_RX_SLOTS, NUM_SAMPLES);
floatData(fBlockA.Rx_R1, rx_block_pointer[blockIndex]+1, NUM_RX_SLOTS, NUM_SAMPLES);
floatData(fBlockA.Rx_L2, rx_block_pointer[blockIndex]+2, NUM_RX_SLOTS, NUM_SAMPLES);
floatData(fBlockA.Rx_R2, rx_block_pointer[blockIndex]+3, NUM_RX_SLOTS, NUM_SAMPLES);

// Place the audio processing algorithm here. 
process_audioBlocks();

// Fix DAC data for AD1939
fixData(tx_block_pointer[blockIndex]+0, fBlockA.Tx_L1, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+1, fBlockA.Tx_R1, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+2, fBlockA.Tx_L2, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+3, fBlockA.Tx_R2, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+4, fBlockA.Tx_L3, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+5, fBlockA.Tx_R3, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+6, fBlockA.Tx_L4, NUM_TX_SLOTS, NUM_SAMPLES);
fixData(tx_block_pointer[blockIndex]+7, fBlockA.Tx_R4, NUM_TX_SLOTS, NUM_SAMPLES);


//Clear the Processing Active Semaphore after processing is complete
isProcessing = 0;

}

SPORT

///
//NAME: SPORT1_isr.c (Block-based Talkthrough)
//DATE: 02/06/10
//PURPOSE: Talkthrough framework for sending and receiving samples to the AD1939.
//
//USAGE: This file contains SPORT1 Interrupt Service Routine. Four buffers are used
// for this example: Two input buffers, and two output buffers.
///
/*
Here is the mapping between the SPORTS and the ADCs/DACs
For AD1939
ADC1 -> DSP : SPORT1A : TDM Channel 0,1
ADC2 -> DSP : SPORT1A : TDM Channel 2,3
DSP -> DAC1 : SPORT0A : TDM Channel 0,1
DSP -> DAC2 : SPORT0A : TDM Channel 2,3
DSP -> DAC3 : SPORT0A : TDM Channel 4,5
DSP -> DAC4 : SPORT0A : TDM Channel 6,7
*/

#include “ADDS_21479_EzKit.h”
#include <sru.h>

// Counter to choose which buffer to process
int buffer_cntr = 1;
// Semaphore to indicate to main that a block is ready for processing
int inputReady = 0;
// Semaphore to indicate to the isr that the processing has not completed before the
// buffer will be overwritten.
int isProcessing = 0;

//If the processing takes too long, the program will be stuck in this infinite loop.
void ProcessingTooLong(void)
{
while(1);
}

void TalkThroughISR(int sig_int)
{
int i;

if(isProcessing)
    ProcessingTooLong();

//Increment the block pointer
buffer_cntr++;
buffer_cntr %= 2;
inputReady = 1;

}

MAIN

/

#include “ADDS_21479_EzKit.h”

void main()
{

initPLL_SDRAM(); //Initialize the PLL and SDRAM controller

// Initialize DAI because the SPORT and SPI signals
// need to be routed
InitDAI();

// This function will configure the AD1939 codec on the 21479 EZ-KIT
Init1939viaSPI();

// Turn on SPORT0 TX and SPORT1 RX for Multichannel Operation
InitSPORT();

// Unmask SPORT1 RX ISR Interrupt 
interrupt(SIG_SP1,TalkThroughISR);

// Be in infinite loop and do nothing until done.
while(1)
{
	if(inputReady)
		handleCodecData(buffer_cntr);
}

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1612002.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AI大模型日报#0420:开源模型击败GPT-4、西湖大学蛋白质通用大模型、GPT的七条经验

导读&#xff1a; 欢迎阅读《AI大模型日报》&#xff0c;内容基于Python爬虫和LLM自动生成。目前采用“文心一言”生成了每条资讯的摘要。 标题: 开源模型打败GPT-4&#xff01;LLM竞技场最新战报&#xff0c;Cohere Command R上线 摘要: GPT-4在LLM竞技场被开源模型Cohere的…

算法课程笔记——集合set

3复杂度不稳定 删一个和删除全部 注意iter是类 遍历是无序的

AI时代,操作系统交互的革命性变革

AI时代对操作系统交互的影响 对于2024年的智能手机厂商们来说&#xff0c;在冲击高端市场的路上有一场绝对输不起的硬仗&#xff0c;那就是AI大模型的落地之战。 OpenAI的ChatGPT引爆了全球AIGC&#xff08;生成式人工智能&#xff09;热潮&#xff0c;短短一年时间里&#xff…

使用Python爬取易车网汽车信息(含x-sign参数逆向分析)

文章目录 1. 写在前面2. 接口分析3. 断点分析3. 算法还原 【&#x1f3e0;作者主页】&#xff1a;吴秋霖 【&#x1f4bc;作者介绍】&#xff1a;擅长爬虫与JS加密逆向分析&#xff01;Python领域优质创作者、CSDN博客专家、阿里云博客专家、华为云享专家。一路走来长期坚守并致…

【论文精读】Attention is all you need

摘要 主要的序列转换模型是基于复杂的循环或卷积神经网络&#xff0c;其中包括一个编码器和一个解码器。性能最好的模型还通过一种注意力机制将编码器和解码器连接起来。我们提出了一种新的简单的网络架构&#xff0c;Transformer&#xff0c;完全基于注意机制&#xff0c;完全…

C++设计模式:适配器模式(十四)

1、定义与动机 定义&#xff1a;将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的哪些类可以一起工作。 动机&#xff1a; 在软件系统中&#xff0c;由于应用环境的变化&#xff0c;常常需要将“一些现存的对象”放在新的环境…

SpringBoot3 + Vue3 + Element-Plus + TS 实现动态二级菜单级联选择器

SpringBoot3 Vue3 Element-Plus TS 实现动态二级菜单选择器 1、效果展示1.1 点击效果1.2 选择效果1.3 返回值1.4 模拟后端返回数据 2、前端代码2.1 UnusedList.vue2.2 goodsType.ts2.3 http.ts 3、后端代码3.1 GoodsCategoryController.java3.2 GoodsCategoryService.java3.…

内网抓取Windows密码明文与hashdump思考题笔记整理

目录 思考题 第一题 第二题 第三题 第四题 第五题 思考题 1.windows登录的明文密码&#xff0c;存储过程是怎么样的&#xff0c;密文存在哪个文件下&#xff0c;该文件是否可以打开&#xff0c;并且查看到密文 2.我们通过hashdump 抓取出 所有用户的密文&#xff0c;分为…

Mysql学习2

目录 一.数据库&#xff1a; 1.创建数据库&#xff1a; 2.查看数据库&#xff1a; 3.备份恢复数据库&#xff1a; 二.表 1.创建表指令&#xff1a; 2.MySQL常用数据类型&#xff1a; 3.删除与修改表&#xff08;重点&#xff09;&#xff1a; 4.数据库CRUD语句&#xf…

简述PDF原理和实践

Hello&#xff0c;我是小恒不会java。 由于最近有输出PDF报表的项目需求&#xff0c;所以复习一下PDF到底是什么&#xff0c;该如何产生&#xff0c;如何应用至项目中。 更多参见Adobe官方文档&#xff08;https://www.adobe.com/cn/&#xff09; PDF原理 PDF&#xff08;Port…

Linux内核之文件系统访问:目录项、inode、物理磁盘访问关系(五十五)

简介&#xff1a; CSDN博客专家&#xff0c;专注Android/Linux系统&#xff0c;分享多mic语音方案、音视频、编解码等技术&#xff0c;与大家一起成长&#xff01; 优质专栏&#xff1a;Audio工程师进阶系列【原创干货持续更新中……】&#x1f680; 优质专栏&#xff1a;多媒…

(数据结构代码,总结,自我思考)=> { return 个人学习笔记; } 【To be continued~】

俗话说 “学而不思则罔”&#xff0c;是时候复习和整理一下自己先前的学习历程了&#xff01; Chapter-One 《BinarySearch》 public static int binarySearch (int[] a, int target) {int i 0, j a.length - 1;while (i < j) {int m (i j) >>> 1; // 求中位…

小红书电商运营实战课,从0打造全程实操(65节视频课)

课程内容&#xff1a; 1.小红书的电商介绍 .mp4 2.小红书的开店流程,mp4 3.小红书店铺基础设置介绍 ,mp4 4.小红书店铺产品上架流程 .mp4 5.客服的聊天过程和子账号建立 .mp4 6.店铺营销工具使用和后台活动参加 .mp4 7.小红书产品上架以及拍单教程,mp4 8.小红书如何选品…

javaWeb项目-智慧餐厅点餐管理系统功能介绍

项目关键技术 开发工具&#xff1a;IDEA 、Eclipse 编程语言: Java 数据库: MySQL5.7 框架&#xff1a;ssm、Springboot 前端&#xff1a;Vue、ElementUI 关键技术&#xff1a;springboot、SSM、vue、MYSQL、MAVEN 数据库工具&#xff1a;Navicat、SQLyog 1、JavaScript Java…

UltraScale+的40G/50G Ethernet Subsystem IP核使用

文章目录 前言一、设计框图二、模块说明三、上板3.1、发送端3.1、接收端 四、总结 前言 上文介绍了10G/25G Ethernet Subsystem IP核使用&#xff0c;本文将在此基础上介绍40G/50G Ethernet Subsystem IP核的使用&#xff0c;总体区别不大。 一、设计框图 由于40G以太网需要…

Jetson nx 外接OLED屏幕

40 针 GPIO 引脚 GPIO引脚可以用作输入或输出端口&#xff0c;它们提供了一个数字电平以使用户在外界设备上进行控制或读取。Jetson TX2 NX共有198个GPIO引脚&#xff0c;分为三个不同的管脚组&#xff1a;J1、J21和J22。每个管脚组都具有数字输入/输出和PWM功能。 以下是 TX2…

获取AngusTester应用免费许可

第一步、进入晓蚕云官网私有化部署&#xff0c;滑动到底部下载与安装&#xff0c;点击获取许可。 第二步、在获取许可申请页面填写申请信息。 注意&#xff1a;MAC地址为您安装应用服务器对应MAC地址&#xff0c;MAC地址错误会导致安装失败。 在常见的操作系统中&#xff0c;查…

Error in render: TypeError: Cannot read properties of undefined (reading‘‘)

报错内容 报错解释&#xff1a;这个错误在渲染过程中尝试读取一个未定义&#xff08;undefined&#xff09;对象的某个属性时发生了TypeError。具体来说&#xff0c;是尝试读取一个值为undefined的对象的某个属性&#xff0c;但该属性不存在&#xff0c;因此无法读取。解决过程…

【面试经典 150 | 二叉搜索树】验证二叉搜索树

文章目录 写在前面Tag题目来源解题思路方法一&#xff1a;中序遍历方法二&#xff1a;递归 写在最后 写在前面 本专栏专注于分析与讲解【面试经典150】算法&#xff0c;两到三天更新一篇文章&#xff0c;欢迎催更…… 专栏内容以分析题目为主&#xff0c;并附带一些对于本题涉及…

国产信创办公软件(流版式软件)厂家汇总以及国产信创外设汇总

国产信创办公软件&#xff08;流版式软件&#xff09;厂家汇总以及国产信创外设汇总。 国产信创办公软件&#xff08;流版式软件&#xff09;厂家汇总 在信创背景下&#xff0c;国内流版式软件的发展呈现出蓬勃的态势。信创&#xff0c;即信息技术应用创新产业&#xff0c;旨在…