MCPcopy Create free account
hub / github.com/christophhart/HISE / prepare

Method prepare

hi_scripting/scripting/api/ScriptingApiObjects.cpp:7347–7394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7345}
7346
7347void ScriptingObjects::ScriptFFT::prepare(int powerOfTwoSize, int maxNumChannels)
7348{
7349 lastSpecs.sampleRate = 44100.0;
7350 lastSpecs.blockSize = powerOfTwoSize;
7351 lastSpecs.numChannels = maxNumChannels;
7352
7353 maxNumChannels = jlimit(1, NUM_MAX_CHANNELS, maxNumChannels);
7354
7355 if (isPowerOfTwo(powerOfTwoSize))
7356 {
7357 windowBuffer.setSize(1, powerOfTwoSize * 2);
7358 windowBuffer.clear();
7359 FloatVectorOperations::fill(windowBuffer.getWritePointer(0), 1.0f, powerOfTwoSize);
7360 FFTHelpers::applyWindow(currentWindowType, windowBuffer, false);
7361
7362 spectrumParameters->order = log2(powerOfTwoSize);
7363 spectrumParameters->Spectrum2DSize = powerOfTwoSize;
7364
7365 maxNumSamples = powerOfTwoSize;
7366
7367 Array<var> newWorkBuffer;
7368
7369 for (int i = 0; i < maxNumChannels; i++)
7370 {
7371 WorkBuffer wb;
7372 wb.chunkInput = new VariantBuffer(maxNumSamples * 2);
7373
7374 if (enableInverse)
7375 wb.chunkOutput = new VariantBuffer(maxNumSamples * 2);
7376
7377 if(magnitudeFunction || enableInverse)
7378 wb.magBuffer = new VariantBuffer(maxNumSamples);
7379
7380 if (phaseFunction || enableInverse)
7381 wb.phaseBuffer = new VariantBuffer(maxNumSamples);
7382
7383 scratchBuffers.add(std::move(wb));
7384 }
7385
7386 SimpleReadWriteLock::ScopedWriteLock sl(lock);
7387
7388 fft = new juce::dsp::FFT(log2(maxNumSamples));
7389 }
7390 else
7391 {
7392 reportScriptError("powerOfTwoSize must be ... a power of two!");
7393 }
7394}
7395
7396var ScriptingObjects::ScriptFFT::process(var dataToProcess)
7397{

Callers 1

Calls 8

jlimitFunction · 0.85
isPowerOfTwoFunction · 0.85
moveFunction · 0.85
log2Function · 0.50
setSizeMethod · 0.45
clearMethod · 0.45
getWritePointerMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected