René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

cpsoct (Csound opcode)

Converts a octave point decimal number into a cycles per second number.
The following example plays a chromatic tune.
sr = 44100
kr = 4410
nchnls = 1

instr 1
  ilen = p3
  iamp = p4
  ifrq = cpsoct(p5)

  print ifrq

  kenv linen iamp, 0.02, ilen, 0.04
  
  asig oscili kenv, ifrq, 1

       out asig
endin
f1 0 1024 10 1

i1   0    0.4  10000  7.0000
i1   0.4  0.4      .  7.0833
i1   0.8  0.4      .  7.1667
i1   1.2  0.4      .  7.2500
i1   1.6  0.4      .  7.3333
i1   2.0  0.4      .  7.4167
i1   2.4  0.4      .  7.5000
i1   2.8  0.4      .  7.5833
i1   3.2  0.4      .  7.6667
i1   3.6  0.4      .  7.7500
i1   4.0  0.4      .  7.8333
i1   4.4  0.4      .  7.9167
i1   4.8  0.4      .  8.0000

e