Closed frantic0 closed 3 years ago
I think I found the problem.
"UnboundTypeError: Cannot call maxiFFT.process due to unbound types: N7maxiFFT8fftModesE
If you look at the error above, it say that maxiFFT.process requires an c++ enum 'fftModes' as parameter which is unbound (no embinding).
check maxiFFT.h, line 47
enum fftModes {NO_POLAR_CONVERSION = 0, WITH_POLAR_CONVERSION = 1}
I'm trying to find a solution and defining the enum as embindings but that doesn't seem to be working... need to dig a bit deeper.
Hey @chriskiefer
here's my solution. I implemented it by bounding the maxiFFT enum and creating an overload to prevent dependent code from breaking.
It's set across all layers, please check. I also found some inconsistency between methods (getMagnitudes vs getMagnitude, where is the latter?)
After all this I found what is apparently a memory leak on fft... I think we need to look at this more carefully and perform some housekeeping.
// MAXI FFT
class_<maxiFFT>("maxiFFT")
#ifdef SPN
.smart_ptr_constructor("shared_ptr<maxiFFT>", &std::make_shared<maxiFFT>)
#else
.constructor<>()
#endif
.function("setup", &maxiFFT::setup)
.function("process", select_overload<bool(float, maxiFFT::fftModes)>(&maxiFFT::process) )
.function("process", select_overload<bool(float,int)>(&maxiFFT::process))
enum_<maxiFFT::fftModes>("maxiFFT.fftModes")
.value("NO_POLAR_CONVERSION", maxiFFT::fftModes::NO_POLAR_CONVERSION)
.value("WITH_POLAR_CONVERSION", maxiFFT::fftModes::WITH_POLAR_CONVERSION)
;
bool process(float value, int fftMode=1);
bool process(float value, fftModes mode=maxiFFT::WITH_POLAR_CONVERSION);
bool maxiFFT::process(float value, int mode){
if(mode==0)
return maxiFFT::process(value, maxiFFT::fftModes::NO_POLAR_CONVERSION);
else
return maxiFFT::process(value, maxiFFT::fftModes::WITH_POLAR_CONVERSION);
}
let m = maximilian();
let fftSize = 1024;
let magMult = 6;
let wave = 0;
let playAudio = () => {
let myOsc = new m.maxiOsc();
let myOsc2 = new m.maxiOsc();
let maxiAudio = new m.maxiAudio();
let samplePlayer = new m.maxiSample();
let fft = new m.maxiFFT();
fft.setup(fftSize, 512, 256);
maxiAudio.init();
// maxiAudio.loadSample("audio/beat2.wav", samplePlayer);
maxiAudio.play = function () {
// create wave for fft
wave = myOsc.sinebuf(10000 + myOsc2.sinewave(1000)*10000);
// process wave
if (fft.process(wave, 1)) {
let mag = ""
for (var i = 0; i < fftSize / 2; i++){
mag = " " + fft.getMagnitudes()[0];
}
console.log("Mags: " + mag);
}
return wave;
}
}
Error
Uncaught abort(Cannot enlarge memory arrays to size 16781312 bytes (OOM). Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ) at Error
at jsStackTrace (http://localhost:9000/script-processor-node/build/maximilian.js:77773:17)
at stackTrace (http://localhost:9000/script-processor-node/build/maximilian.js:77790:16)
at abort (http://localhost:9000/script-processor-node/build/maximilian.js:77577:44)
at abortOnCannotGrowMemory (http://localhost:9000/script-processor-node/build/maximilian.js:83136:7)
at _emscripten_resize_heap (http://localhost:9000/script-processor-node/build/maximilian.js:83138:7)
at sbrk (http://localhost:9000/script-processor-node/build/maximilian.js:72433:8)
at dlmalloc (http://localhost:9000/script-processor-node/build/maximilian.js:70848:19)
at RealFFT_28int_2c_20float__2c_20float__2c_20float__29 (http://localhost:9000/script-processor-node/build/maximilian.js:22113:9)
at fft__calcFFT_28int_2c_20float__2c_20float__29 (http://localhost:9000/script-processor-node/build/maximilian.js:22240:3)
at maxiFFT__process_28float_2c_20maxiFFT__fftModes_29 (http://localhost:9000/script-processor-node/build/maximilian.js:21703:6)
Hi @chriskiefer
I'm trying to refactor the FFT example (20-analysis-FFT.html) in the SPN version of Maximilian (asm.js).
I'm getting an exception on the maxiFFT.process call. Do you think you could have a look to see if I'm missing something?
Here's the stack trace.