kr — Sets the control rate.
These statements are global value assignments, made at the beginning of an orchestra, before any instrument block is defined. Their function is to set certain reserved symbol variables that are required for performance. Once set, these reserved symbols can be used in expressions anywhere in the orchestra.
kr = (optional) -- set control rate to iarg samples per second. The default value is 4410.
In addition, any global variable can be initialized by an init-time assignment anywhere before the first instr statement All of the above assignments are run as instrument 0 (i-pass only) at the start of real performance.
Beginning with Csound version 3.46, kr can be omitted. Csound will use the default values, or calculate kr from defined ksmps and sr It is usually better to just specify ksmps and sr and let csound calculate kr.
Here is an example of the kr opcode. Play kr.csd
Example 494. Example of the kr 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 -odac ;; -iadc ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o kr_example.wav -W ;;; for file output any platform ; By Stefano Cucchi 2020 </CsOptions> <CsInstruments> sr = 44100 kr = 4410 ; NO glitch ;kr = 10 ; Some GLITCH in kFreqMod ;kr = 2 ; Lots of GLITCH in kFreqMod nchnls = 1 0dbfs = 1 instr 1 kenvelopemod linseg 0, 2, p4, p3-4, p4, 2, 0 kFreqMod expseg 200, p3, 800 amodulator oscil kenvelopemod, kFreqMod, 2 acarf phasor 440 ifn = 1 ixmode = 1 ixoff = 0 iwrap = 1 acarrier tablei acarf+amodulator, ifn, ixmode, ixoff, iwrap kgenenvelop linseg 0, 0.5, 0.3, p3-1, 0.3, 0.5, 0 out acarrier * kgenenvelop endin </CsInstruments> <CsScore> f1 0 4096 10 1 f2 0 4096 10 1 0.3 0.5 0.24 0.56 0.367 i1 0 5 0.2 e </CsScore> </CsoundSynthesizer>