[Csnd] Another sensekey issue
Date | 2011-07-27 02:28 |
From | "Art Hunkins" |
Subject | [Csnd] Another sensekey issue |
On the command line, I need to capture specific ASCII keystrokes to assign specific variables. The code below, which attempts to capture ENTER and SPACEBAR keystrokes, only captures the first one listed, ENTER. Can anyone explain why? It would seem to have to do with the way one of the goto's is functioning incorrectly. Art Hunkins |
Date | 2011-07-27 10:12 |
From | Iain McCurdy |
Subject | RE: [Csnd] Another sensekey issue |
Hi Art, There is a problem with your printks's being skipped on the init pass. If you change your gotos to kgotos it works. Personally though I find ifs and elesifs easier to follow, easier to debug and more concise: instr 1 gkasc,gkdown sensekey if gkasc==13&&gkdown==1 then printks "ENTER pressed\n",0 elseif gkasc==32&&gkdown==1 then printks "SPACEBAR pressed\n",0 endif endin btw ENTER might not be the best key to use in your application as it has a different ascii value on linux and OSX. Iain > From: abhunkin@uncg.edu > To: csound@lists.bath.ac.uk > Date: Tue, 26 Jul 2011 21:28:28 -0400 > Subject: [Csnd] Another sensekey issue > > On the command line, I need to capture specific ASCII keystrokes to assign > specific variables. The code below, which attempts to capture ENTER and > SPACEBAR keystrokes, only captures the first one listed, ENTER. > > Can anyone explain why? It would seem to have to do with the way one of the > goto's is functioning incorrectly. > > Art Hunkins > > > <CsoundSynthesizer> > <CsOptions> > </CsOptions> > <CsInstruments> > > sr = 44100 > ksmps = 100 > nchnls = 2 > > instr 1 > > kvalue init 0 > gkasc,gkdown sensekey > if gkdown == 0 goto end > if gkasc != 13 goto skip ; 13 = ENTER > printks "ENTER pressed\n", 0 > kvalue = 1 > goto end > skip: > if gkasc != 32 goto end ; 32 = SPACEBAR, this never registers > printks "SPACEBAR pressed\n", 0 > kvalue = 2 > > end: endin > > > </CsInstruments> > > <CsScore> > > i1 0 30 > > e > > </CsScore> > </CsoundSynthesizer> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > |
Date | 2011-07-28 19:27 |
From | Louis Cohen |
Subject | Re: ***SPAM*** [Csnd] Another sensekey issue |
Art, I think someone answered this already but i quickly noticed that you are using "goto" and I think it should be "kgoto". In any case I would personally avoid goto or kgoto if at all possible. If I were coding this I would write: kvalue init 0 gkasc,gkdown sensekey if (gkasc != 13 && gkdown == 1) then printks "ENTER pressed\n", 0 kvalue = 1 endif if (gkasc != 32 && gkdown == 1) then printks "SPACEBAR pressed\n", 0 kvalue = 2 endif endin On Jul 26, 2011, at 9:28 PM, Art Hunkins wrote: > On the command line, I need to capture specific ASCII keystrokes to > assign specific variables. The code below, which attempts to capture > ENTER and SPACEBAR keystrokes, only captures the first one listed, > ENTER. > > Can anyone explain why? It would seem to have to do with the way one > of the goto's is functioning incorrectly. > > Art Hunkins > > > |