; pitch - as usual ; dist - beginning amount of distortion, 1 = 100%, 0 = 0% ; table - table to distort ; phase-offset - to adjust table so that it starts on a peak value ; e.g. *tri-table* is fine at 0, ; *sine-table* could use values such as 90, -90 ; View the resulting wave in an editor to see what I mean ; If you use the "wrong" value you will get different harmonic content define function pd-note(pitch, dur, dist, table, phase-offset) begin if dist > 1.0 then set dist = 1.0 else if dist < 0.0 then set dist = 0.0 set freq = step-to-hz(pitch) set inc = 1 / freq set dinc = (dist / (dur / inc)) / 2.0 loop for i from 0 to dur by inc set b1 = 1.0 - dist set b2 = dist set f1 = #? (b1 = 0.0, 0.0, freq / b1) / 2.0 set f2 = #? (b2 = 0.0, 0.0, freq / b2) / 2.0 set d1 = b1 / freq set d2 = b2 / freq set p1 = hz-to-step(f1) set p2 = hz-to-step(f2) set a = osc(p1, d1, table, phase-offset) set b = osc(p2, d2, table, phase-offset + 180) if ! boundp(quote(x)) then set x = seq(a,b) else set x = seq(x,a,b) exec snd-play(x) set dist -= dinc end if ! boundp(quote(x)) then set x = seq() return x end ; Distort triangle into saw ;play pd-note(c3, 3.0, 1.0, *tri-table*,0) ; Distort sine into pseudo-saw ;play pd-note(c3, 3.0, 1.0, *sine-table*,-90)