forked from adsp-21369-reverb/VisualDSP-Reverb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockProcess.c
More file actions
89 lines (65 loc) · 2.3 KB
/
Copy pathblockProcess.c
File metadata and controls
89 lines (65 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "tt.h"
#include "DSP.h"
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
//#include <stdfix.h>
//#include <float.h>
#define mix 0.25 // 0.0 for dry signal, 1.0 for wet signal
static int loop_count = 0;
#pragma misra_func(time)
clock_t start_t, end_t, total_t;
float clocks, timer;
void Block_Fixed_To_Float( int * Fixed_In, float * Float_Out_L, float * Float_Out_R );
void Block_Float_To_Fixed( int * Fixed_Out, float * Float_In_L, float * Float_In_R );
void processBlock(unsigned int *block_ptr)
{
int i;
static float leftChannel[NUM_SAMPLES/2];
static float rightChannel[NUM_SAMPLES/2];
float leftDry[NUM_SAMPLES/2];
float rightDry[NUM_SAMPLES/2];
start_t = clock(); // start timer
//Clear the Block Ready Semaphore
blockReady = 0;
//Set the Processing Active Semaphore before starting processing
isProcessing = 1;
loop_count++; // count loops until sdram error
Block_Fixed_To_Float((int *) block_ptr, leftChannel, rightChannel);
for(i=0; i<NUM_SAMPLES/2;i++)
{
leftDry[i] = leftChannel[i];
rightDry[i] = rightChannel[i];
}
DSP_reverb(leftChannel, rightChannel);
for(i=0; i<NUM_SAMPLES/2;i++)
{
leftChannel[i] = leftChannel[i]*mix + leftDry[i]*(1-mix);
rightChannel[i] = rightChannel[i]*mix + rightDry[i]*(1-mix);
}
Block_Float_To_Fixed((int *) block_ptr, leftChannel, rightChannel);
//Clear the Processing Active Semaphore after processing is complete
isProcessing = 0;
clocks = CLOCKS_PER_SEC;
end_t = clock(); // end timer
total_t = end_t - start_t; // compute process cycles
timer = ((double) (total_t))/CLOCKS_PER_SEC; // compute process time
}
void Block_Fixed_To_Float( int * Fixed_In, float * Float_Out_L, float * Float_Out_R )
{
int i;
#pragma SIMD_for
for (i=0;i<NUM_SAMPLES/2;i++)
{
Float_Out_L[i] = ((float) (Fixed_In[2*i]<<8)) * (1.0/2147483648.0);
Float_Out_R[i] = ((float) (Fixed_In[2*i+1]<<8)) * (1.0/2147483648.0);
}
}
void Block_Float_To_Fixed( int * Fixed_Out, float * Float_In_L, float * Float_In_R )
{
int i;
#pragma SIMD_for
for (i=0;i<NUM_SAMPLES/2;i++)
{
Fixed_Out[2*i] = ((int) (2147483648.0*Float_In_L[i]))>>8;
Fixed_Out[2*i+1] = ((int) (2147483648.0*Float_In_R[i]))>>8;
}
}