mainClass.cpp 1.68 KB
Newer Older
Mert Burkay Çöteli's avatar
Mert Burkay Çöteli committed
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
#include "analysistransform.h"
#include "synthesistransform.h"
#include "soundfielddescription.h"


int main()
{
	int bloksize = 4096;
	int padding = 0;
	int total = bloksize + padding;
	analysistransform* m_fft = new analysistransform(2048, total,1024,2);
	synthesistransform* m_ifft = new synthesistransform(2048, total, 1024, 2);
	//soundfielddescription* m_shd = new soundfielddescription();

	double * signal = (double*)calloc(total *2, sizeof(double*));
	double* signal_out = (double*)calloc(total * 2, sizeof(double*));
	double*  realpart = (double*)calloc(total *2, sizeof(double*));
	double*  imagpart = (double*)calloc(total *2, sizeof(double*));
	for (int ch = 0; ch < 2; ch++)
	{
		for (int ik = 0; ik < total; ik++)
		{
			float degree = ((float)ik / (float)48000.0) * 2 * PI * 5000.0;
			if (ik >= padding)
				signal[ik*2 + ch] = 1* sin(degree);
			else
				signal[ik * 2 + ch] = 0.0;
		}
	}

	m_fft->FFT(signal, realpart, imagpart);
	m_ifft->IFFT(signal_out, realpart, imagpart);

	double average_error = 0.0;
		for (int klm = padding; klm < total; klm++)
		{
			average_error += abs(signal[klm * 2 + 1] - signal_out[klm * 2 + 1]);
			
		}
		printf("{%f}", average_error / bloksize);


		soundfielddescription sfd = soundfielddescription();


		char audioscenegeometry[] = R"(
		{
				"$schema": "http://json-schema.org/draft-07/schema#",
				"title" : "Audio Scene Geometry",
				"BlockIndex": ,
				"BlockStart" : ,
				"BlockEnd" : ,
				"SpeechCount" : 1,
				"SourceDetectionMask" : [],
				"SpeechList": [
						{"SpeechID" :  0.93358, "ChannelID" : 0.0, "AzimuthDirection" : 0.35836, "ElevationDirection" : 0.0, "DistanceFlag" : 0.93358, "Distance" : 0.0},
		
				],
				}
		)";


	return 0;
}