| This comes back to what I said the first time you asked the question
here. The variable 'name' in your code does not
appear to be a string. Find out what it is and try to pass a string to
SetChannel(). If you are selecting files, why don't you
use CsoundGUI.filechooser(), that is designed to create a button for a
filechooser window and pass the chosen file to
a channel?
Regards
Victor
On 30 Oct 2010, at 03:10, Art Hunkins wrote:
> Victor,
>
> I've corrected several of my (sometimes silly) mistakes, and think
> I've come
> close to spotting the problem: it seems to have to do with the kind
> of file
> string input that SetChannel() expects.
>
> In a simplified script from my FileMix activity, I get this error
> (per log):
>
> SECTION 1:
> FileName =
> /home/olpc/.sugar/default/data/5c073d96-6757-4632-b75f-
> af09fce807afprJ92j.ogg
> Traceback (most recent call last):
> File "/home/olpc/Activities/FileMix.activity/filemix.py", line 65, in
> version3
> self.w.set_filechannel("file1", self.filename)
> File "/home/olpc/Activities/FileMix.activity/csndsugui.py", line
> 661, in
> set_filechannel
> self.csound.SetChannel(chan,name)
> File "/usr/lib/python2.6/site-packages/csnd.py", line 1736, in
> SetChannel
> return _csnd.Csound_SetChannel(self, *args)
> NotImplementedError: Wrong number of arguments for overloaded function
> 'Csound_SetChannel'.
> Possible C/C++ prototypes are:
> SetChannel(Csound *,char const *,double)
> SetChannel(Csound *,char const *,char const *)
>
> Please note that the filename printed above is self.filename and a
> bonafide
> (and valid) soundfile located in the Journal. The code that actually
> derives
> the filename is:
> self.filename = jobject.file_path
> Apparently this is unacceptable (string) input to SetChannel().
> Perhaps it's
> too long, *wrong format* or something (see further below)?
>
> Incidentally self.filename is originally defined as:
> self.filename = "0"
>
> I tried your two suggested alternatives - w.csound.SetChannel(name,
> string)
> and w.set_channel(name, string) - with the same result.
>
> Finally, compilation is indeed done prior to the SetChannel call, in
> this
> direct sequence:
> self.w.csd("FileMix.csd")
> self.p = False
> self.w.set_filechannel("file1", self.filename)
>
> I might also add that when I set:
> self.filename = "ahha"
> that "ahha" has no problem getting accepted by SetChannel() and
> my .csd.
> Likewise, strangely, when I paste the .ogg filename either into:
> self.filename = "xxx.ogg"
> or into: self.w.set_filechannel("file1", "xxx.ogg")
> everything works fine as well.
>
> Can this indicate some kind of string formatting issue with regard
> to the
> filename?
>
> Art Hunkins
>
> ----- Original Message -----
> From: "Victor Lazzarini"
> To: "Art Hunkins" ; "Developer discussions"
>
> Sent: Sunday, October 24, 2010 3:58 PM
> Subject: Re: [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
> 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 |