Skip to content

Commit

Permalink
Add comments and fix tooltips for complex fft
Browse files Browse the repository at this point in the history
Also added new issue for the normalization
  • Loading branch information
RadStr committed Sep 28, 2020
1 parent 84eb951 commit 454351e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/RocnikovyProjektIFace/Drawing/FFTWindowPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public double[] getIFFTResult(boolean setImagPartToZero, int periodCount) {
// TODO: DEBUG
//ProgramTest.debugPrint("IFFT:", i, fftResult[i]);
// TODO: DEBUG
fftResult[i] *= 2 * DRAW_VALUES.length;
fftResult[i] *= 2 * DRAW_VALUES.length; // TODO: NORM
}

if(setImagPartToZero) {
Expand Down
5 changes: 5 additions & 0 deletions src/RocnikovyProjektIFace/Drawing/FFTWindowPanelAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ protected Color getBinColor(int bin) {
}



// TODO: NORM
//The normalization is quite problematic, I am still not sure what is the right way to solve it.
// Either like this where I just divide (multiply before IFFT) by 2 * windowSize or
// just divide everything except the first bin by windowSize and the 0th bin divide by 2 * windowSize.
@Override
protected double normalizeValue(double value) {
return value / (2 * DRAW_VALUES.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import RocnikovyProjektIFace.AudioPlayerPlugins.IFaces.PluginParametersAnnotation;
import RocnikovyProjektIFace.AudioPlayerPlugins.PluginJPanelBasedOnAnnotations;
import Rocnikovy_Projekt.Program;
import Rocnikovy_Projekt.ProgramTest;
import org.jtransforms.fft.DoubleFFT_1D;

import javax.swing.*;
Expand Down Expand Up @@ -126,7 +127,7 @@ public FFTWindowRealAndImagWrapper(double[] song, int windowSize, int startIndex
isEditable, backgroundColorImagPart, shouldDrawLabelsAtTop);

int binCount = Program.getBinCountRealForward(windowSize);
fftResult = new double[2 * windowSize]; // 2* because we will use complex FFT
fftResult = new double[2 * windowSize]; // 2* because we will use complex FFT
fft = new DoubleFFT_1D(windowSize);


Expand All @@ -137,10 +138,12 @@ public FFTWindowRealAndImagWrapper(double[] song, int windowSize, int startIndex
// TODO: nevim jestli je ta normalizace dobre
// TODO: DRAW PANEL THINGS
for(int i = 0; i < fftResult.length; i++) {
fftResult[i] /= binCount;
fftResult[i] /= (2 * binCount); // TODO: NORM
}
Program.separateRealAndImagPart(realPartPanel.fftWindowPartPanel.DRAW_VALUES,
imagPartPanel.fftWindowPartPanel.DRAW_VALUES, fftResult, windowSize);
realPartPanel.setDrawPanel(realPartPanel.fftWindowPartPanel);
imagPartPanel.setDrawPanel(imagPartPanel.fftWindowPartPanel);

setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(realPartPanel);
Expand Down Expand Up @@ -228,7 +231,7 @@ public double[] getIFFTResult(int periodCount) {
double[] imagPart = imagPartPanel.fftWindowPartPanel.DRAW_VALUES;
Program.connectRealAndImagPart(realPart, imagPart, fftResult);
for(int i = 0; i < fftResult.length; i++) {
fftResult[i] *= 2 * realPart.length;
fftResult[i] *= 2 * realPart.length; // TODO: NORM
}
getComplexIFFT(fftResult, fft);

Expand Down

0 comments on commit 454351e

Please sign in to comment.