



I am having some trouble with an FDN reverb I am starting to design. My plugin will compile, but whenever I run the plugin in rack AFX it crashes. When I load it with the debugger it tells me that it cannot access memory when reading/writing from a circular buffer.Â
Here is the relevant code in various section of the plugin:
Header Variables:Â
float fdnCoef[24][24] = { 0 }; //Matrix of Coefiecents [current][target]
float globalRC= 0.9; //Global Reflections
float inputMatrix[2][24] = { 0 }; //[inch, node]
float outputMatrix[24][2] = { 0 }; //[node, outch]
double thisInput[24];
double thisOutput[24];
double delayTime[24];
double outputs[2] = { 0 };
ZVAFilter fdnFilters[24]; //Filters at the end of each delay line
SimpleDelay fdnDelay[24]; //Delay lines
/*
Basic model
nodes will always write into their assigned delay line. They will read from delay lines based on the coeficent matrix
inputMatrix[i][n] x thisInput[n] (according to input matrix)
fdnDelay[x] x fdnCoef[n][x] =+> thisInput[n] => fdnFilter[n] => globalRC => fndDelay[n]
thisOutput[n] x outputMatrix[n][i]
*/
added to reset function:
for (int n = 0; n < 24; n += 3) {
//Ahead
fdnCoef[n][n + 1] = 1.0;
fdnCoef[n + 1][n + 2] = 1.0;
//To the Left
fdnCoef[n][n + 3] = 0.9;
fdnCoef[n + 1][n + 4] = 0.9;
fdnCoef[n + 2][n + 5] = 0.9;
//To the Right
fdnCoef[n][n - 3] = 0.9;
fdnCoef[n + 1][n - 2] = 0.9;
fdnCoef[n + 2][n - 1] = 0.9;
//Initalize delay lines
fdnDelay[n].reset(resetInfo.sampleRate);
fdnDelay[n].createDelayBuffer(resetInfo.sampleRate, 100.0);
}
for (int n = 0; n < 25; n++) {
delayTime[n] = 10.0;
}
Stereo plug-in processor:
double inL = processFrameInfo.audioInputFrame[0];
double inR = processFrameInfo.audioInputFrame[1];
outputs[0] = 0;
outputs[1] = 0;
for (int n = 0; n < 24; n++) {
thisInput[n] = inL * inputMatrix[0][n];
thisInput[n] += inR * inputMatrix[1][n];
thisOutput[n] = 0;
for (int x = 0; x < 24; x++) {
float thisCoef = fdnCoef[n][x];
if (thisCoef != 0.0) {
thisOutput[n] += fdnDelay[x].readDelayAtTime_mSec(delayTime[x])*thisCoef;
}
}
thisOutput[n] += thisInput[n];
//Filter will go here
outputs[0] += thisOutput[n] * outputMatrix[n][0];
outputs[1] += thisOutput[n] * outputMatrix[n][1];
fdnDelay[n].writeDelay(thisOutput[n]);
}
processFrameInfo.audioOutputFrame[0] = outputs[0];
processFrameInfo.audioOutputFrame[1] = outputs[1];
return true; /// processed
Hi Chris,
 When I load it with the debugger it tells me that it cannot access memory when reading/writing from a circular buffer.Â
Can you give the exact output of the debugger? Is this buffer part of your plugin or RackAFX?
Here is the relevant code in various section of the plugin:
Header Variables:Â
I assume these are members of your class? Or are they "free"/global variables?
float fdnCoef[24][24] = { 0 }; //Matrix of Coefiecents [current][target]
float globalRC= 0.9; //Global Reflections
float inputMatrix[2][24] = { 0 }; //[inch, node]
float outputMatrix[24][2] = { 0 }; //[node, outch]
double thisInput[24];
double thisOutput[24];
double delayTime[24];
double outputs[2] = { 0 };ZVAFilter fdnFilters[24]; //Filters at the end of each delay line
SimpleDelay fdnDelay[24]; //Delay lines
You are creating a lot of stuff here, and if the class is instantiated on stack, this might cause a stack overflow.
Also, check how you are accessing memory: You are probably leaving your array bounds here in multiple places:
fdnCoef[n][n + 1] = 1.0;
fdnCoef[n + 1][n + 2] = 1.0;
//To the Left
fdnCoef[n][n + 3] = 0.9;
fdnCoef[n + 1][n + 4] = 0.9;
fdnCoef[n + 2][n + 5] = 0.9;
//To the Right
fdnCoef[n][n - 3] = 0.9;
fdnCoef[n + 1][n - 2] = 0.9;
fdnCoef[n + 2][n - 1] = 0.9;
//Initalize delay lines
fdnDelay[n].reset(resetInfo.sampleRate);
fdnDelay[n].createDelayBuffer(resetInfo.sampleRate, 100.0);}
for (int n = 0; n < 25; n++) {
delayTime[n] = 10.0;
}


Hey Tom,
Thank you for the quick reply. I have it running now which was due to fixing my array bounds issues (I am a C++ novice and am use to higher level languages just wrapping things for me and there was that one "25" typo).Â
I am doing all of those as free floating variables for now, but I am planning on making the thing into an fdn class that can create a network of n nodes. Do you think instantiating too many of this class would create stack overflow and is there a better way of dealing with setting the coefficients than passing a huge array? This is my first foray into lower level programming so I am sure that I am prone to making some rookie mistakes.Â
Chris_1 said
Hey Tom,Thank you for the quick reply. I have it running now which was due to fixing my array bounds issues (I am a C++ novice and am use to higher level languages just wrapping things for me and there was that one "25" typo).Â
You should also take care about the n+1/+2/-2 indices. They go out of bounds at the beginning and the end of your loop, too. C/C++ will allow you to do so - but still you are writing "somewhere" in memory, outside of the array. Probably you are overwriting something else.Â
I am doing all of those as free floating variables for now, but I am planning on making the thing into an fdn class that can create a network of n nodes. Do you think instantiating too many of this class would create stack overflow and is there a better way of dealing with setting the coefficients than passing a huge array? This is my first foray into lower level programming so I am sure that I am prone to making some rookie mistakes.  Â
It depends 😉 If you create everything on stack, it will most likely become a problem. You have to consider that arrays in C++ are no separate objects, but they are part of the object's representation in memory (or of "global memory" if you don't use a class). An array of floats as a member variable is (at runtime) same as creating the same number of separate variables:
float data[4];
is equivalent to
float a;
float b;
float c;
float d;
Now, if you create arrays of delays, where each delay has arrays of buffers etc. this will add up really quickly.
The problem is not the amount of memory you need for this, but that you are requesting it as a single block of contiguous memory.
Â
Another note: if you place all the variables in "global memory", you won't be able to instantiate more than one plugin!
I hope this helps 😉 If you need more help, maybe we should move the discussion into the "C++ Programming" area.
Most Users Ever Online: 152
Currently Online:
4 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Chaes: 56
Skyler: 48
StevieD: 46
Derek: 46
Frodson: 45
Peter: 43
TheSmile: 43
Nickolai: 43
clau_ste: 39
jeanlecode: 37
Member Stats:
Guest Posters: 1
Members: 775
Moderators: 1
Admins: 6
Forum Stats:
Groups: 13
Forums: 42
Topics: 846
Posts: 3353
Moderators: W Pirkle: 690