Hi,
I'm using object orientating to make an audio plug in. This reads in the audio file as an array. I'm trying to display the mean of the array to the console window using getters and setters.
I have a Mean function in my class.cpp file which is:
Code:
double AudioFile::Mean()
{
if (inputSIG != NULL)
{
double sum = 0, mean;
for (int i = 0; i < numSamples; i++)
{
//sum = last values sum + next value in array
sum = sum + inputSIG[i];
}
mean = sum / (float)numSamples;
return mean;
}
}
I have mean established in my private variables in the class header file.
Code:
private:
double mean;
and it's set to 0 (so its empty and can be filled in when the array in read in with the sound file) in the class source file like this:
Code:
AudioFile::AudioFile()
{
mean=0;
}
How should I go about displaying the calculated mean? How would I apply getters and setters?
I think it would be something like this:
Code:
//in header file
double getmean() {return mean;}
void setmean (mean) {mean}
//in main
audio.Mean();
audio.setmean(mean);
cout << audio.getmean << endl;
I hope this makes sense. I'm basically calculating the mean within a function in a class and trying to get that mean/set an empty mean variable to be that value so I can print it out.
Thanks for any help.