Csound Csound-dev Csound-tekno Search About

[Csnd] Sensekey and ASCII key-up

Date2011-07-06 00:29
From"Art Hunkins"
Subject[Csnd] Sensekey and ASCII key-up
I've been working with sensekey again, and find that sensekey cannot tell me 
when an ASCII key is released. Indeed all it does is identify a key*press*.

I had thought that the kdown parameter could tell me when a key is released, 
but no; a test shows that all parameter activity is at the keypress, none at 
the release. (Sensekey shows all data emanating at "keypress time".)

Of course, perhaps this is just the way ASCII keyboards work (I've tried two 
of them on my Windows XP; same "action"). Though I'm not sure how keyboard 
repeat would work without knowledge that a key was being held down.

I've also tried multiple delay and repeat options under my Accessibility 
settings; the basic fact remains: a message is sent out when a key goes 
down, and nothing when it is released. The ASCII info *immediately* returns 
to "zero" as soon as the keystroke is registered.

Am I missing anything here, or is "ASCII key-up" a non-starter?

Art Hunkins 



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"

Date2011-07-06 01:11
FromRory Walsh
SubjectRe: [Csnd] Sensekey and ASCII key-up
Hi Art. I've come across this before. As you mentioned, it seems to
simply toggle quickly between 0 and 1. I've never had need to know
when the key is in a 'pressed' state, but I have turned particular
keys into toggle switches using a simple UDO:



-odac



opcode keyMonitor, k, kkk
kinkey, kkey, kdown xin
kcnt init 0
if((kinkey==kkey)&&(kdown==1)) then
	if(kcnt==0) then
		kcnt=1
	elseif(kcnt==1) then
		kcnt=0
	endif
endif
xout kcnt
endop

instr 1
kkey, kdown sensekey
;press a to toggle a=97
ktoggle keyMonitor 97, kkey, kdown
printk2 ktoggle
endin



i1 0 1024



It will output 1 the first time it is pressed and 0 the second time.
It won't work for held keys but you could perhaps throw some kind of
timing mechanism in there to tell it to continue outputting 1 if kdown
keeps toggling between 1 and 0. It's a hack for sure. I'm going to
guess that others have far better solutions to this!

On 6 July 2011 00:29, Art Hunkins  wrote:
> I've been working with sensekey again, and find that sensekey cannot tell me
> when an ASCII key is released. Indeed all it does is identify a key*press*.
>
> I had thought that the kdown parameter could tell me when a key is released,
> but no; a test shows that all parameter activity is at the keypress, none at
> the release. (Sensekey shows all data emanating at "keypress time".)
>
> Of course, perhaps this is just the way ASCII keyboards work (I've tried two
> of them on my Windows XP; same "action"). Though I'm not sure how keyboard
> repeat would work without knowledge that a key was being held down.
>
> I've also tried multiple delay and repeat options under my Accessibility
> settings; the basic fact remains: a message is sent out when a key goes
> down, and nothing when it is released. The ASCII info *immediately* returns
> to "zero" as soon as the keystroke is registered.
>
> Am I missing anything here, or is "ASCII key-up" a non-starter?
>
> Art Hunkins
>
>
> 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"
>
>


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"


Date2011-07-06 16:38
FromLouis Cohen
SubjectRe: [Csnd] Sensekey and ASCII key-up
I had the same experience on MacOSX, with MacCsound and QTCsound. I  
gave up trying to sense when a key is released, and found a different  
musical solution.

At one point I thought of using FLTK, which had somewhat more  
promising support of the keyboard. But other problems about FLTK were  
too hard to deal with, so I just decided that great art didn't always  
need to know when a key was released.

-Lou

On Jul 5, 2011, at 7:29 PM, Art Hunkins wrote:

