Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)

Date2009-05-08 18:43
From"Art Hunkins"
SubjectRe: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)
Andres and other Python-knowledgeable developers,

One more try (better I hope; the issue is passing an ASCII keystroke from 
OLPC Python to a csd):


In secondary function:

self.connect('key-press-event'), self.w.onKeyPress)
("w" refers to main loop)

In main loop:

def onKeyPress(self, widget, event):
  self.csound.SetChannel("ascii", event)

Then, in the csd (with no sensekey):

(in header)
 gkasc init 0

(in instrument)
gkasc chnget "ascii"
ktrig   trigger gkasc, .5, 0
          if ktrig == 0 goto skip
;"ascii-related code" goes here; concludes with next two lines
gkasc = 0
         chnset gkasc, "ascii"
skip:

I'd appreciate very specific corrections. I'm still in the woods, wandering.

Art Hunkins

----- Original Message ----- 
From: "Art Hunkins" 
To: "Andres Cabrera" 
Cc: 
Sent: Thursday, May 07, 2009 10:43 PM
Subject: Re: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)


> Andres,
>
> How about this (I'm grasping now!):
>
> def onKeyPress(self, widget, event):
>  self.csound.SetChannel("ascii",event)
>
> Then, in the csd (with no sensekey):
>
> gkasc init 0
>
> gkasc chnget "ascii"
> ktrig   trigger gkasc, .5, 0
>          if ktrig == 0 goto skip
> gkasc = 0
> ;rest of "ascii-related code" goes here
> skip:
>
> ----- Original Message ----- 
> From: "Andres Cabrera" 
> To: "Art Hunkins" 
> Sent: Thursday, May 07, 2009 9:42 PM
> Subject: Re: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)
>
>
> On Thu, May 7, 2009 at 8:23 PM, Art Hunkins  wrote:
>> Andres,
>>
>> I think I prefer your first suggestion (quoted below). (I wouldn't begin 
>> to
>> know how or where to do things in c.)
>>
>> Can you suggest the code to pass each keystroke to a channel, and via
>> chnexport to sensekey?
>>
>
> You can't... You can pass he pressed keys through the software bus and
> receive them in your csd using invalue or chnget (depending on which
> software bus you are using).
>
> Cheers,
> Andrés 


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2009-05-09 01:23
FromAndres Cabrera
SubjectRe: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)
Hi,

On Fri, May 8, 2009 at 12:43 PM, Art Hunkins  wrote:
> Andres and other Python-knowledgeable developers,
>
> One more try (better I hope; the issue is passing an ASCII keystroke from
> OLPC Python to a csd):
>
>
> In secondary function:
>
> self.connect('key-press-event'), self.w.onKeyPress)
> ("w" refers to main loop)
>
> In main loop:
>
> def onKeyPress(self, widget, event):
>  self.csound.SetChannel("ascii", event)
>

The event variable is actually an object, so you wil not be able to
pass it directly. You need to find the key that triggered the event.
See the code in that function in TamTamMini, to see how the event
varible is used.
You will have a problem here that only the last pressed key for the
control period will be processed, since the channel vaue is being
overwritten. One solution is to accumulate the keys pressed in a
string variable, pass the string variable and then separate the
individual keys in Csound.

> Then, in the csd (with no sensekey):
>
> (in header)
> gkasc init 0
>
> (in instrument)
> gkasc chnget "ascii"
> ktrig   trigger gkasc, .5, 0
>         if ktrig == 0 goto skip
> ;"ascii-related code" goes here; concludes with next two lines
> gkasc = 0
>        chnset gkasc, "ascii"
> skip:
>

don't set gkasc again, clear the channel. Also as I said above, think
of using a string channel. (not sure if chnget/chnset support string
channels... if not, you would need to use invalue/outvalue)

Cheers,
Andrés
- Show quoted text -

> I'd appreciate very specific corrections. I'm still in the woods, wandering.
>
> Art Hunkins
>
> ----- Original Message ----- From: "Art Hunkins" 
> To: "Andres Cabrera" 
> Cc: 
> Sent: Thursday, May 07, 2009 10:43 PM
> Subject: Re: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)
>
>
>> Andres,
>>
>> How about this (I'm grasping now!):
>>
>> def onKeyPress(self, widget, event):
>>  self.csound.SetChannel("ascii",event)
>>
>> Then, in the csd (with no sensekey):
>>
>> gkasc init 0
>>
>> gkasc chnget "ascii"
>> ktrig   trigger gkasc, .5, 0
>>         if ktrig == 0 goto skip
>> gkasc = 0
>> ;rest of "ascii-related code" goes here
>> skip:
>>
>> ----- Original Message ----- From: "Andres Cabrera"
>> 
>> To: "Art Hunkins" 
>> Sent: Thursday, May 07, 2009 9:42 PM
>> Subject: Re: [Cs-dev] [Csnd] sensekey and Sugar (OLPC)
>>
>>
>> On Thu, May 7, 2009 at 8:23 PM, Art Hunkins  wrote:
>>>
>>> Andres,
>>>
>>> I think I prefer your first suggestion (quoted below). (I wouldn't begin
>>> to
>>> know how or where to do things in c.)
>>>
>>> Can you suggest the code to pass each keystroke to a channel, and via
>>> chnexport to sensekey?
>>>
>>
>> You can't... You can pass he pressed keys through the software bus and
>> receive them in your csd using invalue or chnget (depending on which
>> software bus you are using).
>>
>> Cheers,
>> Andrés
>
>



--


Andrés

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net