Adding Comments to Your Code

It’s always a good idea to add comments to your code while you’re developing a piece in Csound (or a program in any other programming language, for that matter). Comments will be ignored by the Csound compiler. Comments are useful first and foremost because you may open up a file two years from now and have no memory of what your code does. Comments will also be immensely useful if your code is read by someone else. For a good example of how helpful copious comments can be, go to CsoundQt’s Examples menu, look in the Music submenu, and open up “Kung-Xanadu.” (This piece also provides an inspiring example of a few of the sound colors you can create with Csound.)

Csound provides three ways to add comments. First, anything on a line that follows a semicolon is a comment. This is the original format for Csound comments:


  instr 1; a plucked FM sound
  ; first, read the p-fields into the instrument:
  idur = p3
  iamp = p4
  ; etc....

Here, Csound will “see” the symbols instr 1—they’re active code. But the rest of the line, ; a plucked FM sound, is strictly for the benefit of anyone who happens to be reading the code. Likewise, the lines with idur and iamp will be read by the Csound compiler, but the lines immediately above and below them are comments and will be ignored.

More recently, a comment syntax borrowed from the C programming language has been added to Csound. If you want to type a longish block of text and not have to put a semicolon at the beginning of every line, you can start and end your comment text like this:


  /*
  This is also a comment.
  */

The symbol /* starts the comment, and the symbol */ ends it.

Finally, anything you type into your file before the <CsoundSynthesizer> tag or after the </CsoundSynthesizer> ending tag will be ignored by Csound.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.223.168