Csound Csound-dev Csound-tekno Search About

Re: [Csnd] Python help please

Date2011-08-24 20:23
From"Art Hunkins"
SubjectRe: [Csnd] Python help please
Thanks, Tarmo.

I'm a big fan of soundin.x and use it for my default soundfiles. When users 
substitute their own files, I need to be able to pass *their* filenames as 
well. So, both/and.

Art Hunkins

----- Original Message ----- 
From: "Tarmo Johannes" 
To: 
Cc: "Art Hunkins" 
Sent: Wednesday, August 24, 2011 11:23 AM
Subject: Re: [Csnd] Python help please


> Hello,
>
> and another hint,  perhaps it is useful:
> if you play the audio samples  in csound with diskin, diskin2, diskin or 
> soundin,  the filename can be given also as integer  number
> like
> aL,aR soundin 1
>
> the number  " denotes the file soundin.filcod;" (from the manual).
>
> If you put your files to the same directory as the csd and rename them 
> soundin.1, soundin.2 etc
> you can pass just the number and get rid from the business with strings - 
> it is always easier to manipulate the  numbers.
>
> tarmo
>
> On Wednesday 24 August 2011 17:31:02 Art Hunkins wrote:
>> I've written a Python script for a new XO/Sugar activity for children
>> (SamplePlay).
>> It includes 26 buttons that allow a user to select (from the Journal) up 
>> to
>> 26 audio
>> samples/loops to play. AFAIK, the "filename" must be sent to Csound as a
>> discrete variable, on its own channel (see below).
>>
>> As a result, I've 26 iterations(!) (0-25) of the same basic code. I'd 
>> like
>> to simplify it if possible (the code itself works fine). Any suggestions
>> from
>> you Python/Csound enthusiasts are very much welcomed. (The code 
>> references
>> Victor's csndsugui.py, but I don't think this is significant her
>>
>>    self.path0 = "0"
>>   (up through)
>>    self.path25 = "0"
>>
>>    self.jobject0 = None
>>   (through)
>>    self.jobject25 = None
>>
>>  def choose0(self, widget):
>>    chooser = ObjectChooser(parent=self, 
>> what_filter=mime.GENERIC_TYPE_AUDIO)
>>    result = chooser.run()
>>    if result == gtk.RESPONSE_ACCEPT:
>>      self.jobject0 = chooser.get_selected_object()
>>      self.path0 = str(self.jobject0.get_file_path())
>>    else:
>>      self.jobject0 = None
>>      self.path0 = "0"
>>   (through)
>> def choose25(self, widget):
>>    chooser = ObjectChooser(parent=self, 
>> what_filter=mime.GENERIC_TYPE_AUDIO)
>>    result = chooser.run()
>>    if result == gtk.RESPONSE_ACCEPT:
>>      self.jobject25 = chooser.get_selected_object()
>>      self.path25 = str(self.jobject25.get_file_path())
>>    else:
>>      self.jobject25 = None
>>      self.path25 = "0"
>>
>> def send_data(self):
>>    self.w.set_filechannel("file0", self.path0)
>>    self.w.set_filechannel("file1", self.path1)
>>   (through)
>>    self.w.set_filechannel("file24", self.path24)
>>    self.w.set_filechannel("file25", self.path25)
>>
>>
>> Hoping (as a Python novice) to be shown a more efficient way; I'm in the
>> dark -
>>
>> 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"