# This script generates a series of gated sounds # The part of the sound gated "out" is replace by # a 500 Hz square wave, so that all sounds have the same # value form: "Gating" word: "name", "chain" positive: "initialGate_(in_s)", "0.8" positive: "numberOfGates", "10" endform selectObject: "Sound " + name$ sf = Get sampling frequency ft = Get finishing time am = Get absolute extremum: 0, 0, "None" am = am/2 durGate = ft - initialGate #Create square-wave Create Sound: "squareWave", 0, ft, sf, "am*sin(2*pi*500*x)" Formula: "if self > 0 then am else self fi" Formula: "if self <=0 then -1*am else self fi" for i from 0 to numberOfGates splice_point = initialGate + durGate * (i/10) rest = ft - splice_point selectObject: "Sound " + name$ #extract part and apply fade-out thisGate = Extract part: 0, splice_point, "Rectangular", 1, "no" selectObject: "Sound squareWave" thisSquare = Extract part: 0, rest, "Rectangular", 1, "no" #splice together selectObject: thisGate if i < 10 plusObject: thisSquare Concatenate with overlap: 0.005 Rename: "gate_" + fixed$(i,0) else Copy: "gate_10" endif #clean up selectObject: thisGate plusObject: thisSquare Remove endfor