📄 dwtdenoising.c
字号:
byte_T *longFiltOutput = mem;
byte_T *shortFiltOutput = mem + outElemTimesBpe;
/* Two-channel analysis subband filter function */
MWDSP_2ChABank_Fr_DF_DD((real_T *)in,
(real_T *)longFiltOutput,
(real_T *)shortFiltOutput,
(real_T *)tapBuf,
(real_T *)sums,
(real_T *)
&dwtdenoising_P.DyadicAnalysisFilterBan_HF[0],
(real_T *)
&dwtdenoising_P.DyadicAnalysisFilterBan_LF[0],
tapIdx,
phaseIdx,
1,
inFrameSize,
4,
4);
/* Update offset for memcpy operation and for next level */
offset += 64 >> (level+1);
/* copy low pass filtered results to the top of WorkBuffer for next level function call
the high pass filtered results remains stored in the bottom half WorkBuffer */
memcpy((byte_T *)memBase, ((byte_T *)memBase + offset*sizeof(real_T)),
outElemTimesBpe);
/* Update parameters for next level */
inFrameSize = inFrameSize >> 1;
outElem = outElem >> 1;
tapBuf += 1 * 8 * sizeof(real_T);
sums += 2 * 1 * sizeof(real_T);
tapIdx++;
phaseIdx++;
}
/* Output data */
{
byte_T *const memBase = (byte_T *)
&dwtdenoising_DWork.DyadicAnalysisFilterBank_WorkBu[0];
byte_T *outPortAddr[4]; /* Local array of pointers to the output port locations */
int_T outElem = 64;
int_T offset = 64; /* initial offset */
int_T i;
outPortAddr[0] = (byte_T *)rtb_DyadicAnalysisFilterBank_o1;
outPortAddr[1] = (byte_T *)rtb_DyadicAnalysisFilterBank_o2;
outPortAddr[2] = (byte_T *)rtb_DyadicAnalysisFilterBank_o3;
outPortAddr[3] = (byte_T *)rtb_DyadicAnalysisFilterBank_o4;
for (i=0; i < 3; i++) {
byte_T *y = outPortAddr[i];
byte_T *mem = (byte_T *)memBase + offset*sizeof(real_T);
outElem = 64 >> (i+1);
memcpy(y, mem, outElem*sizeof(real_T));
offset += 64 >> (i+1); /* calculate offset for next level */
}
/* last output port */
{
byte_T *y = outPortAddr[4-1];
byte_T *mem = (byte_T *)memBase + (2*64 - outElem)*sizeof(real_T);
memcpy(y, mem, outElem*sizeof(real_T));
}
}
}
/* Update: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay' */
{
/* Single channel input (Delay = 21000, Samples per channel = 32) */
byte_T *buff = (byte_T *)&dwtdenoising_DWork.IntegerDelay_IC_BUFF[0];
const byte_T *u = (const byte_T *) rtb_DyadicAnalysisFilterBank_o1;
int_T buffstart = dwtdenoising_DWork.IntegerDelay_CIRC_BUF_IDX;
while (buffstart >= 21000)
buffstart -= 21000;
{
int_T copy1size = buffstart <= (21000 - 32)? 32 : 21000 - buffstart;
memcpy(buff + (buffstart * sizeof(real_T)), u, copy1size * sizeof
(real_T));
memcpy(buff, u + copy1size * sizeof(real_T), (32 - copy1size) *
sizeof(real_T));
}
dwtdenoising_DWork.IntegerDelay_CIRC_BUF_IDX = (int32_T) (buffstart +
32);
}
/* Update: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay1' */
{
/* Single channel input (Delay = 7000, Samples per channel = 16) */
byte_T *buff = (byte_T *)&dwtdenoising_DWork.IntegerDelay1_IC_BUFF[0];
const byte_T *u = (const byte_T *) rtb_DyadicAnalysisFilterBank_o2;
int_T buffstart = dwtdenoising_DWork.IntegerDelay1_CIRC_BUF_IDX;
while (buffstart >= 7000)
buffstart -= 7000;
{
int_T copy1size = buffstart <= (7000 - 16)? 16 : 7000 - buffstart;
memcpy(buff + (buffstart * sizeof(real_T)), u, copy1size * sizeof
(real_T));
memcpy(buff, u + copy1size * sizeof(real_T), (16 - copy1size) *
sizeof(real_T));
}
dwtdenoising_DWork.IntegerDelay1_CIRC_BUF_IDX = (int32_T) (buffstart +
16);
}
/* Update: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay2' */
{
/* Single channel input (Delay = 7000, Samples per channel = 8) */
memcpy((byte_T *)&dwtdenoising_DWork.IntegerDelay2_IC_BUFF[0] +
(dwtdenoising_DWork.IntegerDelay2_CIRC_BUF_IDX*sizeof(real_T)),
(const byte_T *) rtb_DyadicAnalysisFilterBank_o3, 8 * sizeof
(real_T));
dwtdenoising_DWork.IntegerDelay2_CIRC_BUF_IDX += (int32_T)8;
if (dwtdenoising_DWork.IntegerDelay2_CIRC_BUF_IDX == 7000)
dwtdenoising_DWork.IntegerDelay2_CIRC_BUF_IDX = 0;
}
/* Update: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay3' */
{
/* Single channel input (Delay = 7000, Samples per channel = 8) */
memcpy((byte_T *)&dwtdenoising_DWork.IntegerDelay3_IC_BUFF[0] +
(dwtdenoising_DWork.IntegerDelay3_CIRC_BUF_IDX*sizeof(real_T)),
(const byte_T *) rtb_DyadicAnalysisFilterBank_o4, 8 * sizeof
(real_T));
dwtdenoising_DWork.IntegerDelay3_CIRC_BUF_IDX += (int32_T)8;
if (dwtdenoising_DWork.IntegerDelay3_CIRC_BUF_IDX == 7000)
dwtdenoising_DWork.IntegerDelay3_CIRC_BUF_IDX = 0;
}
}
}
}
}
/* Model step function */
void dwtdenoising_step(void)
{
/* (no output/update code required) */
}
/* Model initialize function */
void dwtdenoising_initialize(boolean_T firstTime)
{
(void)firstTime;
/* Registration code */
/* initialize real-time model */
(void) memset((char_T *)dwtdenoising_M,0,
sizeof(RT_MODEL_dwtdenoising));
/* block I/O */
{
int_T i;
void *pVoidBlockIORegion;
pVoidBlockIORegion = (void *)(&dwtdenoising_B.ADC[0]);
for (i = 0; i < 128; i++) {
((real_T*)pVoidBlockIORegion)[i] = 0.0;
}
}
/* states (dwork) */
(void) memset((char_T *) &dwtdenoising_DWork,0,
sizeof(D_Work_dwtdenoising));
{
int_T i;
real_T *dwork_ptr = (real_T *) &dwtdenoising_DWork.IntegerDelay_IC_BUFF[0];
for (i = 0; i < 42310; i++) {
dwork_ptr[i] = 0.0;
}
}
/* Start for function-call system: '<Root>/Denoising Algorithm' */
codec_init();
/* S-Function Block: <S2>/DAC (c6711dsk_dac) */
config_codec_output();
/* S-Function Block: <S2>/ADC (c6711dsk_adc) */
config_codec_input();
/* Initial conditions for function-call system: '<Root>/Denoising Algorithm' */
/* Initialization: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay' */
{
/* copy ICs from edit box to IC buffer */
dwtdenoising_DWork.IntegerDelay_CIRC_BUF_IDX = 0;
{
int_T i = 0;
for (i=0; i<21000; i++) {
dwtdenoising_DWork.IntegerDelay_IC_BUFF[i] =
dwtdenoising_P.IntegerDelay_IC;
}
}
}
/* Initialization: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay1' */
{
/* copy ICs from edit box to IC buffer */
dwtdenoising_DWork.IntegerDelay1_CIRC_BUF_IDX = 0;
{
int_T i = 0;
for (i=0; i<7000; i++) {
dwtdenoising_DWork.IntegerDelay1_IC_BUFF[i] =
dwtdenoising_P.IntegerDelay1_IC;
}
}
}
/* Initialization: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay2' */
{
/* copy ICs from edit box to IC buffer */
dwtdenoising_DWork.IntegerDelay2_CIRC_BUF_IDX = 0;
{
int_T i = 0;
for (i=0; i<7000; i++) {
dwtdenoising_DWork.IntegerDelay2_IC_BUFF[i] =
dwtdenoising_P.IntegerDelay2_IC;
}
}
}
/* Initialization: Signal Processing Blockset Delay (sdspdelay) - '<S4>/Integer Delay3' */
{
/* copy ICs from edit box to IC buffer */
dwtdenoising_DWork.IntegerDelay3_CIRC_BUF_IDX = 0;
{
int_T i = 0;
for (i=0; i<7000; i++) {
dwtdenoising_DWork.IntegerDelay3_IC_BUFF[i] =
dwtdenoising_P.IntegerDelay3_IC;
}
}
}
/* Signal Processing Blockset IDWT S-Function (sdspidwt) - '<S2>/Dyadic Synthesis Filter Bank' */
{
/* Initialize long and short tap delay buffer indices to zero */
int32_T *longTapIdx = &dwtdenoising_DWork.DyadicSynthesisFilterBank_Lon_b[0];
int32_T *shortTapIdx = &dwtdenoising_DWork.DyadicSynthesisFilterBank_Sho_h[0];
int_T i = 3;
while (i--) {
*longTapIdx++ = 0;
*shortTapIdx++ = 0;
}
/* Initialize all elements of long and short tap delay buffers to zero */
{
real_T *longTapBuf = &dwtdenoising_DWork.DyadicSynthesisFilterBank_LongT[0];
real_T *shortTapBuf = &dwtdenoising_DWork.DyadicSynthesisFilterBank_Short
[0];
int_T j = 12;
while (j--) {
*longTapBuf++ = 0.0;
}
j = 12;
while (j--) {
*shortTapBuf++ = 0.0;
}
}
}
/* Signal Processing Blockset DWT S-Function (sdspdwt) - '<S2>/Dyadic Analysis Filter Bank' */
{
/* Initialize TapDelayIndex to zero and
polyphase index to one for all filter banks */
int32_T *phasePtr = &dwtdenoising_DWork.DyadicAnalysisFilterBank_PhaseI[0];
int32_T *memPtr = &dwtdenoising_DWork.DyadicAnalysisFilterBank_TapD_m[0];
int_T i;
for (i=0; i<3; i++) {
*memPtr++ = 0;
*phasePtr++ = 1;
}
/* Initialize all elements of PartialSums Buffer and input taps to zero */
{
real_T *sumsPointer = &dwtdenoising_DWork.DyadicAnalysisFilterBank_Sums[0];
real_T *tapDelayBuf = &dwtdenoising_DWork.DyadicAnalysisFilterBank_TapDel
[0];
int_T j = 1 * 6;
while (j--) {
*sumsPointer = 0.0;
sumsPointer++;
}
j = 24;
while (j--) {
*tapDelayBuf = 0.0;
tapDelayBuf++;
}
}
}
}
/* Model terminate function */
void dwtdenoising_terminate(void)
{
/* DSP/BIOS Task Block: <S3>/S-Function1 (dspbios_task) */
/* Suspend: Task0 */
{
TSK_epilog(&Task0);
TSK_setpri(&Task0, -1);
}
}
/* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -