Csound Csound-dev Csound-tekno Search About

Re: [Csnd] Sensekey and ASCII key-up

Date2011-07-06 02:41
From"Art Hunkins"
SubjectRe: [Csnd] Sensekey and ASCII key-up
Thanks for the suggestion, Rory.

What I'd like to do with ASCII is to emulate a MIDI key: press a key, a note 
starts; release the key, note stops.

Seems straightforward enough; hardly rocket science.

Your code brought one wild possibility to mind: set the Accessibility 
options for keys to start repeating immediately and fast, and have your UDO 
monitor the switching. When it stops toggling for, say, .1 second, the note 
is released.

I think maybe I've been spending too much time in front of my computer.

Art Hunkins
----- Original Message ----- 
From: "Rory Walsh" 
To: 
Sent: Tuesday, July 05, 2011 8:11 PM
Subject: Re: [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"

= 



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 06:35
FromJustin Glenn Smith
SubjectRe: [Csnd] Sensekey and ASCII key-up
There is no ascii keycode or ansi event representing a keyup.

The Linux console can provide keyup events if you put it in raw mode, and theoretically one could make a Linux console specific opcode that would do this.

If you have access to graphic displays and Fltk opcodes, FlkeyIn will provide keyup info.

I don't use any frontends, but I presume any GUI frontend could be made to provide keyup events to csound (via a control channel or orchestra event) if they don't do so already.

Art Hunkins wrote:
> Thanks for the suggestion, Rory.
> 
> What I'd like to do with ASCII is to emulate a MIDI key: press a key, a
> note starts; release the key, note stops.
> 
> Seems straightforward enough; hardly rocket science.
> 
> Your code brought one wild possibility to mind: set the Accessibility
> options for keys to start repeating immediately and fast, and have your
> UDO monitor the switching. When it stops toggling for, say, .1 second,
> the note is released.
> 
> I think maybe I've been spending too much time in front of my computer.
> 
> Art Hunkins
> ----- Original Message ----- From: "Rory Walsh" 
> To: 
> Sent: Tuesday, July 05, 2011 8:11 PM
> Subject: Re: [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"
> 
> =
> 
> 
> 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 07:55
Fromjoachim heintz
SubjectRe: [Csnd] Sensekey and ASCII key-up
hi art -

if i understood you correctly, this udo does what you want (it returns
'1' as long as a certain key is hold, like a midi key):
http://www.csounds.com/udo/displayOpcode.php?opcode_id=134

there is also an example on this page. hope this helps -

	joachim



Am 06.07.2011 03:41, schrieb Art Hunkins:
> Thanks for the suggestion, Rory.
> 
> What I'd like to do with ASCII is to emulate a MIDI key: press a key, a
> note starts; release the key, note stops.
> 
> Seems straightforward enough; hardly rocket science.
> 
> Your code brought one wild possibility to mind: set the Accessibility
> options for keys to start repeating immediately and fast, and have your
> UDO monitor the switching. When it stops toggling for, say, .1 second,
> the note is released.
> 
> I think maybe I've been spending too much time in front of my computer.
> 
> Art Hunkins
> ----- Original Message ----- From: "Rory Walsh" 
> To: 
> Sent: Tuesday, July 05, 2011 8:11 PM
> Subject: Re: [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"
> 
> =
> 
> 
> 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"