| First of all, I would like to thank everybody who joined this thread.
I've learned a lot and I can now see that there is still a lot more to
learn.
I have been pondering over this problem a bit and I even made the
daring attempt to write a CSound orc/sco 'program' in a structured
way. I know that 'structured' and 'object-oriented' are not the same,
but I think that the step from CSound to OO must enivetably go via
something structured.
I took the Toot4 example from Richard Boulanger's "An Instrument
Design Tutorial", because it's simple and straightforward, and there
is something in there that could perhaps be re-used (the chorus).
I hope the structured version is clear enough, I took the liberty of
inventing a couple of new typedefs (audio, control, ftab), and I added
to the out () function 2 parameters: start and duration.
//
// instr 4 ; toot4.orc
// iamp = ampdb(p4) ; convert decibels to linear amp
// iscale = iamp * .333 ; scale the amp at initialization
// inote = cpspch(p5) ; convert "octave.pitch" to cps
// k1 linen iscale, p6, p3, p7 ; p4=amp
// a3 oscil k1, inote*.996, 1 ; p5=freq
// a2 oscil k1, inote*1.004, 1 ; p6=attack time
// a1 oscil k1, inote, 1 ; p7=release time
// a1 = a1 + a2 + a3
// out a1
// endin
//
// f1 0 4096 10 1 ; sine wave
//;instr start dur amp(p4) freq(p5) attack(p6) rel(p7)
// i4 0 1 75 8.04 .1 .7
// ...
//e
//Now in C-style CSound
ftab ftSine;
audio Chorus (control cSignal,
audio a1,
float fFreq)
{
float fNote = cpspch (fFreq);
audio a1 = oscil (cSignal, fNote, ftSine);
audio a2 = oscil (cSignal, fNote * .996, ftSine);
audio a3 = oscil (cSignal, fNote * 1.004, ftSine);
return (a1 + a2 + a3);
}
void Toot4 (float fStart,
float fDuration,
float fAmp,
float fFreq,
float fAttack,
float fRelease)
{
float fDb = ampdb (fAmp);
float fScale = fDb * .333;
control cEnvelope = linen (fScale, fAttack, fDuration, fRelease);
out (fStart, fDuration, Chorus (cEnvelope, fFreq));
}
main ()
{
InitCSound (16000, 1000, 1);
ftSine = gen (0, 4096, 10, 1);
Toot4 (0, 1, 75, 8.04, .1, .7);
...
}
---jpff@maths.bath.ac.uk wrote:
>
> Message written at 17 Sep 1998 17:52:39 +0100
> --- Copy of mail to zuijlen@ibm.net ---
>
> The score language in Csound has evolved a little, with repeat
> sections, overlapping sections, and so on. If this is insufficient
> for a particular use I usually find the a C program is my next step.
> Flexible and adjustable and readily available on all my machines.
> ==John ffitch
>
==
Koen Dejonghe
QAD Service Line
Origin International Competences & Alliances
http://www.origin-it.com
+32 2 712 3668
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com |