sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; table-lookup oscillator for concatenated single-cycle waveforms instr 201 idur = p3 iamp = p4 ifreq = p5 ifnum = p6 inumtables = p7 ; number of concatenated 1-cycle waveforms in ifnum ilen = ftlen(ifnum) kenv linseg 0, .05, iamp, idur - .1, iamp, .05, 0 aphase phasor ifreq / inumtables asig tablei aphase*ilen, ifnum out asig*kenv endin f1 0 4096 10 1 ; pure sine - fundamental f2 0 4096 10 0 1 ; pure sine - 2nd harmonic f3 0 4096 10 0 0 1 ; pure sine - 3rd harmonic f4 0 4096 10 0 0 0 1 ; pure sine - 4th harmonic f5 0 4096 10 0 0 0 0 1 ; pure sine - 5th harmonic f6 0 4096 10 0 0 0 0 0 1 ; pure sine - 6th harmonic f7 0 4096 10 0 0 0 0 0 0 1 ; pure sine - 7th harmonic f8 0 4096 10 0 0 0 0 0 0 0 1 ; pure sine - 8th harmonic f10 0 32769 18 1 1 0 4096 2 1 4097 8192 3 1 8193 12288 4 1 12289 16384 5 1 16385 20480 6 1 20481 24576 7 1 24577 28672 8 1 28673 32768 f11 0 8192 18 1 1 0 4096 2 1 4097 8192 f12 0 8192 18 1 1 0 4096 3 1 4097 8192 f13 0 8192 18 1 1 0 4096 8 1 4097 8192 ; f2 0 4096 10 1 .50 .3333 .25 .20 .142856 .125 .1111 .10 ; saw wave approximation ; f3 0 4096 10 .50 .25 .125 .0625 .03125 .015625 .0073125 .00365625 ; "log" spectrum ; f4 0 4096 9 1 1 0 3 .3333 0 5 .2 0 7 .1429 0 9 .1111 0 ; square wave approximation ; f5 0 4096 9 3 1 0 2.8046875 1 0 3.1953125 1 0 ; an inharmonic spectrum? ; f6 0 8192 9 23 1 0 29 1 0 31 1 0 34 1 0 47 1 0 53 1 0 101 1 0 ; an inharmonic spectrum ; f7 0 128 17 0 1 16 -1 ; pulse wave 12% duty f9 0 512 -19 1 .5 270 .5 ; inverted cosine envelope f9 0 512 -19 .5 .5 270 .5 ; half-cosine interpolation env ;a0 0 40 ; uncomment to skip section 2 ;ins t dur amp freq tbl inumtables ;---------------------------------------------- i201 0 2 7500 256 1 1 i. + . . . 2 . i. . . . . 11 . i201 7 2 7500 256 1 1 i. + . . . 3 . i. . . . . 12 . i201 14 2 7500 256 1 1 i. + . . . 4 . i. . . . . 13 . e ;ins t dur amp freq tbl inumtables ;---------------------------------------------- i201 0 1 7500 256 11 1 i. + . . 512 . . i. . . . 384 . . i. . .5 . 320 . . i. . . . 288 . . i. . 4 . 256 . . e