1 #include "context.h"
2 #include "source.h"
3 #include <stdlib.h>
4
5 #define WINDOW_BITS 9
6
7 typedef clunk::mdct_context<WINDOW_BITS, clunk::vorbis_window_func, float> mdct_type;
8 typedef clunk::fft_context<WINDOW_BITS - 2, float> fft_type;
9
main(int argc,char * argv[])10 int main(int argc, char *argv[]) {
11 if (argc > 1 && argv[1][0] == 'b' && argv[1][1] == 'm') {
12 mdct_type mdct;
13 for(int i = 0; i < 1000000; ++i)
14 mdct.mdct();
15 return 0;
16 }
17 if (argc > 1 && argv[1][0] == 'b' && argv[1][1] == 'f') {
18 fft_type fft;
19 for(int i = 0; i < 2000000; ++i)
20 fft.fft();
21 return 0;
22 }
23 if (argc > 1 && argv[1][0] == 't') {
24 fft_type fft;
25 for(int i = 0; i < fft_type::N; ++i) {
26 fft.data[i] = std::complex<float>((i / 4) & 1, 0);
27 }
28 fft.fft();
29 for(int i = 0; i < fft_type::N; ++i) {
30 printf("%f, %f = %f\n", fft.data[i].real(), fft.data[i].imag(), std::abs(fft.data[i]));
31 }
32 fft.ifft();
33
34 for(int i = 0; i < fft_type::N; ++i) {
35 fft.data[i] -= std::complex<float>((i / 4) & 1, 0);
36 printf("%f, %f\n", fft.data[i].real(), fft.data[i].imag());
37 }
38
39 return 0;
40 }
41 clunk::Context context;
42 context.init(44100, 2, 1024);
43
44 clunk::Object * o = context.create_object();
45 clunk::Sample * s = context.create_sample();
46
47 s->load("scissors.wav");
48 static const int d = 2, n = 6;
49
50 context.save("test_out.raw");
51 /* o->play("l", new clunk::Source(s, false, clunk::v3<float>(-d, 0, 0)));
52 sleep(1);
53 //o->play("c", new clunk::Source(s, false, clunk::v3<float>(0, 0, 0)));
54 //sleep(1);
55 o->play("r", new clunk::Source(s, false, clunk::v3<float>(d, 0, 0)));
56 sleep(1);
57
58 o->play("u", new clunk::Source(s, false, clunk::v3<float>(0, d, 0)));
59 sleep(1);
60
61 o->play("b", new clunk::Source(s, false, clunk::v3<float>(0, 0, d)));
62 sleep(1);
63 */
64
65 for(int i = 0; i <= n; ++i) {
66 float a = M_PI * i / n;
67 o->play("s", new clunk::Source(s, false, clunk::v3<float>(-cos(a), -sin(a), 0) * d));
68 usleep(500000);
69 }
70
71 /* for(int i = 0; i <= n; ++i) {
72 float a = M_PI * i / n;
73 o->play("s", new clunk::Source(s, false, clunk::v3<float>(cos(a), -0.25f, sin(a)) * d));
74 usleep(500000);
75 }
76 */ usleep(500000);
77 return 0;
78 }
79