> I've been working with sensekey again, and find that sensekey cannot  
> tell me when an ASCII key is released. Indeed all it does is  
> identify a key*press*.
>
> I had thought that the kdown parameter could tell me when a key is  
> released, but no; a test shows that all parameter activity is at the  
> keypress, none at the release. (Sensekey shows all data emanating at  
> "keypress time".)
>
> Of course, perhaps this is just the way ASCII keyboards work (I've  
> tried two of them on my Windows XP; same "action"). Though I'm not  
> sure how keyboard repeat would work without knowledge that a key was  
> being held down.
>
> I've also tried multiple delay and repeat options under my  
> Accessibility settings; the basic fact remains: a message is sent  
> out when a key goes down, and nothing when it is released. The ASCII  
> info *immediately* returns to "zero" as soon as the keystroke is  
> registered.
>
> Am I missing anything here, or is "ASCII key-up" a non-starter?
>
> Art Hunkins
>
>
> 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"
>



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"

Date2011-07-08 09:24
FromTarmo Johannes
SubjectRe: [Csnd] Sensekey and ASCII key-up
Attachmentspy-keyup-test.csd  
Hello,

there can be one solution - one thing that makes csound really unlimited is the possibility to embed python programming and thususe python modules -  so basically you can do whatever.

See a great article about it by Andrés Cabrera at http://www.csounds.com/journal/issue6/pythonOpcodes.html

I made a quick search and first python library that enables reading key-releases is pygame http://pygame.org/docs/index.html
It was very easy to install on linux, I assume it should not be a prblem in  OSX or Windows.

A little drawback is that pygame needs to create a separate window and you have to click on it to tell the module to read the keys. It can be very clumsy when you have to do something for example with qutecsound widgets. It is just an example, I am sure there must be also a way to read raw keyboard events.

here is the example (+ in attachment for any case):

--------


-odac -d



sr=44100
ksmps=32
nchnls=2
0dbfs=1

; python in csound - http://www.csounds.com/journal/issue6/pythonOpcodes.html
;pygame - http://pygame.org/docs/

pyinit
; a strange thing about pyrun - the next line and last }} have to be in the beginning of line, not indented
pyruni {{
import pygame
from pygame.locals import *

pygame.init()
pygame.display.set_caption('ESC to close!')
screen = pygame.display.set_mode((200, 20), ) 
}} ; this opens a small window, you have to focus to that (klick on it), otherwise the keys are not read


instr 1
	
	pyrun {{ 
key=0.0
keypress=0.0
keylift=0.0
for event in pygame.event.get():
  if (event.type == KEYDOWN):
	key=float(event.key)
	keypress=1.0
	if (event.key == K_ESCAPE):
          pygame.display.quit()
 
  if (event.type == KEYUP):
	key=float(event.key)
	keylift=1.0
}}
	kkeypress pyeval "keypress"
	kkeylift pyeval "keylift"
	kkey pyeval "key"
	
	if (kkeypress==1 && kkey!=27) then ; 27 -ESCAPE key used for closing the window
		printks "Key %d pressed",1,kkey
		Sline1 sprintfk "i 2.%d 0 -1 %f",kkey,kkey*2 ;make the instrument number in form 2. to be able to turn it off later
		scoreline Sline1, kkeypress
		pyassign "keypress",0 ; reset the flag
	endif
	
	if (kkeylift==1 ) then 
		printks "Key %d lifted",1, kkey
		Sline2 sprintfk "i -2.%d 0 0 ",kkey ; turn the not according to key off
		scoreline Sline2, kkeylift
		pyassign "keylift",0 ; reset
	endif	

endin


instr 2
	ifreq=p4	
	kenv madsr 0.2, 0.3, 0.5,0.5 ;
	asig oscil kenv, ifreq, 1
	outs asig,asig
endin




f 1 0 8192 10 1 0.6 0.7 0.4 0.3 0.2 ; sine with some harmonics

i 1 0 60





---------

greetings,
tarmo


