2 ZynAddSubFX - a software synthesizer
4 RtAllocTest.h - CxxTest for RT Safe Note Allocation
5 Copyright (C) 2014 Mark McCurry
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
14 #include <cxxtest/TestSuite.h>
17 #include "../Misc/Part.h"
18 #include "../Misc/Util.h"
19 #include "../Misc/Allocator.h"
20 #include "../Params/Presets.h"
21 #include "../DSP/FFTwrapper.h"
22 #include "../globals.h"
28 size_t allocated_size
;
29 void *(*old_malloc_hook
)(size_t, const void*);
30 void *hook(size_t size
, const void *v
)
32 printf("Alloc(%d,%p)\n", size
, v
);
33 allocated_size
+= size
;
36 void *res
= malloc(size
);
42 class RtAllocTest
:public CxxTest::TestSuite
53 //First the sensible settings and variables that have to be set:
55 synth
->buffersize
= 256;
59 denormalkillbuf
= new float[synth
->buffersize
];
61 //phew, glad to get thouse out of my way. took me a lot of sweat and gdb to get this far...
62 fft
= new FFTwrapper(synth
->oscilsize
);
63 micro
= new Microtonal();
64 part
= new Part(memory
, micro
, fft
);
65 part
->partoutl
= new float[synth
->buffersize
];
66 part
->partoutr
= new float[synth
->buffersize
];
67 //prepare the default settings
79 old_malloc_hook
= __malloc_hook
;
81 part
->NoteOn(82, 101, 0);
82 printf("allocated size = %u\n", allocated_size
);
83 printf("allocations = %u\n", allocations
);