Parameters

I am new to csound, and am running csound 4.32f12 on my Debian
sarge home system. I have got to the point where I can make simple
tunes with a .sco file, using a simple and standard .orc file.
I have two questions:

1. in my .orc file, I have the line
kctrl line 5000, p3, 3000 ; amplitude envelope
which I sort of understand . . . except for the kctrl word. I have
grepped in the manual for ctrl and find setctrl, ctrl14, ctrl21, etc,
but no simple ctrl.

2. In my various .sco files, I have to keep inserting pitches, like
440(A), 660(E), etc. For present, and especially for later work
(e.g. dividing the octave into, say, 15 equal tones), I'd like to
make a table so that I can access these tones by number. There
are builtin codes, e.g. cpspch, to do this; but I want to create
my own. Can this be done, and if so, how?

Many thanks in advance for assistance!

Alan McConnell

Re: Parameters

Alan,

Welcome to Csound! Some answers to your questions:

1. "kctrl" is an arbitrary variable name that creates a storage location where Csound puts the output of the "line" opcode. You could just as easily call it "kMyLine" or "kAlan" or anything that begins with "k". Csound has several different types of variables and each type has names beginning with a different letter (a, k, i, p, f, S, etc.)

Generally, most opcodes have one or more input and output parameters. These parameters are given names in the manual but those names are arbitrary and you can use different names. In fact, you may have to use different names if you use the same opcode more than once and need to distinguish between their outputs. Here is a simple instrument example using the oscil opcode:


instr 1

; First create some constants - the frequency value (p4)
; comes from the score.
; I chose these names to be clear and meaningful to me.

ifrequency = p4
iamplitude = 5000
itableNum = 1

; Now we create two oscillators -
; the second one has a frequency twice the first.
; Note that they output to two different variables:
; aosc1 and aosc2

aosc1 oscil iamplitude, ifrequency, itableNum
aosc2 oscil iamplitude, ifrequency * 2, itableNum

; Now, output the sum of the two oscillators.

out aosc1 + aosc2

endin

2. Csound has some other tuning opcodes that are more flexible than cpspch. Check out "cps2pch" for equal divisions of the octave other than 12, and "cpstuni" or "cpsxpch" for arbitrary microtonal scales. These latter two can use lookup tables created with the GEN 02 routine.

I hope that this helps. If you need more assistance, please feel free to ask. The Csound mailing list is a good place to get quick help from many people. Just click on "Community" link here on the top of the cSounds.com page for information on how to join.

Anthony

Parameters

Thanks to Anthony Kozar for his quick and illuminating reply!

1. I now understand about kctrl.

2. I shall look at Anthony's tips about the various "ps2pch"-type
routines. Ideally I would like to be able to set e.g a variable
"pitch1" to 440, and be able to write tunes with pitch1, pitch2,
etc, rather than 440, 495, 550, etc. In particular, I'd like to
write "tunes" with _accurate_ pitches; staying away from tempered
tunings.

Again thanks; and I hope I'm using this list properly!

Alan McConnell
classical musician and Linux user

Hi Alan, You may want to

Hi Alan,

You may want to take a look at cps2pch, cpsxpch, cpstun, and cpstuni opcodes.

Cheers!
steven