Skip to content

cosr

Calculates a cosine value based on the current time (now)

Syntax

ival cosr iperiod [, icinit], [imchannel]
ival = cosr(iperiod [, icinit], [imchannel])

Usage

cosr calculates the cosine of now. This is useful as a kind of i-rate oscillator, providing cyclical values with each evaluation. cosr is adapted from the cosr macro in the [impromptu](https://en.wikipedia.org/wiki/Impromptu_(programming_environment) live coding environment.


Outputs and arguments

ival -- The output value.

iperiod -- Time in beats for the cosine to complete a cycle.

iamp (optional, default=0.5) -- amplitude of the cosine. Range is between +iamp to -iamp.

ioffset (optional, default=0.5) -- offset added to the output values.

Example

See the example for loopevent.orc

cosr
instr Sound101
  ;; Sound source

  ares vco2 p4,p5
  kfr transeg 8000, 0.2, -5, p5*4, p3-0.4, 2, p5
  ares moogladder2 ares,kfr/(cosr(12, 5, 5.5)),0.6
send ares
endin

patchsig "Sound101", "outs"
;; connect sound to output.

loopevent fillarray_i(n("Sound101"),0,-1/9,0.5,0), fillarray_i(2,4,6,5,4,5,8,9) - 14, fillarray_i(1/12),1
;; A flamboyant run.