⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expander.asm

📁 adsp21065例程代码 音频处理及其他 adsp2XXX源代码 在Vdsp++下应用
💻 ASM
字号:
/***   EXPANDER.ASM   *********************************************************************
*                                                                                         *
*       ADSP-21065L EZ-LAB  Expander Effect Program                                       *
*       Developed using ADSP-21065L EZ-LAB Evaluation Platform                            *
*                                                                                         *
*                                                                                         *
*       What the expander does?                                                           *
*       -----------------------                                                           *
*       Opposite of a compressor, with opposite input/output ratios                       *
*       Uses in conjunction with a compressor to produce what is know as a 'compander'.   *
*       Can be used to enhance missing dynamics in a compresses signal, but it is         *
*       recommended that moderate expansion ratios be used, or else risk introducing      *
*       distortion with the signal saturating to +/- 0.99999.  This effect is often       *
*       used to to recover the full dynamic range of a compresses signal.  Also useful    *
*       for reducing noise in tape recoreding and wireless systems by increasing the      *
*       level of the audio signal relative to low-level noise beyond a low threshold.     *
*                                                                                         *
*       Parameters:                                                                       *
*       -----------                                                                       *
*       Threshold:  The level at which the dynamics processor begins adjusting the        *
*       volume of the signal.                                                             *
*       Compression Ratio:  Level comparison of the input and output signals of the 	  *
*       dynamics processor past the threshold. Recommended rations range from 1.1 to      *
*       3.0, with typical ratios ranging from 1.3 to 1.5                                  *
*                                                                                         *
*       Future Parameters that will be added in Rev 2.0:                                  *
*       ------------------------------------------------                                  *
*       Attack Time:  The amount of time it takes once the input signal has passed the    *
*       threshold for the dynamics processor to begin attenuating the signal.             *
*       Release Time:  The amount of time it takes once the input signal has passed       *
*       below the threshold for the dynamics processor to stop attenuating the signal     *	
*                                                                                         *
*                                                                                         *
*                                                                                         *
*                                                        John Tomarakos                   *
*                                                        ADI DSP Applications Group		  *
*                                                        Revision 1.0			          *
*                                                        11/19/98                         *
*                                                                                         *
*******************************************************************************************/

/* ADSP-21065L System Register bit definitions */
#include 	"def21065l.h"
#include 	"new65Ldefs.h"

.EXTERN 	Left_Channel_In;
.EXTERN		Right_Channel_In;
.EXTERN 	Left_Channel_Out;
.EXTERN		Right_Channel_Out;

.GLOBAL		Stereo_Expander;
.GLOBAL		select_expansion_ratio;
.GLOBAL		select_threshold;


.segment /dm    expander;

.var	IRQ1_counter = 0x00000003;		
.var	IRQ2_counter = 0x00000003;

.var	ratio = 1.3;
.var	threshold = 0.5;

.endseg;


.segment /pm pm_code;

/********************************************************************************
 *                                                                              *
 *                           STEREO EXPANDER ROUTINE                            *
 *                                                                              *
 *              inputs:                                                         *
 *              f2 = left channel data                                          *
 *              f3 = right channel data                                         *
 *                                                                              *
 *              outputs:                                                        *
 *              f2 = compressed left channel data                               *
 *              f3 = compressed right channel data                              *
 *                                                                              *
 ********************************************************************************/

Stereo_Expander:
	r2 = DM(Left_Channel_In);			/* left input sample */
	r3 = DM(Right_Channel_In);			/* right input sample */

	r1 = -31;     						/* scale the sample to the range of +/-1.0 */									
   	f2 = float r2 by r1; 				/* convert fixed point sample to floating point */							
	f3 = float r3 by r1; 				/* convert fixed point sample to floating point */
							      	
	f0 = DM(ratio);						/* f0 = ratio = 1.3 */
	f1 = DM(threshold);					/* f1 = threshold = 0.5	*/
	
