sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 instr 210 idur = p3 iamp = p4 ifreq = p5 ienvfn = p6 ; amplitude envelope ftable iwavesweepfn = p7 ; ftable used to sweep across wavetables ilowfn = p8 ; lowest ftable wave ihighfn = p9 ; highest ftable wave kenv oscil1i 0, 1.0, idur, ienvfn kswpenv oscil1i 0, 1.0, idur, iwavesweepfn ; wavetable sweep envelope ; calculate current table pair and interpolation amount inumtables = ihighfn - ilowfn ; 1 less than number of tables kfn1 = int(kswpenv*inumtables) + ilowfn kfn2 = kfn1 + 1 kinterp = frac(kswpenv*inumtables) ; read tables with phasor ixmode = 1 ; normalized index aphase phasor ifreq asig tableikt aphase, kfn1, ixmode if kswpenv == 1.0 kgoto skipfn2 ; if kfn1 is last table, there is no kfn2 asig2 tableikt aphase, kfn2, ixmode skipfn2: ; interpolate between tables and output amix ntrpol asig, asig2, kinterp out amix*kenv*iamp endin