SciChartÂ® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

Hello.

I’m trying to modifying Audio Analyzer Example.

This is scenario.

2. Calculate FFT (for all sample data of wav file)
3. Display FFT result to FFT & Spectrogram chart.

The point is this : read all data at once and calulate FFT for dispaly in chart.

I already have FFT result with re[] and im[] type arrays.

1. When I setting up X,Y axis of FFT chart, following code applied.
Q. x,y axis and value setup is correct?

``````            // prepare fft input (dataF is float type sample data of wav file)
double[] re = new double[dataF.length];
double[] im = new double[dataF.length];
double[] mag = new double[dataF.length];
for(int ii=0; ii<dataF.length; ii++) {
re[ii] = (double)dataF[ii];
im[ii] = 0.0d;
}

FFTf.transform(re, im);  // using Bluestein DFT algorithm.

for(int nn=0; nn < re.length; nn++) {
mag[nn] = Math.sqrt(re[nn] * re[nn] + im[nn] * im[nn]);
if(nn <= 10 || re.length - 10 <= nn)
}

// setup fft and x,y values
for(int l=0; l < re.length/20; l++) {
fftDS.append((1.0*l*sampleRate/re.length), Math.sqrt(re[l] * re[l] + im[l] * im[l]));
}
``````
2. When I setting up X,Y axis of Spectrogram chart, following code applied.
Q. x,y axis and value setup is correct?

``````            fftCount = dataProvider.getAudioDataByteSize() / 4096;
spectrogramDS = new UniformHeatmapDataSeries<>(Long.class, Long.class, Double.class, re.length/20, fftCount);
fftOffsetValueCount = (re.length/20)*fftCount - (re.length/20);
spectrogramValues = new DoubleValues((re.length/20)*fftCount);
spectrogramValues.setSize((re.length/20)*fftCount);

// update spectrogram chart data
for(int jj=0; jj < fftCount; jj += 4096) {
double[] spectrogramItems = spectrogramValues.getItemsArray();
double[] fftItems = getFrom(mag, 4096, jj);

System.arraycopy(spectrogramItems, re.length/20, spectrogramItems, 0, fftOffsetValueCount);
System.arraycopy(fftItems, 0, spectrogramItems, fftOffsetValueCount, re.length/20);

spectrogramDS.updateZValues(spectrogramValues);
}
``````

FFT chart is working but Spectrogram is not.

Version
3.1.0.4412
• You must to post comments
0
0

Hi there,

I’m not 100% sure that it’s correct because you didn’t provide all code, but assuming that FFT data is correct and point count is correct as well I think that data series update code seems to be correct.

Best regards,
Yura

• You must to post comments
Showing 1 result