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

cpspch (Csound opcode)

... yet to be finished ...
The highest tone on a piano (the C) plays on a frequency of 4186 Hertz. This tone is specified as 12.00 in pch notation. cpspch(12.00) returns 4186. 440 hertz is produced with cpspch(8.09).
cpspch.orc
sr     = 44100
kr     = 4410
nchnls = 2

instr 1

  i_frq = cpspch(p4)

  print i_frq

endin
cpspch.sco
i1  0   1    0.09
i1  +   1    1.09
i1  +   1    2.09
i1  +   1    3.09
i1  +   1    4.09
i1  +   1    5.09
i1  +   1    6.09
i1  +   1    7.09
i1  +   1    8.09
i1  +   1    9.09
i1  +   1   10.09
i1  +   1   11.09
The (for better readability) truncated output is:
instr 1:  i_frq = 3.438
instr 1:  i_frq = 6.874
instr 1:  i_frq = 13.749
instr 1:  i_frq = 27.500
instr 1:  i_frq = 55.000
instr 1:  i_frq = 110.000
instr 1:  i_frq = 220.000
instr 1:  i_frq = 440.000
instr 1:  i_frq = 880.000
instr 1:  i_frq = 1760.000
instr 1:  i_frq = 3520.000
So, a 440hz tone is achieved with cpspch(7.09).