Can someone please explain the difference between a, k, i, and g?
Csounds.com |
|
Support Csounds.comJoin with these Generous Csounders and make a donation to help Csounds.com keep going and growing. Thanks so much!
Another way to help is by purchasing a copy of The Csound Instrument Catalog. User loginPodcast
latest entries:
- browse all the entries - browse by tag - feed URL ![]() - Instructions for listening and submitting your own tracks Recent blog postsSearch |
re: a k i g
k-rate variables are control rate variables. Each time an instrument is run, it reads through the code at ksmps intervals. ksmps is defined in the header as a number of samples. So if ksmps = 32, Csound runs a pass through the code every 32 samples. k-rate variables are then updated at each pass. This is commonly referred to as the "k-pass." If it doesn't need sample accuracy, then you should use a k-rate variable as it is easier on the cpu.
a-rate variables are used for audio. Technically, they are vectors (or arrays) of numbers that are ksmps long. The index of the vector is traversed at the sampling rate (sr), and the vectors are updated at each k-pass. But it's generally just easier to think of them as audio rate variables.
i-rate variables are initialization variables. When an instrument is called, it first does an initialization pass, or i-pass. This is when the i-rate variables are set, and they act as constants. After this the k-passes begin.
g variables are global variables, and they can be i-, k-, or a-rate. These variables are declared in the header and can be accessed by any instrument.
You can read more about them here:
http://www.csounds.com/journal/issue10/CsoundRates.html