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

硬件准备

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.hqwc.cn/news/636111.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SpringBoot基于JavaWeb的菜鸟驿站快递管理系统ssm

前端&#xff1a;vue.jsElementUI 编程语言: java 框架&#xff1a; ssm/springboot 详细技术&#xff1a;springboot springbootvueMYSQLMAVEN 数据库: mysql5.7 数据库工具&#xff1a;Navicat/SQLyog都可以 ide工具&#xff1a;IDEA 或者eclipse 对菜鸟驿站快递管理系统设计…

基于SpringBoot+Vue的爱心公益网站 免费获取源码

项目源码获取方式放在文章末尾处 项目技术 数据库&#xff1a;Mysql5.7/8.0 数据表&#xff1a;11张 开发语言&#xff1a;Java(jdk1.8) 开发工具&#xff1a;idea 前端技术&#xff1a;vue 后端技术&#xff1a;SpringBoot 功能简介 (有文档) 项目获取关键字&#…

Spring Boot + Thymeleaf 实现的任务发布网站

角色&#xff1a; 管理员雇主雇员 功能 雇主&#xff1a;登录、注册、发布任务、选择中标雇员、评价雇员雇员&#xff1a;登录、注册、查看任务列表、投标任务、收藏任务、完成任务管理员、登录、任务管理、雇主管理、雇员管理 部分功能截图 部署 导入数据库…

Linux驱动开发——(一)设备树的基本属性及其应用

目录 一、常见基本属性 1.1 compatible属性 1.2 status属性 1.3 reg属性 1.4 #address-cells属性和#size-cells属性 二、基本属性在设备树的表现 三、基本属性在驱动代码的表现 3.1 驱动代码 3.2 驱动代码中的OF函数 3.2.1 of_find_node_by_path 3.2.2 of_find_prope…

uniapp之消除图片的空白占用空间

我们在使用uniapp开发的过程中一定会遇到一个情况就是我们加载的图片总有一点空白出现在不该出现的地方代码如下 <view style"background:#ff0000;"><image style"width:100%;"src"https://t7.baidu.com/it/u1819248061,230866778&fm19…

插入排序的可视化实现(Python)

插入排序的Python代码 import tkinter as tk import random import timeclass InsertionSortVisualizer:def __init__(self, root, canvas_width800, canvas_height400, num_bars10):self.root rootself.canvas_width canvas_widthself.canvas_height canvas_heightself.nu…

【1471】java项目进度管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 java 项目进度管理系统是一套完善的java web信息管理系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发&#xff0c;数据库为Mysql5.0&…

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…

中国人为什么不说自信,而说信天

中国人从来不说自信&#xff0c;中国人信天&#xff0c;老天爷是最公平的。做好自己&#xff0c;天命注定&#xff0c;我都这么努力了&#xff0c;老天爷不帮我帮谁&#xff1f; 中国人信天是有逻辑关系的&#xff0c;很简单&#xff1a;做错事情了或者结果不好了&#xff0c;…

如何爬出 Kotlin 协程死锁的坑?

作者&#xff1a;悬衡 一、前言 在 Java 中有一个非常经典的死锁问题, 就是明明自己已经占用了线程池, 却还继续去申请它, 自己等自己, 就死锁了, 如下图和代码: // 这段代码将死锁到天荒地老final ExecutorService executorService Executors.newSingleThreadExecutor();exe…

c/c++开发方向

(17 封私信 / 1 条消息) c/c中最挣钱的方向是哪个&#xff1f; - 知乎 (zhihu.com) C的特点是尽量把硬件的性能利用起来。 性能敏感的垂直领域。 &#xff08;快&#xff09;&#xff08;性能&#xff09;&#xff08;性能&#xff09; &#xff08;可能就不是去写应用层业…

域名信息查询同款WHOIS源码

域名查询一般是指查询域名的whois注册信息&#xff0c;域名WHOIS是当前域名系统中不可或缺的一项信息服务。在使用域名进行Internet冲浪时&#xff0c;很多用户希望进一步了解域名、名字服务器详细信息&#xff0c;这就会用到WHOIS。 域名信息查询同款WHOIS源码