I try to rebuild my FFT project to class and I stuck at the passing objects buff as parameter to my functions.
In case where I alloc buffs using varSetCapacity(buf,bytes,0) then I can use tst(buf), however the same thing but using this.setCapacity("buf",bytes) and then tst(this.buf) just fail. I know I can fix it by passing pointer but it will require to edit most of my functions that I need to share with other projects.
Code: Select all
class _FFT
{
buf := ""
bufPtr := 0
binsN := 0
__new(){
}
resize(binsN){
if(binsN>this.binsN){
this.binsN := binsN
bytes := binsN*2*8 ; binsN*CPLXsize*dataSize
this.setCapacity("buf",bytes*2) ; 2 buffs at once
this.bufPtr := this.getAddress("buf")
}
}
fill(){
loop,% this.binsN*4
numPut(A_Index,this.bufPtr+0,(A_Index-1)*8,"double")
}
feedPtr(inputPtr,binsN){
this.resize(binsN)
this.fill()
tst(this.buf) ; <----- it fails to pass buf
}
}
tst(byref buf){
str := ""
loop, 10
str .= numget(buf,(A_Index-1)*8,"double") "`n"
msgbox,% str ; it should display numbers from 1 to 10
}