lingo

 

Below are the basic Lingo scripts for generating the sine frequency Shockwave movie.

 

 

 

-- CPS PART

 

global FREQUENCY, AMPLITUDE

on startMovie me
listOfXtras = the xtraList
set stop = true
repeat with currentXtra in listOfXtras
if currentXtra.name contains "cpsdirector" then stop = false
end repeat
if stop then halt
CPSxtra("cleanAll")
set audioOut0 to CPSgetObject("audioOut")
set sinus1 to CPSgetObject("sinus")
set multiply2 to CPSgetObject("*")
CPSOBJConversate(multiply2,"_UP")
CPSOBJConversate(multiply2,"_UP")
CPSOBJConversate(multiply2,"_UP")
set FREQUENCY to CPSgetObject("fader")
set AMPLITUDE to CPSgetObject("fader")
CPSgetConnection(FREQUENCY,40,sinus1,20)
CPSgetConnection(AMPLITUDE,40,multiply2,20)
CPSgetConnection(multiply2,30,audioOut0,11)
CPSgetConnection(multiply2,30,audioOut0,10)
CPSgetConnection(sinus1,30,multiply2,10)
CPSOBJkin(FREQUENCY,2010.0,0)
CPSOBJkin(AMPLITUDE,0.08,0)
CPSstartAudio()
end

on stopMovie
cpsStopAudio()
end

 

--DRAW SINUS

 

global theVISUALFREQ, theVISUALAMP

on exitFrame me
visualFreq = theVISUALFREQ * 100
visulaAMP = integer(theVISUALAMP * 100)
if visualFreq < 1 then
visualFreq = 1
else
visualFreq = visualFreq
end if
mem = sprite(me.spriteNum).member
list = []
repeat with x = -100*pi() to 100*pi()
y = sin(float(x)/visualFreq)* visulaAMP
add list, [#vertex: point(x,y)]
end repeat
mem.vertexList = list
end

 

 

--SLIDER-FREQUENCY

 

global FREQUENCY, theVISUALFREQ
property sp
property y, xMin, xMax
property dragging
property offx
property pCPSVar

on beginsprite(me)
sp = sprite(me.spritenum)
spLine = sprite(me.spritenum - 1)
y = sp.locv --
xMin = spLine.left -- set x & y constraints
xMax = spLine.right --
sprite(me.spriteNum).color = rgb("808080")
end
on mousedown()
offx = (the mouseh) - sp.loch
dragging = true
end
on mouseup()
dragging = false
end

on mouseupOutside()
dragging = false
end
on exitframe()
if dragging then
sp.loch = (the mouseh) - offx
end if
sp.locv = y --
if sp.loch > xMax then sp.loch = xMax -- enforce constraints
if sp.loch < xMin then sp.loch = xMin --
theFREQ = (sp.loch - xMin) / float(xMax - xMin) -- max/min opposite for reverse
theVISUALFREQ = (sp.loch - xMax) / float(xMin - xMax)
CPSOBJkin(FREQUENCY,float(theFREQ)*10000,0)
end

on mouseEnter me
sprite(me.spriteNum).color = rgb("FF0000")
end
on mouseLeave me
sprite(me.spriteNum).color = rgb("808080")
end

 

 

 

 

Top^

 

 

©sonicspace.org 2005