mpulse

mpulse — Generates a set of impulses.

Description

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.

Syntax

ares mpulse kamp, kfreq [, ioffset]

Initialization

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.

Performance

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.

Examples

Here is an example of the mpulse opcode. It uses the file mpulse.csd.

Example 240. Example of the mpulse opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o mpulse.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; 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


</CsInstruments>
<CsScore>

; Play Instrument #1 for one second.
i 1 0 1
e


</CsScore>
</CsoundSynthesizer>

          

Credits

Example written by Kevin Conder.