Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Fw: Csound API Question?

Date2010-10-24 20:21
From"Art Hunkins"
SubjectRe: [Cs-dev] Fw: Csound API Question?
Victor,

Attempting to implement your pointer, I tried the following:

1) I added the line:
self.ready = True
before my call to set_filechannel

2) In the set_filechannel method (in csndsugui), I commented out lines 3, 5 
and 6 - leaving only the call to csound.SetChannel.

Neither of these changes made any difference; still no filename, nor even 
"ahha" passed to my csd.

Please note that I also tried a sequence that first selects and compiles the 
csd, whereupon the performer selects a variety of performance parameters 
passed successfully via chnexport *and selecting the desired file from the 
Journal (our issue)*, then performing. Passing all the other values works 
fine (of course, different methods are employed). Same result.

Any further suggestions are most welcome (from anyone).

Victor, I really appreciate your help trying to troubleshoot me through 
this.

Art Hunkins

----- Original Message ----- 
From: "Victor Lazzarini" 
To: "Art Hunkins" ; "Developer discussions" 

Sent: Sunday, October 24, 2010 4:38 AM
Subject: Re: [Cs-dev] Fw: Csound API Question?


> The definition of the method is:
>
> def set_filechannel(self,chan,name):
> """overrides the base method, setting the channel string"""
>   if not self.ready:
>       self.csound.SetChannel(chan,name)
>   else:
>       BasicGUI.set_filechannel(self,chan,name)
>
> So, what happens is that if the variable 'ready' is True, this uses  the 
> base class method (ie. does not call
> SetChannel). Maybe that is the problem.
>
> 'ready' becomes True after a successful compilation using CsoundGUI. 
> compile() or CsoundGUI.csd()
> or CsoundGUI.recompile().
>
>
> Victor
>
>
>
> On 24 Oct 2010, at 03:17, Art Hunkins wrote:
>
>> I've been having a terrible time getting a filename communicated  through 
>> the
>> API to my csd (Python, XO, Sugar 0.84).
>>
>> The particular method, which works fine otherwise, and uses calls from
>> Victor's csndsugui, is as follows:
>> def choose(self, widget):
>>
>>  self.chooser = ObjectChooser(parent=self,
>> what_filter=mime.GENERIC_TYPE_AUDIO)
>>
>>  self.result = self.chooser.run()
>>
>>  if self.result == gtk.RESPONSE_ACCEPT:
>>
>>    self.jobject = self.chooser.get_selected_object()
>>
>>    if self.jobject and self.jobject.file_path:
>>
>>      self.filename1 = self.jobject.file_path
>>
>>      print 'FileName = ', self.filename1
>>
>>      self.w.set_filechannel("filename1", self.filename1)
>>
>>
>>
>> No errors  are logged.
>>
>> Sname chnget "filename1", and puts Sname, 1
>>
>> (within an instrument in my csd) simply receives a blank filename. 
>> However,
>> "FileName =" in the above code prints out correctly, i.e., the file  has 
>> been
>> correctly located.
>>
>> The same null result occurs when self.filename1 in the last line of 
>> above
>> code is, instead, "haha" (as illustrated in Victor's example).
>>
>> I've discovered that I was retrieving the filename before the .csd was
>> compiled. Perhaps this is a problem? In any case, I also tried  selecting 
>> the
>> filename (i.e., running the above method, which is triggered by a  button
>> press) after .csd compilation and before running - same result (no
>> communication).
>>
>> I'd much appreciate any clues, please. My Python skills are so  minimal, 
>> and
>> this issue has been stumping me for months now.
>>
>> Art Hunkins
>>
>> ----- Original Message -----
>> From: "Victor Lazzarini" 
>> To: "Art Hunkins" ; "Developer discussions"
>> 
>> Sent: Tuesday, October 12, 2010 4:58 AM
>> Subject: Re: [Cs-dev] Fw: Csound API Question?
>>
>>
>>> No, SetChannel() works properly, the script I placed here showed  that 
>>> it
>>> does. The problem
>>> is that your program is not giving it the right arguments. You are  not
>>> giving it two strings, which
>>> is what it expects. This is what the error message says.
>>>
>>> Victor
>>>
>>> On 11 Oct 2010, at 17:48, Art Hunkins wrote:
>>>
>>>> don't now believe any of the WARNING messages, including the  final 
>>>> one,
>>>> are causing the problem; I believe that the SetChannel call is the
>>>> culprit.
>>>> (Is it possible Oeyvind is on the right track?)
>>>>
>>>> A final thought: You mentioned the Csound API hadn't been  modified 
>>>> since
>>>> 5.10. I wonder if there's any chance that SoaS 0.86.3 (the Sugar
>>>> Blueberry
>>>> version I'm testing with) could be using an older API? Or would   there 
>>>> be
>>>> any
>>>> difference? The Csound is 5.10, and all *should* have been  updated  at
>>>> that
>>>> time, right?
>>>>
>>>> Art Hunkins
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Nokia and AT&T present the 2010 Calling All Innovators-North America 
>> contest
>> Create new apps & games for the Nokia N8 for consumers in  U.S. and 
>> Canada
>> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in 
>> marketing
>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi  Store
>> http://p.sf.net/sfu/nokia-dev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-10-24 20:58
FromVictor Lazzarini
SubjectRe: [Cs-dev] Fw: Csound API Question?
You should not add self.ready = True, because this is a test of  
compilation, which should
not be done by you, only internally. In any case, the test was for it  
to be False, not True. If
Csound has not been compiled, the SetChannel() call will not do  
anything, so none of the
things you've done will correctly test this.

Did you try writing a simple application based on the csndsugui  
examples in the git repository,
like the Playfile activity?

I would suggest you do so. My idea for csndsugui is that some methods,  
like set_filechannel()
do not necessarily need to be called directly. If you use a  
filechooser like this:

win.csd("playfile.csd")
win.filechooser(bbox,"soundfile")

you will get a filechooser button which will open a dialog and the  
selected file will be
passed to the CSD in the "soundfile" channe, like so:

S1 chnget "soundfile"
i1 strcmp S1,"0"
  if i1 != 0 goto continue
  puts "no filename selected !!", 1
  turnoff
  goto end
  continue:
...

If you are not using this mechanism, then you may as well call the  
Csound class method
SetChannel() directly, or via the set_channel() wrapper (which checks  
if self.ready is not True).

directly:
obj.csound.SetChannel(name, string)

via set_channel
obj.set_channel(name, string)

where obj is your CsoundGUI object.

If csound is compiled, any of these will work. They will fail if  
csound is not compiled.

Victor

On 24 Oct 2010, at 20:21, Art Hunkins wrote:

> Victor,
>
> Attempting to implement your pointer, I tried the following:
>
> 1) I added the line:
> self.ready = True
> before my call to set_filechannel
>
> 2) In the set_filechannel method (in csndsugui), I commented out  
> lines 3, 5
> and 6 - leaving only the call to csound.SetChannel.
>
> Neither of these changes made any difference; still no filename, nor  
> even
> "ahha" passed to my csd.
>
> Please note that I also tried a sequence that first selects and  
> compiles the
> csd, whereupon the performer selects a variety of performance  
> parameters
> passed successfully via chnexport *and selecting the desired file  
> from the
> Journal (our issue)*, then performing. Passing all the other values  
> works
> fine (of course, different methods are employed). Same result.
>
> Any further suggestions are most welcome (from anyone).
>
> Victor, I really appreciate your help trying to troubleshoot me  
> through
> this.
>
> Art Hunkins
>
> ----- Original Message -----
> From: "Victor Lazzarini" 
> To: "Art Hunkins" ; "Developer discussions"
> 
> Sent: Sunday, October 24, 2010 4:38 AM
> Subject: Re: [Cs-dev] Fw: Csound API Question?
>
>
>> The definition of the method is:
>>
>> def set_filechannel(self,chan,name):
>> """overrides the base method, setting the channel string"""
>>  if not self.ready:
>>      self.csound.SetChannel(chan,name)
>>  else:
>>      BasicGUI.set_filechannel(self,chan,name)
>>
>> So, what happens is that if the variable 'ready' is True, this  
>> uses  the
>> base class method (ie. does not call
>> SetChannel). Maybe that is the problem.
>>
>> 'ready' becomes True after a successful compilation using CsoundGUI.
>> compile() or CsoundGUI.csd()
>> or CsoundGUI.recompile().
>>
>>
>> Victor
>>
>>
>>
>> On 24 Oct 2010, at 03:17, Art Hunkins wrote:
>>
>>> I've been having a terrible time getting a filename communicated   
>>> through
>>> the
>>> API to my csd (Python, XO, Sugar 0.84).
>>>
>>> The particular method, which works fine otherwise, and uses calls  
>>> from
>>> Victor's csndsugui, is as follows:
>>> def choose(self, widget):
>>>
>>> self.chooser = ObjectChooser(parent=self,
>>> what_filter=mime.GENERIC_TYPE_AUDIO)
>>>
>>> self.result = self.chooser.run()
>>>
>>> if self.result == gtk.RESPONSE_ACCEPT:
>>>
>>>   self.jobject = self.chooser.get_selected_object()
>>>
>>>   if self.jobject and self.jobject.file_path:
>>>
>>>     self.filename1 = self.jobject.file_path
>>>
>>>     print 'FileName = ', self.filename1
>>>
>>>     self.w.set_filechannel("filename1", self.filename1)
>>>
>>>
>>>
>>> No errors  are logged.
>>>
>>> Sname chnget "filename1", and puts Sname, 1
>>>
>>> (within an instrument in my csd) simply receives a blank filename.
>>> However,
>>> "FileName =" in the above code prints out correctly, i.e., the  
>>> file  has
>>> been
>>> correctly located.
>>>
>>> The same null result occurs when self.filename1 in the last line of
>>> above
>>> code is, instead, "haha" (as illustrated in Victor's example).
>>>
>>> I've discovered that I was retrieving the filename before the .csd  
>>> was
>>> compiled. Perhaps this is a problem? In any case, I also tried   
>>> selecting
>>> the
>>> filename (i.e., running the above method, which is triggered by a   
>>> button
>>> press) after .csd compilation and before running - same result (no
>>> communication).
>>>
>>> I'd much appreciate any clues, please. My Python skills are so   
>>> minimal,
>>> and
>>> this issue has been stumping me for months now.
>>>
>>> Art Hunkins
>>>
>>> ----- Original Message -----
>>> From: "Victor Lazzarini" 
>>> To: "Art Hunkins" ; "Developer discussions"
>>> 
>>> Sent: Tuesday, October 12, 2010 4:58 AM
>>> Subject: Re: [Cs-dev] Fw: Csound API Question?
>>>
>>>
>>>> No, SetChannel() works properly, the script I placed here showed   
>>>> that
>>>> it
>>>> does. The problem
>>>> is that your program is not giving it the right arguments. You  
>>>> are  not
>>>> giving it two strings, which
>>>> is what it expects. This is what the error message says.
>>>>
>>>> Victor
>>>>
>>>> On 11 Oct 2010, at 17:48, Art Hunkins wrote:
>>>>
>>>>> don't now believe any of the WARNING messages, including the   
>>>>> final
>>>>> one,
>>>>> are causing the problem; I believe that the SetChannel call is the
>>>>> culprit.
>>>>> (Is it possible Oeyvind is on the right track?)
>>>>>
>>>>> A final thought: You mentioned the Csound API hadn't been   
>>>>> modified
>>>>> since
>>>>> 5.10. I wonder if there's any chance that SoaS 0.86.3 (the Sugar
>>>>> Blueberry
>>>>> version I'm testing with) could be using an older API? Or  
>>>>> would   there
>>>>> be
>>>>> any
>>>>> difference? The Csound is 5.10, and all *should* have been   
>>>>> updated  at
>>>>> that
>>>>> time, right?
>>>>>
>>>>> Art Hunkins
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Nokia and AT&T present the 2010 Calling All Innovators-North America
>>> contest
>>> Create new apps & games for the Nokia N8 for consumers in  U.S. and
>>> Canada
>>> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
>>> marketing
>>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to  
>>> Ovi  Store
>>> http://p.sf.net/sfu/nokia-dev2dev
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America  
> contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and  
> Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in  
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi  
> Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net