On Wednesday 06 July 2011 18:38:50 Louis Cohen wrote:
> I had the same experience on MacOSX, with MacCsound and QTCsound. I  
> gave up trying to sense when a key is released, and found a different  
> musical solution.
> 
> At one point I thought of using FLTK, which had somewhat more  
> promising support of the keyboard. But other problems about FLTK were  
> too hard to deal with, so I just decided that great art didn't always  
> need to know when a key was released.
> 
> -Lou
> 
> On Jul 5, 2011, at 7:29 PM, Art Hunkins wrote:
> 
> > I've been working with sensekey again, and find that sensekey cannot  
> > tell me when an ASCII key is released. Indeed all it does is  
> > identify a key*press*.
> >
> > I had thought that the kdown parameter could tell me when a key is  
> > released, but no; a test shows that all parameter activity is at the  
> > keypress, none at the release. (Sensekey shows all data emanating at  
> > "keypress time".)
> >
> > Of course, perhaps this is just the way ASCII keyboards work (I've  
> > tried two of them on my Windows XP; same "action"). Though I'm not  
> > sure how keyboard repeat would work without knowledge that a key was  
> > being held down.
> >
> > I've also tried multiple delay and repeat options under my  
> > Accessibility settings; the basic fact remains: a message is sent  
> > out when a key goes down, and nothing when it is released. The ASCII  
> > info *immediately* returns to "zero" as soon as the keystroke is  
> > registered.
> >
> > Am I missing anything here, or is "ASCII key-up" a non-starter?
> >
> > Art Hunkins
> >
> >
> > 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"
> >
> 
> 
> 
> 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"
> 
> 

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"


Date2011-07-08 10:46
Fromjoachim heintz
SubjectRe: [Csnd] Sensekey and ASCII key-up
AttachmentsKeyOnce.csd  
very cool ... i have installed pygame on ubuntu 10.10 via the synaptic
package manager, and your .csd worked perfectly.
what i cannot understand right now: i have a simple .csd (see
attachment) which works perfectly in qutecsound, but not in the
terminal. in qutecsound i get the "space bar released" as expected, but
not in the terminal. this is not related to the automatic key
repetitions - i disabled it before. i have tested it on ubuntu and osx,
it's the same. does anyone know what is different here between
qutecsound and the terminal in this respect?
in general, it would be nice if we could have a "keyup" opcode like, for
instance, in pd.

	joachim
	