expand_left:
	f4 = abs f2;
	comp(f4,f1);						/* Is left channel past threshold? */
	if LT jump expand_right;			/* If not, check the right channel */
	f4 = f4 - f1; 						/* signal = signal - threshold */
	f4 = f4 * f0; 						/* signal = signal * ratio */
	f4 = f4 + f1; 						/* signal = signal + threshold */
	f2 = f4 copysign f2;				/* f2 now contains compressed left channel*/
expand_right:
	f4 = abs f3;
	comp(f4,f1);						/* Is right channel past threshold? */
	if LT jump finish_processing;		/* if not, return from subroutine */
	f4 = f4 - f1;						/* signal = signal - threshold */
	f4 = f4 * f0;						/* signal = signal * ratio */
	f4 = f4 + f1;						/* signal = signal + threshold */
	f3 = f4 copysign f3;				/* f3 now contains compressed right channel*/

finish_processing:
	r1 = 31;     						/* scale the result back up to MSBs */			   
	r2 = fix f2 by r1;					/* convert back to fixed point number */
	r3 = fix f3 by r1;					/* convert back to fixed point number */
	
	/* send compressor results to left and right DAC channels */				
	DM(Left_Channel_Out) = r2;
	DM(Right_Channel_Out) = r3;

	rts;


/* ------------------------------------------------------------------------------------ */
/*                                                                                      */
/*                         IRQ1 Pushbutton Interrupt Service Routine                    */
/*                                                                                      */
/*      This routine allows the user to modify expansion ration settings with 5 presets.*/
/*                                                                                      */
/*      Default before 1st IRQ push:                                                    */
/*      1st Pushbutton Press:                                                           */
/*      2nd Pushbutton Press:                                                           */
/*      3rd Pushbutton Press:                                                           */
/*      4th Pushbutton Press:                                                           */
/*      5th Pushbutton Press:                                                           */
/*      6th Pushbutton Press:	Reverts back to 1st Pushbutton Press                    */
/*                                                                                      */
/*      The pushbutton setting is shown by the active LED setting, all others are off   */	
/* ------------------------------------------------------------------------------------ */
						  
select_expansion_ratio:
    bit set mode1 SRRFH;				/* enable background register file */
	NOP; 								/* 1 CYCLE LATENCY FOR WRITING TO MODE1 REGISER!!   */

	r13 = 5;							/* number of presets */	
	r15 = DM(IRQ1_counter);				/* get preset count */
	r15 = r15 + 1;						/* increment preset */
	comp (r15, r13);
	if ge r15 = r15 - r15;				/* reset to zero */
	DM(IRQ1_counter) = r15;				/* save preset count */

	r10 = pass r15;						/* get preset mode */
	if eq jump ratio_setting_2;			/* check for count == 0 */
	r10 = r10 - 1;
	if eq jump ratio_setting_3; 		/* check for count == 1 */
	r10 = r10 - 1;
	if eq jump ratio_setting_4;			/* check for count == 3 */
	r10 = r10 - 1;
	if eq jump ratio_setting_5;			/* check for count == 4 */

ratio_setting_1:						/* count therefore, is == 5 if you are here */
	/* 1:1.1 ratio */			
	f14 = 1.1;	
	DM(ratio) = f14;
	bit set ustat1 0x3D;				/* turn on Flag5 LED */
	bit clr ustat1 0x02;
	dm(IOSTAT)=ustat1;		
     	jump done;

ratio_setting_2:
	/* 1:1.2 ratio */			
	f14 = 1.2;		
	DM(ratio) = f14;
	bit set ustat1 0x3B;				/* turn on Flag6 LED */
	bit clr ustat1 0x04;
	dm(IOSTAT)=ustat1;
	jump done;

ratio_setting_3:
	/* 1:1.3 ratio */			
	f14 = 1.3;		
	DM(ratio) = f14;
	bit set ustat1 0x37;				/* turn on Flag7 LED */
	bit clr ustat1 0x08;
	dm(IOSTAT)=ustat1;
	jump done;

