From: =?ISO-8859-1?Q?Miguel_Agustín_Mesa_Pérez? ()
Date: Apr 29, 2005
Subject:
Problem with instrument control
Hi, I'm using csound to simulate some birds singing around. The main
idea is to have an instrument that controlls when to call another
instrument in order to make it sound like a bird. I use a random
function to decide whether a bird sings or not.
But my problem is that csound doesn't seem to respect what I've programmed.
And also, it calls the instrument number 10 (the bird) in spite of I
don't call it yet (at the very first time). And consequently, it sends
a windows error "the app doesn't respond"
I would appreciate so much your help!
The code (reduced) looks like this:
/*ORC FILE*/
sr =3D 48000
kr =3D 1
ksmps =3D 48000
nchnls =09=3D 12
/* VARIABLES */
gkstarted init 0
/* how many birds at each tree*/
gkBirdsRL init 0
gkBirdsRR init 0
gkBirdsFL init 0
gkBirdsFR init 0
instr 1 ; Init
if gkstarted > 0 igoto endlabel
gkBirdsRL random 10, 20
gkBirdsRR random 10, 20
gkBirdsFL random 10, 20
gkBirdsFR random 10, 20
printks "\\n gkBirdsRL =3D %f\\n", 1/kr, gkBirdsRL
printks "\\n gkBirdsRR =3D %f\\n", 1/kr, gkBirdsRR
printks "\\n gkBirdsFL =3D %f\\n", 1/kr, gkBirdsFL
printks "\\n gkBirdsFR =3D %f\\n", 1/kr, gkBirdsFR
gkstarted =3D 1
schedule 2, 0, p4
endlabel:
endin
instr 2=09;A KIND OF GOD WHO DECIDES IF A BIRD SING OR NOT
kwouldsing random 0, 10
kwouldsing =3D int(kwouldsing)
if kwouldsing > 1 kgoto nosing =20
kifn random 4, 8
kifn =3D int(kifn)
schedkwhen 1, 0, 0, 10, 0, 2.5, kifn
nosing:
printks "\\n kwouldsing =3D %f\\n", 1/kr, kwouldsing
endin
instr 10 ; bird singing
print p4 ;to see which function will be called
/* signal to be sung */
a1=09lposcil 10000, 1, 0, -1, p4
outch 7,a1 ;just one channel now
endin
/*CSD FILE*/
/* table of audio sources */
f 4 0 0 1 "F:\csound\project1\graznidos\cg_gtgr_031701 - A.aif" 0 0 0
f 5 0 0 1 "F:\csound\project1\cg_gtgr_031701 - B.aif" 0 0 0
f 6 0 0 1 "F:\csound\project1\cg_gtgr_031701 - C.aif" 0 0 0
f 7 0 0 1 "F:\csound\project1\cg_gtgr_031701 - D.aif" 0 0 0
f 8 0 0 1 "F:\csound\project1\cg_gtgr_031701 - DE.aif" 0 0 0
i 1 0 10
e
-- [EMAIL REMOVED] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) [EMAIL REMOVED]