back to list

To Mr Alves Just and C sound

🔗patrick pagano <ppagano@xxxxxxxxx.xxxx>

7/13/1999 11:32:43 AM

Dear Bill began fiddling with the table for Cps2

does this look correct and can you lucidify the table idea for me a bit
Thanks Pat
;just intonation C sound Instrument
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
zakinit 50, 50

instr 101
ioutch = p5 ; Output channel
ipanl = sqrt(p6) ; Pan left
ipanr = sqrt(1-p6) ; Pan right
k1 linen 5000,03,p3,.5
aamp linseg 0, .002, 1, p3-.004, 1, .002, 0 ; Declick envelope
ifreg cps2pch p4,-1 ; refer to multiplier table #1
asound oscili k1,ifreg,1
aout = asound*aamp
outs aout*ipanl, aout*ipanr ; Output stereo
zawm aout, ioutch ; Mix to the Zak channel
outs asound*aamp,asound*aamp
endin
;sco
;table # start size gen fn C C# D Eb
etc.
f 1 0 16 -2 1.000000 1.066667 1.125000
1.200000
1.250000 1.333333 1.440000 1.500000 1.600000 1.666667
1.750000
1.875000

; inst start duration pitch out
i 101 0 3 8.00 1 0
i 101 3 3 8.07 2 1
i 101 6 3 8.10 1 0
i 101 9 3 8.11 1 1
i 101 12 3 8.03 2 0
; Sta Dur Amp TimL FdbkL XFdbkL TimR FdbkR XFdbkR InChL InChR
i15 0 15 .5 3 .4 .5 3 0.4 .6 1 2

; Clear Zak
; Sta Dur
i99 0 15

🔗alves@xxxxx.xx.xxx.xxxxxxxxxxxxxxx)

7/16/1999 10:13:25 AM

>From: patrick pagano <ppagano@bellsouth.net>
>
>Dear Bill began fiddling with the table for Cps2
>
>does this look correct and can you lucidify the table idea for me a bit
>Thanks Pat

Pat,

Here's how I'd do it:

sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

instr 101
; p3 = duration
; p4 = loudness
; p5 = pitch
; p6 = pan
ipanl = sqrt(p6) ; Pan left
ipanr = sqrt(1-p6) ; Pan right
imax = 5000 ; max amplitude
ifreq cps2pch p5,-1 ; refer to multiplier table #1
aamp linseg 0, .002, p4, p3-.004, p4, .002, 0 ; envelope
aout oscili aamp*imax,ifreq,2 ; simple oscillator
outs aout*ipanl, aout*ipanr ; Output stereo
endin

;sco
;table # start size gen fn C C# D Eb etc.
f 1 0 16 -2 1.000000 1.066667 1.125000 1.200000
1.250000 1.333333 1.440000 1.500000 1.600000 1.666667 1.750000
1.875000
f 2 0 8192 10 1

; inst start dur loud pitch pan
i 101 0 3 1 8.00 0
i 101 3 3 1 8.07 1
i 101 6 3 1 8.10 0
i 101 9 3 1 8.11 1
i 101 12 3 1 8.03 0

e

First, I simplified this example by not using zak, which is not really
necessary here anyway. I changed the p-variables around because, while
still a matter of personal taste, it is more "standard" to use p4 for
loudness and p5 for pitch. I simplified the calculation of amplitude, which
depends on four things: the envelope, p4, the maximum amplitude allowed in
the instrument (assuming 0<=p4<=1), and the pan for each channel. These
just need to be multiplied together at some point.

You were also using the tuning table as the waveform (the last parameter in
the oscili statement), which does make a nice buzzy sound, but I inserted a
new function table (#2) with a sine wave in it for the oscillator. For
those of you following along, a point of clarification: the parameters in
the tuning table (#1) are the decimal equivalents of the just ratios of
your tuning system.

The way cps2pch then works is that it is given a pitch representation where
the number to the left of the decimal point is the octave and the two
numbers to the right of the decimal point are the step number, from 00 to
however many steps there are minus 1. If the second parameter is negative,
then it takes the 440 12TET tuning for C (261.6 hz) of the specified octave
and multiplies it by the corresponding entry in the table whose number is
the absolute value of the second parameter.

For example, let's take the second note above: 8.07. C of the 8th octave
(in Csound terms) is 261.6 hz. Through the p5 variable, this note is passed
to the statement ifreq cps2pch p5,-1. The -1 tells cps2pch to look up the
pitch class in function table #1. The pitch class or step number is 7.
Counting from zero, that corresponds to table entry 1.5. So, cps2pch
returns 261.6*1.5 or 392.4 and puts it in the init-time variable ifreq.

If you don't want 261.6 as your 1/1, there are several things you can do.
First, you could change your table entries so that another pitch was 1/1
and the ratios before it were less than 1. For example, this table:

;table # start size gen fn C C# D Eb etc.
f 1 0 16 -2 0.888889 .9481484 1.000000 1.066667
1.111111 1.185185 1.280000 1.333333 1.422222 1.481482 1.555556
1.666667

would produce the same scale, but with 1/1 transposed to D (9/8 above 261.6
hz). It might be easier to just insert something like the following
statement into your orchestra:

ifreq = ifreq*8/9 ; transpose 1/1 to D

I often use a global variable to set the pitch reference, so that it can be
used in all instruments and even changed during the course of the piece if
I want to modulate.

The above score and orchestra does render a sound file with the correct
pitches on my machine. However, be careful about at least one thing when
pasting the above code into your word processor. If some of the longer
lines wrapped over and your email program put in hard carriage returns
where they did, Csound will think a new line has started and evaluate it as
a Csound statement, so be sure to take out those extra returns.

I hope this helps. Let me know if I'm unclear about anything.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^ Bill Alves email: alves@hmc.edu ^
^ Harvey Mudd College URL: http://www2.hmc.edu/~alves/ ^
^ 301 E. Twelfth St. (909)607-4170 (office) ^
^ Claremont CA 91711 USA (909)607-7600 (fax) ^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^