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

📄 amf_pooleddelay.c

📁 ADI SHARC DSP 音频算法标准模块库
💻 C
字号:
// 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_Delay.c#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



#include "AMF_PooledDelay.h"

void AMF_PooledDelay_Render(AMF_PooledDelay * restrict instance,float * restrict * buffers, int tickSize);

// NOTE: The C version of this function is for reference only (it is
//       intended just to show the general algorithm that the module
//       uses), and it may not have been fully tested
#if 0

void AMF_PooledDelay_Render(AMF_PooledDelay * restrict instance,float * restrict * buffers,int tickSize) {
    
    int i,temp,ch;
   	int inputcount = instance->b.inputPinCount;
    int outputcount = instance->b.outputPinCount;
    int total_delay_size = instance->DelaySize;
   	float *base_ptr = &instance->DelayBuffer[0];            // delay buffer
   	int *delay_size = &instance->DelayChan[0];
	int *max_Delay_size = &instance->MaxDelayChan[0];
	int write_index,read_index;
	float *read_ptr, *write_ptr, *in, *out ;
	int valid_chans=0,index;
	float temp_val;
	float *end_ptr;
	

	/*****************************************
	* Check for wether given delay for channel
	* is not exceding total  provided delay
	******************************************/
	temp = 0;
	for(ch = 0;ch < inputcount;ch++)
	{
		temp += max_Delay_size[ch];
		if(temp < total_delay_size)
			valid_chans++;
	}

	/******************************************
	* Apply delay to all channels
	*******************************************/

	for(ch = 0;ch < valid_chans; ch++)
	{
		write_index = instance->WriteIndexChan[ch];
		read_index = write_index - delay_size[ch];

		while (read_index<0) 
		{
			read_index += max_Delay_size[ch];
		}
		write_ptr = base_ptr;
        read_ptr = base_ptr;
		/* make write and read pointers to appropriate positions*/
		write_ptr = write_ptr + (write_index );
		read_ptr = read_ptr + (read_index);
		end_ptr = base_ptr +  max_Delay_size[ch];

		in = buffers[ch];
		out = buffers[inputcount+ch];

		
        for (i=0;i<tickSize;i++)
		{
			*write_ptr++ = in[i];
			temp_val = *read_ptr++;
					
			if((write_ptr) >= end_ptr)
				write_ptr = base_ptr;
			
			if(read_ptr >= end_ptr)
				read_ptr = base_ptr;
	
            out[i] = temp_val;              
         }

        index = write_ptr - base_ptr;
        instance->WriteIndexChan[ch]=index;
        base_ptr += max_Delay_size[ch];

	}
	/*******************************************************
	* Mute the invalid channels -- this will happenes
	* only when provided delay exceeds given total delay
	* by user
	*******************************************************/
	for(ch = valid_chans;ch < inputcount; ch++)
	{        
		out = buffers[inputcount + ch];
        for (i=0;i<tickSize;i++)
		     out[i] = 0.0;              
	}

    
}



#endif



SEG_MOD_SLOW_CONST const AMF_ModuleVariableClass AMFClassPooledDelay = {

    /* Flags */
    AMFModuleClassFlag_VARIABLE_PIN_COUNT,

    /** Reference to render function. */
    (AMF_RenderFunction)AMF_PooledDelay_Render,  // render function 

    /* Default bypass */
    (void *)0,
      
};

⌨️ 快捷键说明

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