I have a piece of code which performs operations on a user defined amount of channels.
I am trying to use an array to handle the channels (following Salem's advice) which works well when testing for an array of fixed length as below:
Code:
class class_name:
.
.
protected:
virtual void function(int n, float *const *in, float *const *out);
float *Outchan[3]; // Declare Array for 4 Channels
.
.
void class_name::function(int n, float *const *in, float *const *out)
{
int i,nofout;
for (nofout=0; nofout<num_channels;nofout++)
{OutChan[nofout] = out[nofout];} // Set number of outputs in signal vector
if (First==1)
{
ULStat = cbGetStatus (BoardNum, &Status, &CurCount, &CurIndex,AIFUNCTION);
for (nofout=0; nofout<num_channels;nofout++)
{OutChan[nofout] = 0;} // Give each channel a value in turn
}
else First=0;
}
else
{
while (n>0)
{
for (nofout=0; nofout<num_channels;nofout++) //adapt to varying channels
{
for (i=DuplicateSample;i>0;i--) //number of duplicate same sample
{
*OutChan[nofout]++ = ADData[OutCount];
}
*OutChan[nofout]++ = (ADData[OutCount++];
if (OutCount==Count) OutCount=0;
}
n=n-(DuplicateSample+1);
}
}
}
However, I can't figure out how to adapt this to work with a dynamic array.
I replaced with
Code:
float *OutChan; // in class declaration
.
OutChan= new float[num_channels]; // in the function
But the compiler returns conversion errors.
I suspect my phobia & lack of understanding of pointers are letting me down again!
Could someone please explain how I would correctly use a dynamic array here?
Thanks