ITAConvolutionTest.cpp 917 Bytes
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
#include <stdio.h>
Fabian Schlieper's avatar
Fabian Schlieper committed
2
#include <cstring>
Jonas Stienen's avatar
Jonas Stienen committed
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

#include <ITAAudiofileReader.h>
#include <ITAAudiofileWriter.h>

#include <ITAConvolution.h>
#include <ITAStringUtils.h>

using namespace std;


void test1() {
	// Einfaches Durchfalten. Kein Austausch
	const int m=7;
	const int n=5;
	int o = m+n-1;

	float* s = new float[m];
	float* h = new float[n];
	float* g = new float[o];

	memset(s, 0, m*sizeof(float));
	memset(h, 0, n*sizeof(float));
	memset(g, 0, o*sizeof(float));

	for (int i=0; i<(m>>1); i++) s[i] = 1;
	for (int i=0; i<(n>>1); i++) h[i] = 1;
	//for (int i=0; i<n; i++) h[i] = 1;

	printf("s = %s\n", FloatArrayToString(s, m).c_str());
	printf("h = %s\n", FloatArrayToString(h, n).c_str());

	ITAConvolution conv(m, n);
	conv.convolve(s, m, h, n, g, o);

	printf("g = %s\n", FloatArrayToString(g, o).c_str());

	delete[] s;
	delete[] h;
	delete[] g;
}

int main(int argc, char* argv[]) {

	test1();

	return 0;
}