Skip to content

Commit

Permalink
Update BasicFFTProcessor.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Seank23 committed Jan 29, 2022
1 parent bba3165 commit adab06e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion MusicAnalyser/App/DSP/Scripts/BasicFFTProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public void Process()
if(InputArgs["SAMPLE_RATE"].GetType().Name == "Int32")
sampleRate = (int)InputArgs["SAMPLE_RATE"];
}
float pitchFactor = 1;
if (InputArgs.ContainsKey("PITCH_FACTOR"))
{
if (InputArgs["PITCH_FACTOR"].GetType().Name == "Single")
pitchFactor = (float)InputArgs["PITCH_FACTOR"];
}

int fftPoints = 2;
while (fftPoints * 2 <= input.Length) // Sets fftPoints to largest multiple of 2 in BUFFERSIZE
Expand Down Expand Up @@ -93,7 +99,7 @@ public void Process()
output[i] = Math.Pow(output[i], 2) / 100;
}
OutputBuffer = output;
double scale = (double)fftPoints / sampleRate;
double scale = fftPoints / sampleRate / pitchFactor;
OutputArgs.Add("SCALE", scale);
}
}
Expand Down

0 comments on commit adab06e

Please sign in to comment.