Am 08.07.2011 10:24, schrieb Tarmo Johannes:
> Hello,
> 
> there can be one solution - one thing that makes csound really unlimited is the possibility to embed python programming and thususe python modules -  so basically you can do whatever.
> 
> See a great article about it by Andrés Cabrera at http://www.csounds.com/journal/issue6/pythonOpcodes.html
> 
> I made a quick search and first python library that enables reading key-releases is pygame http://pygame.org/docs/index.html
> It was very easy to install on linux, I assume it should not be a prblem in  OSX or Windows.
> 
> A little drawback is that pygame needs to create a separate window and you have to click on it to tell the module to read the keys. It can be very clumsy when you have to do something for example with qutecsound widgets. It is just an example, I am sure there must be also a way to read raw keyboard events.
> 
> here is the example (+ in attachment for any case):
> 
> --------
> 
> 
> -odac -d
> 
> 
> 
> sr=44100
> ksmps=32
> nchnls=2
> 0dbfs=1
> 
> ; python in csound - http://www.csounds.com/journal/issue6/pythonOpcodes.html
> ;pygame - http://pygame.org/docs/
> 
> pyinit
> ; a strange thing about pyrun - the next line and last }} have to be in the beginning of line, not indented
> pyruni {{
> import pygame
> from pygame.locals import *
> 
> pygame.init()
> pygame.display.set_caption('ESC to close!')
> screen = pygame.display.set_mode((200, 20), ) 
> }} ; this opens a small window, you have to focus to that (klick on it), otherwise the keys are not read
> 
> 
> instr 1
> 	
> 	pyrun {{ 
> key=0.0
> keypress=0.0
> keylift=0.0
> for event in pygame.event.get():
>   if (event.type == KEYDOWN):
> 	key=float(event.key)
> 	keypress=1.0
> 	if (event.key == K_ESCAPE):
>           pygame.display.quit()
>  
>   if (event.type == KEYUP):
> 	key=float(event.key)
> 	keylift=1.0
> }}
> 	kkeypress pyeval "keypress"
> 	kkeylift pyeval "keylift"
> 	kkey pyeval "key"
> 	
> 	if (kkeypress==1 && kkey!=27) then ; 27 -ESCAPE key used for closing the window
> 		printks "Key %d pressed",1,kkey
> 		Sline1 sprintfk "i 2.%d 0 -1 %f",kkey,kkey*2 ;make the instrument number in form 2. to be able to turn it off later
> 		scoreline Sline1, kkeypress
> 		pyassign "keypress",0 ; reset the flag
> 	endif
> 	
> 	if (kkeylift==1 ) then 
> 		printks "Key %d lifted",1, kkey
> 		Sline2 sprintfk "i -2.%d 0 0 ",kkey ; turn the not according to key off
> 		scoreline Sline2, kkeylift
> 		pyassign "keylift",0 ; reset
> 	endif	
> 
> endin
> 
> 
> instr 2
> 	ifreq=p4	
> 	kenv madsr 0.2, 0.3, 0.5,0.5 ;
> 	asig oscil kenv, ifreq, 1
> 	outs asig,asig
> endin
> 
> 
> 
> 
> f 1 0 8192 10 1 0.6 0.7 0.4 0.3 0.2 ; sine with some harmonics
> 
> i 1 0 60
> 
> 
> 
> 
> 
> ---------
> 
> greetings,
> tarmo
> 
> 
> On Wednesday 06 July 2011 18:38:50 Louis Cohen wrote:
>> I had the same experience on MacOSX, with MacCsound and QTCsound. I  
>> gave up trying to sense when a key is released, and found a different  
>> musical solution.
>>
>> At one point I thought of using FLTK, which had somewhat more  
>> promising support of the keyboard. But other problems about FLTK were  
>> too hard to deal with, so I just decided that great art didn't always  
>> need to know when a key was released.
>>
>> -Lou
>>
>> On Jul 5, 2011, at 7:29 PM, Art Hunkins wrote:
>>
>>> I've been working with sensekey again, and find that sensekey cannot  
>>> tell me when an ASCII key is released. Indeed all it does is  
>>> identify a key*press*.
>>>
>>> I had thought that the kdown parameter could tell me when a key is  
>>> released, but no; a test shows that all parameter activity is at the  
>>> keypress, none at the release. (Sensekey shows all data emanating at  
>>> "keypress time".)
>>>
>>> Of course, perhaps this is just the way ASCII keyboards work (I've  
>>> tried two of them on my Windows XP; same "action"). Though I'm not  
>>> sure how keyboard repeat would work without knowledge that a key was  
>>> being held down.
>>>
>>> I've also tried multiple delay and repeat options under my  
>>> Accessibility settings; the basic fact remains: a message is sent  
>>> out when a key goes down, and nothing when it is released. The ASCII  
>>> info *immediately* returns to "zero" as soon as the keystroke is  
>>> registered.
>>>
>>> Am I missing anything here, or is "ASCII key-up" a non-starter?
>>>
>>> Art Hunkins
>>>
>>>
>>> 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"
>>>
>>
>>
>>
>> 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"
>>
>>
> 
> 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"
> 

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"


Date2011-07-08 12:23
Frommenno
Subject[Csnd] Re: Sensekey and ASCII key-up
a bit off topic, but i get no result whatsoever using the sensekey opcode.
For example when i try your csd, Joachim (KeyOnce.csd) i get the following
result:
i1 -1.000000
i1 0.000000

and that's it. Pushing the spacebar or any other key does not create a
reaction.
Nor do any of the examples of the manual work.
The prove that my keyboard works is that i am typing with it atm.
Any ideas what this could be?

regards
Menno

--
View this message in context: http://csound.1045644.n5.nabble.com/Sensekey-and-ASCII-key-up-tp4555172p4564416.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"

Date2011-07-08 16:41
Fromjoachim heintz
SubjectRe: [Csnd] Re: Sensekey and ASCII key-up
that's what i tried o describe as difference between using this csd in
qutecsound and in the terminal, right? (in other words: it works in
qutecsound.)


