Reply To: SA-API

Forums SA Series Discussions SA-API Reply To: SA-API

#156218
AndrewAndrew
Moderator

Hello Raja,

Here is the code for finding the peak frequency in C.

In the code below, you will already have sweepSize, binSize, and startFreq from the API, and you will have the sweepMaxArray from the get sweep API function. This should be easy to convert to Visual Basic.

double peak = -2000.0; // Small initial value
int peakIndex = -1;
for(int i = 0; i < sweepSize; i++) { if(sweepMaxArray[i] > peak) {
peak = sweepMaxArray[i];
peakIndex = i;
}
}

double peakFrequency = startFreq + binSize * peakIndex;
double peakAmp = peak;

Regards