ratio_setting_4:
	/* 1:1.4 ratio */			
	f14 = 1.4;		
	DM(ratio) = f14;
	bit set ustat1 0x2F;				/* turn on Flag8 LED */
	bit clr ustat1 0x10;
	dm(IOSTAT)=ustat1;
	jump done;

ratio_setting_5:
	/* 1:1.5 ratio */				
	f14 = 1.5;		
	DM(ratio) = f14;
	bit set ustat1 0x1F;				/* turn on Flag9 LED */
	bit clr ustat1 0x20;
	dm(IOSTAT)=ustat1;

done:	
	rti(db);
	bit clr mode1 SRRFH;				/* switch back to primary register set */
	nop;
	
/* ------------------------------------------------------------------------------------ */
/*                                                                                      */
/*                       IRQ2 Pushbutton Interrupt Service Routine                      */
/*                                                                                      */
/*      This routine selects the expansion threshhold, which is the level at which      */
/*      expansion of the input signal occurs.                                           */
/*                                                                                      */	
/* ------------------------------------------------------------------------------------ */
						  
select_threshold:
    bit set mode1 SRRFH;				/* enable background register file */
	NOP; 								/* 1 CYCLE LATENCY FOR WRITING TO MODE1 REGISER!!   */

	r13 = 5;							/* number of presets */	
	r15 = DM(IRQ2_counter);				/* get preset count */
	r15 = r15 + 1;						/* increment preset */
	comp (r15, r13);
	if ge r15 = r15 - r15;				/* reset to zero */
	DM(IRQ2_counter) = r15;				/* save preset count */

	r10 = pass r15;						/* get preset mode */
	if eq jump threshold_2;				/* check for count == 0 */	
	r10 = r10 - 1;						/* get preset mode */
	if eq jump threshold_3;				/* check for count == 1 */	
	r10 = r10 - 1;						/* get preset mode */
	if eq jump threshold_4;				/* check for count == 2 */	
	r10 = r10 - 1;						/* get preset mode */
	if eq jump threshold_5;				/* check for count == 3 */

threshold_1:							/* count therefore, is == 4 if you are here */
	f14 = 0.75;			
	DM(threshold) = f14;
	bit set ustat1 0x2C;		
	bit clr ustat1 0x02;				/* turn on Flag4 & Flag5 LEDs */
	dm(IOSTAT)=ustat1;
     	jump exit;

threshold_2:
	f14 = 0.5;	
	DM(threshold) = f14;
	bit set ustat1 0x2A;		
	bit clr ustat1 0x05;				/* turn on Flag4 & Flag6 LEDs */
	dm(IOSTAT)=ustat1;
	jump exit;
	
threshold_3:							/* count therefore, is == 4 if you are here */
	f14 = 0.30;	
	DM(threshold) = f14;
	bit set ustat1 0x26;		
	bit clr ustat1 0x09;				/* turn on Flag4 & Flag7 LEDs */
	dm(IOSTAT)=ustat1;
     	jump exit;

threshold_4:							/* count therefore, is == 4 if you are here */
	f14 = 0.25;	
	DM(threshold) = f14;
	bit set ustat1 0x2E;		
	bit clr ustat1 0x11;				/* turn on Flag4 & Flag8 LEDs */
	dm(IOSTAT)=ustat1;
     	jump exit;

threshold_5:							/* count therefore, is == 4 if you are here */
	f14 = 0.15;	
	DM(threshold) = f14;
	bit set ustat1 0x1E;		
	bit clr ustat1 0x21;				/* turn on Flag4 & Flag9 LEDs */
	dm(IOSTAT)=ustat1;

exit:	
	rti(db);
	bit clr mode1 SRRFH;				/* switch back to primary register set */
	nop;

.endseg;









⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -