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

📄 amf_volumefletchermunson_render.asm

📁 ADI SHARC DSP 音频算法标准模块库
💻 ASM
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.

// File    : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_VolumeFletcherMunson_Render.asm#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $




//    Module Name     : AMF_VolumeFletcherMunson_Render.asm 
//    DSP Processor   : ADSP21161
//    Original Author : Tim Stilson
//    Date            : 7/22/03
//====================================================================================
// Processor resources used:
//  75 words pmem INTERNAL
//  (70 + 5*tickSize + 5*tickSize/2) = (70 + 7.5*tickSize)
//====================================================================================

// Revision History
//
//      8/27/03 Tim Stilson: started, based on AMF_VolumeFletcherMunson_Render.asm
//      5/15/06 Tim Stilson: fixed bug of L0 not being cleared after first loop (hidden if &in[] < &aux[])

#if 1

#include "processor.h"
#include "AMF_VolumeFletcherMunson.h"
#include "asm_macros.h"
#include "asm_sprt.h"

.global _AMF_VolumeFletcherMunson_Render;           ;

.segment /pm SEG_MOD_FAST_CODE;
_AMF_VolumeFletcherMunson_Render:

//====================================================================================
                            
//push call preserve regs to stack here once stack call params are retrieved
    puts=mode1;
    r0=i0; puts = r0;
    r0=i1; puts = r0;
    r0=i2; puts = r0;
    r0=b0; puts = r0;
    puts = r3;
    puts = r5;
    puts = r6;
    puts = r9;
    puts = r13;
    puts = r14;
    
    i1=r8;                          // i1->buffers[]

    i4=dm(0,i1);                    // i4=input[]
    s14=i4;                         // remember it

    i2=dm(1,i1);                    // i2=output[]
    s13=i2;                         // remember it

    i1=r4;                          // i1->testModuleInstance[0]
    
////////////// allpass biquad: b0=b0, b1=b1, b2=1, a1=b1, a2=b0 (non-negated), based on Sami's biquad
// non-simd

    // initialize states pointers
    r0=dm(AMF_VolumeFletcherMunson_AuxPtr,i1);     // &aux
    b0=r0;                          // i0 points to 1st state
    l0=2;                           // l0 = number of filter states

    r1 = r12;                       // ticksize 

    f3=dm(AMF_VolumeFletcherMunson_b0,i1);          // f3 = b0 = a2
    f2=dm(AMF_VolumeFletcherMunson_b1,i1);          // f2 = b1 = a1
    f0=1.0;                                         // f0 = b2 = 1.0

////////////////////////////////////////////////////////////////////////////////
 //                                           f9 = load input
 //                                           f5 = load state1, move to other side
 //     f12 = a1*state1,                      f6 = load state2, stay here
 //     f12 = a2*state2,   f8 = f9-a1*state1,                 
 //   loop:
 //       f12 = b1*state1, f5 = f8-a2*state2 =new state,      
 //       f8  = b0*new state,                 store new state,  move to other side
 //       f12 = b2*state2, f8 = f8+b1*state1, f6 = load state2, stay here
 //       f12 = a1*state1, f8 = f8+b2*state2, f9 = load input
 //       f12 = a2*state2, f8 = f9-a1*state1, store output
////////////////////////////////////////////////////////////////////////////////
                                            f9 = dm(i4,m6);
                                            f5 = dm(i0,m6);
        f12 = f2 * f5,                      f6 = dm(i0,m5);
        f12 = f3 * f6,   f8 = f9 - f12;
    lcntr = r1, do (pc,5) until lce;
        f12 = f2 * f5,   f5 = f8 - f12;
        f8  = f3 * f5,                      dm(i0,m6) = f5;
        f12 = f0 * f6,   f8 = f8 + f12,     f6 = dm(i0,m5);
        f12 = f2 * f5,   f8 = f8 + f12,     f9 = dm(i4,m6);
        f12 = f3 * f6,   f8 = f9 - f12,     dm(i2,m6) = f8;
////////////////////////////////////////////////////////////////////////////////

    i0 = s14; // restore *in;
    i4 = s13; // restore *out;
    i2 = s13; // *out also (output of allpass);
    l0=0;  // turn off the circular buffer for I0
    

    f8=1.0;
    f4=dm(AMF_VolumeFletcherMunson_AmpSmoothing,i1);                // f4 = float ampSmoothing = instance->ampSmoothing
    f3=f8-f4,   f13=dm(AMF_VolumeFletcherMunson_AmpTarget,i1);      // f3 = oneMinusRate = 1.0 - ampSmoothing,  f13 = ampTarget
    f13=f13*f4, f14=dm(AMF_VolumeFletcherMunson_LowAmpTarget,i1);   // f13 = target*r, f14 = lowAmpTarget
    f14=f14*f4, f5=dm(AMF_VolumeFletcherMunson_Amp,i1);             // f14 = targetLow*r, f5 = amp

    // compute c1 and c2 (smoothing coefs for updating every two samples rather than every sample)

    f3=f3*f3,   f6=dm(AMF_VolumeFletcherMunson_LowAmp,i1);          // f3 = c1 = (1-r)^2, f6 = lowAmp
    f8=f3+f8;                                                       // f8 = 2-r;
    f13=f13*f8;                                                     // f13 = target*c2 = target*r*(2-r)
    f14=f14*f8;                                                     // f14 = targetLow*c2 = targetLow*r*(2-r)
  
    r1 = lshift r1 by -1;

    s3=f3;  // the above calculations and loads are done in SISD because we can't do broadcast loads since the struct may be off-chip
    s5=f5;
    s6=f6;
    s13=f13;
    s14=f14;

    bit set mode1 PEYEN;
    m4=2;

    f4=0.5;                                             // f4/s4=0.5, used inside loop

                                   f12=dm(i2,m4);       // read first allpass output
                                   f8=dm(i0,m4);        // read first input
        f0=f8+f12,    f12=f8-f12;                       // f0=in+ap, f12=in-ap
        f8=f0*f5;                                       // f8=amp*(in+ap)
    LCNTR=r1, DO AMF_VolumeFletcherMunson_loop2_end UNTIL LCE;
        f12=f12*f6;                                     // f8=lowAmp*(in-ap)
        f8=f3*f5,     f0=f8+f12,    f12=dm(i2,m4);      // f8=amp*c1, f0=amp*(in+ap)+lowAmp*(in-ap), f12 = next allpass
        f0=f0*f4,     f5=f8+f13,    f8=dm(i0,m4);       // f0=0.5*(amp(in+ap)+lowAmp(in-ap)), f5=amp*c1+c2, f8=next in
        f8=f3*f6, f0=f8+f12, f12=f8-f12, dm(i4,m4)=f0;  // f8=lowAmp*c1, next[f0=in+ap, f12=in-ap], send output
AMF_VolumeFletcherMunson_loop2_end: 
        f8=f0*f5,     f6=f8+f14;                        // f8=amp*(in+ap), f6=lowAmp*c1+c2low

    bit clr MODE1 PEYEN;
    nop;

    dm(AMF_VolumeFletcherMunson_Amp,i1)=f5;    // instance->amp=last amp
    dm(AMF_VolumeFletcherMunson_LowAmp,i1)=f6; // instance->amp=last amp


    r14 = gets(1);
    r13 = gets(2);
    r9 = gets(3);
    r6 = gets(4);
    r5 = gets(5);
    r3 = gets(6);
    b0 = gets(7);
    i2 = gets(8);
    i1 = gets(9);
    i0 = gets(10);
    mode1=gets(11);
    alter(11);
    
//------------------------------------------------------------------------------------
_AMF_VolumeFletcherMunson_Render.END:
    leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
.endseg;
#endif  

⌨️ 快捷键说明

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