Hello!
I recently started to use Bela platform in order to implement some basic system for research at my faculty. This program has two parts: first is some calculation and the second one is standard Bela real-time program with setup(), render() and cleanup() function as usual. I run first part separately from second part, and I get what I want (point is-it works). I run it in visual studio. It has some classes, it has .h and .cpp files...
Problem occurs when I want to combine those two programs, and first run first part (i copied .cpp and .h files in BelaIDE, and I need to put main() somewhere) and then the second part which sholud be real-time. I tried to put whole main function in setup() function, then I tried to put that whole function above setup(), I even tried to make another function (eg m() and put all content of my original main in that function) and to call that function from setup(). But none of those works.
Could you help me, please?
Problem with function running before real-time program
TijanaDjordjevic
Error is:
Segmentation fault
Makefile:579: recipe for target 'runide' failed
make: *** [runide] Error 139
I don't know if problem is about some allocation.
Please help!!
hi there,
when you include a main()
function in your program none of the Bela setup/render/cleanup functions is called. If you renamed the main()
function to something else, then setup()
should be called as expected and a printf("SETUP\n")
as the first line of the setup()
function should demonstrate that. If you get a segmentation fault before such line is even executed, then it may be happening during the initialisation of some global variable.
- Edited
Thanks for replying!
I declared some global variables above that function, because I will need that variables in render() later.
For example:
Delay* SamplesToWait = new Delay[NumberOfSources];
(I have class Delay (which has fields: int NumberOfMicrophones and float *d) and NumberOfSources is 8)
Then I calculate those SamplesToWait in that functon (lets call it m() ), and i call from setup() my m() function. But when I try to access to SamplesToWait in render() I get Segmentation fault. I guessed that problem is something with pointers, and I tried to remove destructor, but it's not that. (It's interesting that I get another values of Delay[1].NumberOfMicrophones with and without destructor even if I initialize it with the same value, and none of those values is ok-it should be 8, but it is 17(without destructor)or 0(with destructor)).
If you need my code I will send you, I will comment so you can understand properly, code is quite simple.
Best regards!
Problem solved!!!
Thank you so much!
Problem was destructor (because it kills what I make before I use it) and initialization (I write some command to calculate size but that command was not inside any function and it did not run, so it was some random value for size, because of that I was getting strange results).
great to hear that