Am 08.07.2011 13:23, schrieb menno:
> a bit off topic, but i get no result whatsoever using the sensekey opcode.
> For example when i try your csd, Joachim (KeyOnce.csd) i get the following
> result:
> i1 -1.000000
> i1 0.000000
> 
> and that's it. Pushing the spacebar or any other key does not create a
> reaction.
> Nor do any of the examples of the manual work.
> The prove that my keyboard works is that i am typing with it atm.
> Any ideas what this could be?
> 
> regards
> Menno
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Sensekey-and-ASCII-key-up-tp4555172p4564416.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> 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"
> 
> 


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"

Date2011-07-08 19:41
FromJustin Smith
SubjectRe: [Csnd] Sensekey and ASCII key-up

As I mentioned in another message, the ansi terminal protocol does not have any way to provide keyup info. since qtecsound uses the windowing system for input rather than an ansi terminal, it can get keyup events.

----- Original message -----
> very cool ... i have installed pygame on ubuntu 10.10 via the synaptic
> package manager, and your .csd worked perfectly.
> what i cannot understand right now: i have a simple .csd (see
> attachment) which works perfectly in qutecsound, but not in the
> terminal. in qutecsound i get the "space bar released" as expected, but
> not in the terminal. this is not related to the automatic key
> repetitions - i disabled it before. i have tested it on ubuntu and osx,
> it's the same. does anyone know what is different here between
> qutecsound and the terminal in this respect?
> in general, it would be nice if we could have a "keyup" opcode like, for
> instance, in pd.
>
>     joachim
>    
>
>
> Am 08.07.2011 10:24, schrieb Tarmo Johannes:
> > Hello,
> >
> > there can be one solution - one thing that makes csound really
> > unlimited is the possibility to embed python programming and thususe
> > python modules -  so basically you can do whatever.
> >
> > See a great article about it by Andrés Cabrera at
> > http://www.csounds.com/journal/issue6/pythonOpcodes.html
> >
> > I made a quick search and first python library that enables reading
> > key-releases is pygame http://pygame.org/docs/index.html It was very
> > easy to install on linux, I assume it should not be a prblem in  OSX
> > or Windows.
> >
> > A little drawback is that pygame needs to create a separate window and
> > you have to click on it to tell the module to read the keys. It can be
> > very clumsy when you have to do something for example with qutecsound
> > widgets. It is just an example, I am sure there must be also a way to
> > read raw keyboard events.
> >
> > here is the example (+ in attachment for any case):
> >
> > --------
> > <CsoundSynthesizer>
> > <CsOptions>
> > -odac -d
> > </CsOptions>
> > <CsInstruments>
> >
> > sr=44100
> > ksmps=32
> > nchnls=2
> > 0dbfs=1
> >
> > ; python in csound -
> > http://www.csounds.com/journal/issue6/pythonOpcodes.html ;pygame -
> > http://pygame.org/docs/
> >
> > pyinit
> > ; a strange thing about pyrun - the next line and last }} have to be
> > in the beginning of line, not indented pyruni {{
> > import pygame
> > from pygame.locals import *
> >
> > pygame.init()
> > pygame.display.set_caption('ESC to close!')
> > screen = pygame.display.set_mode((200, 20), )
> > }} ; this opens a small window, you have to focus to that (klick on
> > it), otherwise the keys are not read
> >
> >
> > instr 1
> >    
> >     pyrun {{
> > key=0.0
> > keypress=0.0
> > keylift=0.0
> > for event in pygame.event.get():
> > if (event.type == KEYDOWN):
> >     key=float(event.key)
> >     keypress=1.0
> >     if (event.key == K_ESCAPE):
> > pygame.display.quit()
> >
> > if (event.type == KEYUP):
> >     key=float(event.key)
> >     keylift=1.0
> > }}
> >     kkeypress pyeval "keypress"
> >     kkeylift pyeval "keylift"
> >     kkey pyeval "key"
> >    
> >     if (kkeypress==1 && kkey!=27) then ; 27 -ESCAPE key used for closing
> > the window        printks "Key %d pressed",1,kkey
> >         Sline1 sprintfk "i 2.%d 0 -1 %f",kkey,kkey*2 ;make the instrument
> > number in form 2.<keycode> to be able to turn it off later        scoreline
> > Sline1, kkeypress        pyassign "keypress",0 ; reset the flag
> >     endif
> >    
> >     if (kkeylift==1 ) then
> >         printks "Key %d lifted",1, kkey
> >         Sline2 sprintfk "i -2.%d 0 0 ",kkey ; turn the not according to key
> > off        scoreline Sline2, kkeylift
> >         pyassign "keylift",0 ; reset
> >     endif   
> >
> > endin
> >
> >
> > instr 2
> >     ifreq=p4   
> >     kenv madsr 0.2, 0.3, 0.5,0.5 ;
> >     asig oscil kenv, ifreq, 1
> >     outs asig,asig
> > endin
> >
> >
> > </CsInstruments>
> > <CsScore>
> > f 1 0 8192 10 1 0.6 0.7 0.4 0.3 0.2 ; sine with some harmonics
> >
> > i 1 0 60
> >
> > </CsScore>
> > </CsoundSynthesizer>
> >
> >
> > ---------
> >
> > greetings,
> > tarmo
> >
> >
> > On Wednesday 06 July 2011 18:38:50 Louis Cohen wrote:
> > > I had the same experience on MacOSX, with MacCsound and QTCsound. I 
> > > gave up trying to sense when a key is released, and found a
> > > different    musical solution.
> > >
> > > At one point I thought of using FLTK, which had somewhat more 
> > > promising support of the keyboard. But other problems about FLTK
> > > were    too hard to deal with, so I just decided that great art
> > > didn't always    need to know when a key was released.
> > >
> > > -Lou
> > >
> > > On Jul 5, 2011, at 7:29 PM, Art Hunkins wrote:
> > >
> > > > I've been working with sensekey again, and find that sensekey
> > > > cannot    tell me when an ASCII key is released. Indeed all it does
> > > > is    identify a key*press*.
> > > >
> > > > I had thought that the kdown parameter could tell me when a key is
> > > >    released, but no; a test shows that all parameter activity is at
> > > > the    keypress, none at the release. (Sensekey shows all data
> > > > emanating at    "keypress time".)
> > > >
> > > > Of course, perhaps this is just the way ASCII keyboards work (I've
> > > >    tried two of them on my Windows XP; same "action"). Though I'm
> > > > not    sure how keyboard repeat would work without knowledge that a
> > > > key was    being held down.
> > > >
> > > > I've also tried multiple delay and repeat options under my 
> > > > Accessibility settings; the basic fact remains: a message is sent 
> > > > out when a key goes down, and nothing when it is released. The
> > > > ASCII    info *immediately* returns to "zero" as soon as the
> > > > keystroke is    registered.
> > > >
> > > > Am I missing anything here, or is "ASCII key-up" a non-starter?
> > > >
> > > > Art Hunkins
> > > >
> > > >
> > > > 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"
> > > >
> > >
> > >
> > >
> > > 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"
> > >
> > >
> >
> > 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"
> >
>
> 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"
>

