Generates a set of impulses of amplitude kamp at frequency kfreq. The first impulse is after a delay of ioffset seconds. The value of kfreq is read only after an impulse, so it is the interval to the next impulse at the time of an impulse.
ioffset (optional, default=0) -- the delay before the first impulse. If it is negative, the value is taken as the number of samples, otherwise it is in seconds. Default is zero.
kamp -- amplitude of the impulses generated
kfreq -- frequency of the impulse train
After the initial delay, an impulse of kamp amplitude is generated as a single sample. Immediately after generating the impulse, the time of the next one is calculated. If kfreq is zero, there is an infinite wait to the next impulse. If kfreq is negative, the frequency is counted in samples rather than seconds.
Here is an example of the mpulse opcode. It uses the files mpulse.orc and mpulse.sco.
Example 234. Example of the mpulse opcode.
/* mpulse.orc */ ; Initialize the global variables. sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; Instrument #1. instr 1 ; Generate an impulse every 1/10th of a second. kamp = 30000 kfreq = 0.1 a1 mpulse kamp, kfreq out a1 endin /* mpulse.orc */
/* mpulse.sco */ ; Play Instrument #1 for one second. i 1 0 1 e /* mpulse.sco */