I am creating a custom module. In the Matlab constructor file I added the following code:
S=stft_design(K, ATTEN);
add_array(M,'H','float',single(S.HH),'const','wola window filter');
M.H.arrayHeap = 'AWE_HEAP_FAST2SLOW';
M.H.arraySizeConstructor= '320*sizeof(float)';
At this point I can see that M.H has the correct data.
The following C constructor code is created:
if ((S->H = (FLOAT32 *) awe_fwMalloc(320*sizeof(float), AWE_HEAP_FAST2SLOW, retVal)) == 0)
{
// Error code is in *retVal
return 0;
}
Attaching VS to awe_server I can examine S->H, it is all zeros. How does the data get transferred from Matlab M.H to C S->H?
2:53pm
Hi Darrel,
The initial value of your array will get transferred to the target when a layout is loaded with that module in it. This means that the initial values you defined will not be available in your .c code's constructor, which matches what you see since S->H is all zero's when you set a breakpoint after the malloc.
Instead of being defined in the .c code, the binary commands following the creation of the module will populate the internal variables with the initial conditions that you specify in the matlab definition. If you put a breakpoint in your Process function, then the values in S->H should be what you expect since at that point the layout has been fully loaded and all initial values set.
For (hopefully) a little more clarity, see this section of an .aws generated with a SOFCascadeHP module in it:
0,create_module,SOFCascadeHP1,ModuleSOFCascadeHP,1,1,0,wire3,wire4,1,10.0,1,1.0
0,write_int_array,SOFCascadeHP1.filterType[0],5
0,write_float_array,SOFCascadeHP1.freq[0],250.0
0,write_float_array,SOFCascadeHP1.Q[0],1.0
0,write_float_array,SOFCascadeHP1.currentCoeffs[0],2.33929422e-05,0.97686398,-0.000511335151,0.977125645,-0.0452136062
The SOFCascadeHP module first gets created, which will call the module's constructor, and then the initial values of the internal parameters and arrays are populated by subsequent commands. If you generate an .aws with your module in it you should see something similar.
Let us know if you still have any issues, or if this explanation wasn't clear enough.
Thanks
-Axel