<Attachment>  KeyOnce.csd


Date2011-07-08 20:13
Fromjoachim heintz
SubjectRe: [Csnd] Sensekey and ASCII key-up
thanks!
	j

Am 08.07.2011 20:41, schrieb Justin Smith:
> As I mentioned in another message, the ansi terminal protocol does not
> have any way to provide keyup info. since qtecsound uses the windowing
> system for input rather than an ansi terminal, it can get keyup events.
> 
> ----- Original message -----
>> very cool ... i have installed pygame on ubuntu 10.10 via the synaptic
>> package manager, and your .csd worked perfectly.
>> what i cannot understand right now: i have a simple .csd (see
>> attachment) which works perfectly in qutecsound, but not in the
>> terminal. in qutecsound i get the "space bar released" as expected, but
>> not in the terminal. this is not related to the automatic key
>> repetitions - i disabled it before. i have tested it on ubuntu and osx,
>> it's the same. does anyone know what is different here between
>> qutecsound and the terminal in this respect?
>> in general, it would be nice if we could have a "keyup" opcode like, for
>> instance, in pd.
>>
>>     joachim
>>    
>>
>>
>> Am 08.07.2011 10:24, schrieb Tarmo Johannes:
>> > Hello,
>> >
>> > there can be one solution - one thing that makes csound really
>> > unlimited is the possibility to embed python programming and thususe
>> > python modules -  so basically you can do whatever.
>> >
>> > See a great article about it by Andrés Cabrera at
>> > http://www.csounds.com/journal/issue6/pythonOpcodes.html
>> >
>> > I made a quick search and first python library that enables reading
>> > key-releases is pygame http://pygame.org/docs/index.html It was very
>> > easy to install on linux, I assume it should not be a prblem in  OSX
>> > or Windows.
>> >
>> > A little drawback is that pygame needs to create a separate window and
>> > you have to click on it to tell the module to read the keys. It can be
>> > very clumsy when you have to do something for example with qutecsound
>> > widgets. It is just an example, I am sure there must be also a way to
>> > read raw keyboard events.
>> >
>> > here is the example (+ in attachment for any case):
>> >
>> > --------
>> > 
>> > 
>> > -odac -d
>> > 
>> > 
>> >
>> > sr=44100
>> > ksmps=32
>> > nchnls=2
>> > 0dbfs=1
>> >
>> > ; python in csound -
>> > http://www.csounds.com/journal/issue6/pythonOpcodes.html ;pygame -
>> > http://pygame.org/docs/
>> >
>> > pyinit
>> > ; a strange thing about pyrun - the next line and last }} have to be
>> > in the beginning of line, not indented pyruni {{
>> > import pygame
>> > from pygame.locals import *
>> >
>> > pygame.init()
>> > pygame.display.set_caption('ESC to close!')
>> > screen = pygame.display.set_mode((200, 20), )
>> > }} ; this opens a small window, you have to focus to that (klick on
>> > it), otherwise the keys are not read
>> >
>> >
>> > instr 1
>> >    
>> >     pyrun {{
>> > key=0.0
>> > keypress=0.0
>> > keylift=0.0
>> > for event in pygame.event.get():
>> > if (event.type == KEYDOWN):
>> >     key=float(event.key)
>> >     keypress=1.0
>> >     if (event.key == K_ESCAPE):
>> > pygame.display.quit()
>> >
>> > if (event.type == KEYUP):
>> >     key=float(event.key)
>> >     keylift=1.0
>> > }}
>> >     kkeypress pyeval "keypress"
>> >     kkeylift pyeval "keylift"
>> >     kkey pyeval "key"
>> >    
>> >     if (kkeypress==1 && kkey!=27) then ; 27 -ESCAPE key used for
> closing
>> > the window        printks "Key %d pressed",1,kkey
>> >         Sline1 sprintfk "i 2.%d 0 -1 %f",kkey,kkey*2 ;make the
> instrument
>> > number in form 2. to be able to turn it off later       
> scoreline
>> > Sline1, kkeypress        pyassign "keypress",0 ; reset the flag
>> >     endif
>> >    
>> >     if (kkeylift==1 ) then
>> >         printks "Key %d lifted",1, kkey
>> >         Sline2 sprintfk "i -2.%d 0 0 ",kkey ; turn the not according
> to key
>> > off        scoreline Sline2, kkeylift
>> >         pyassign "keylift",0 ; reset
>> >     endif   
>> >
>> > endin
>> >
>> >
>> > instr 2
>> >     ifreq=p4   
>> >     kenv madsr 0.2, 0.3, 0.5,0.5 ;
>> >     asig oscil kenv, ifreq, 1
>> >     outs asig,asig
>> > endin
>> >
>> >
>> > 
>> > 
>> > f 1 0 8192 10 1 0.6 0.7 0.4 0.3 0.2 ; sine with some harmonics
>> >
>> > i 1 0 60
>> >
>> > 
>> > 
>> >
>> >
>> > ---------
>> >
>> > greetings,
>> > tarmo
>> >
>> >
>> > On Wednesday 06 July 2011 18:38:50 Louis Cohen wrote:
>> > > I had the same experience on MacOSX, with MacCsound and QTCsound. I 
>> > > gave up trying to sense when a key is released, and found a
>> > > different    musical solution.
>> > >
>> > > At one point I thought of using FLTK, which had somewhat more 
>> > > promising support of the keyboard. But other problems about FLTK
>> > > were    too hard to deal with, so I just decided that great art
>> > > didn't always    need to know when a key was released.
>> > >
>> > > -Lou
>> > >
>> > > On Jul 5, 2011, at 7:29 PM, Art Hunkins wrote:
>> > >
>> > > > I've been working with sensekey again, and find that sensekey
>> > > > cannot    tell me when an ASCII key is released. Indeed all it does
>> > > > is    identify a key*press*.
>> > > >
>> > > > I had thought that the kdown parameter could tell me when a key is
>> > > >    released, but no; a test shows that all parameter activity is at
>> > > > the    keypress, none at the release. (Sensekey shows all data
>> > > > emanating at    "keypress time".)
>> > > >
>> > > > Of course, perhaps this is just the way ASCII keyboards work (I've
>> > > >    tried two of them on my Windows XP; same "action"). Though I'm
>> > > > not    sure how keyboard repeat would work without knowledge that a
>> > > > key was    being held down.
>> > > >
>> > > > I've also tried multiple delay and repeat options under my 
>> > > > Accessibility settings; the basic fact remains: a message is sent 
>> > > > out when a key goes down, and nothing when it is released. The
>> > > > ASCII    info *immediately* returns to "zero" as soon as the
>> > > > keystroke is    registered.
>> > > >
>> > > > Am I missing anything here, or is "ASCII key-up" a non-starter?
>> > > >
>> > > > Art Hunkins
>> > > >
>> > > >
>> > > > 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"
>> > > >
>> > >
>> > >
>> > >
>> > > 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"
>> > >
>> > >
>> >
>> > 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"
>> >
>>
>> 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"
>>
> 
>   KeyOnce.csd
> 


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"

