asfft and w3d
Posted by: defboyuk ()
Date: January 30, 2008 07:42PM

Hi

I am building a simple test app that takes asfft and uses microphone input to adjust the size of a w3d object.

im getting an object expected script error

ive got two scripts one to do and one to react

do_asfft:

property gFFT, gBins
global values

on beginSprite
-- creates xtra instance and checks it worked
gFFT = new(Xtra "asFFT"winking smiley
if not objectp(gFFT) then put "error : 'new' failed"

-- sets the number of bins/ frequencies you want (must be power of 2)
-- can be between 2 and 256, 8 works well, any lower and its not very accurate
-- try using setParams(gBins, 4) if you want it to be more accurate, but cost in processing time
gBins = 32
err = gFFT.setParams(gBins)
if err = 0 then put "error init:" & gFFT.getError()
end

on enterFrame
if objectp(gFFT) then

-- get mic data, returns an array/ list. values.count will = gBins
-- 100 is the number that full volume will be- i used 100 as 100%
-- but you can use any number even 11 like spinal taps amp!
--
-- true, false means normalised, unequalised. normalised sound will show volume
-- otherwise it will only show frequency- the equaliser makes mine crash!
values = gFFT.getFFT(100, TRUE, FALSE)
if values = 0 then put "error reading:"&gFFT.getError()

--put values
-- dumps out global var values, tab this out and it can still be used

--put values

-- from elsewhere, read the list using:
--
-- global values
-- repeat with i = 1 to values.count
-- put values[i]
-- end repeat

end if

end

do_react:

property n, spritenum, s

global values

on beginsprite

s = sprite( spritenum )

n = random( 32 )

end

on enterframe

member("test"winking smiley.model("test"winking smiley.transform.scale=vector(2,5,3) * values[1]

end


can anyone see my problem???

Sorry, only registered users may post in this forum.
This forum powered by Phorum.