[Csnd] local and global variables

Dear community,
I’ve studied the code of the “random-walk” of joachim that I’ve found on https://flossmanual.csound.com/basics/random
I would like to know if the global variables giLowestPitch,giHighestPitch,giStartPitch,gkPitchDev and gkPitchDir in EXAMPLE 01D09_random_walk.csd could
also be local variables?
Thanks for Your help,
Stefan

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Variables starting with “g” are always global in scope.

hi stefan -

after a quick look at the code, i see two reasons for making the variables global:
1. better overview
2. they are used in both instruments (see line 93)

but for sure the varibles could be made local, if you prefer. you need to send the lowest and highest pitch as p-fields to instr play then.

best -
  joachim

Dear Joachim,
thanks for the answer.
No I do understand it much better!
Stefan