Date2011-07-10 13:27
Frommenno
Subject[Csnd] Re: Sensekey and ASCII key-up
no that's not what i mean Joachim; even running this simple csd from the
manual gives me this weird output:

 i1    -1.00000

and nothing more. No response when i push whatever key on my keyboard.
???

This is the csd from the manual:



; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac  -idac   ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o sensekey.wav -W ;;; for file output any platform



; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
  k1 sensekey
  printk2 k1
endin





; Play Instrument #1 for thirty seconds.
i 1 0 30
e





greetings
Menno

--
View this message in context: http://csound.1045644.n5.nabble.com/Sensekey-and-ASCII-key-up-tp4555172p4570853.html
Sent from the Csound - General mailing list archive at Nabble.com.


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"

Date2011-07-10 13:42
Fromjoachim heintz
SubjectRe: [Csnd] Re: Sensekey and ASCII key-up
i see ...
it works with k1,kd instead of just k1. i thought this bug has been
fixed. i will file it to the bug tracker.
best -
	joachim

Am 10.07.2011 14:27, schrieb menno:
> no that's not what i mean Joachim; even running this simple csd from the
> manual gives me this weird output:
> 
>  i1    -1.00000
> 
> and nothing more. No response when i push whatever key on my keyboard.
> ???
> 
> This is the csd from the manual:
> 
> 
> 
> ; Select audio/midi flags here according to platform
> ; Audio out   Audio in
> -odac  -idac   ;;;RT audio I/O
> ; For Non-realtime ouput leave only the line below:
> ; -o sensekey.wav -W ;;; for file output any platform
> 
> 
> 
> ; Initialize the global variables.
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> 
> ; Instrument #1.
> instr 1
>   k1 sensekey
>   printk2 k1
> endin
> 
> 
> 
> 
> 
> ; Play Instrument #1 for thirty seconds.
> i 1 0 30
> e
> 
> 
> 
> 
> 
> greetings
> Menno
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Sensekey-and-ASCII-key-up-tp4555172p4570853.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> 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"
> 
> 


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"