Csound Csound-dev Csound-tekno Search About

Python string variables in csound

Date2015-12-31 11:11
FromAlex Weiss
SubjectPython string variables in csound
Hello,

I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?

Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.

Thanks,
Alex
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 15:34
FromVictor Lazzarini
SubjectRe: Python string variables in csound
You could use a string channel. Take the running Csound instance and call the relevant
API function from python. In this page there are instructions on how to access the
Csound instance.

http://www.csounds.com/manual/html/pyinit.html


========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 31 Dec 2015, at 11:11, Alex Weiss  wrote:
> 
> Hello,
> 
> I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> 
> Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> 
> Thanks,
> Alex
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2015-12-31 18:02
FromAlex Weiss
SubjectRe: Python string variables in csound
Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code: 

pyruni {{

import os, random, csnd6

filename = random.choice(os.listdir("."))

c = csnd6.csoundGetInstance(_CSOUND_)

c.SetChannel("filename", filename)

}}


The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?


Thanks,

Alex


On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You could use a string channel. Take the running Csound instance and call the relevant
API function from python. In this page there are instructions on how to access the
Csound instance.

http://www.csounds.com/manual/html/pyinit.html


========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Hello,
>
> I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
>
> Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
>
> Thanks,
> Alex
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 18:14
FromVictor Lazzarini
SubjectRe: Python string variables in csound
Try using

c.csoundSetStringChannel()

regards
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 31 Dec 2015, at 18:02, Alex Weiss  wrote:
> 
> Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code: 
> 
> pyruni {{
> import os, random, csnd6
> filename = random.choice(os.listdir("."))
> c = csnd6.csoundGetInstance(_CSOUND_)
> c.SetChannel("filename", filename)
> }}
> 
> The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> 
> Thanks,
> Alex
> 
> On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini  wrote:
> You could use a string channel. Take the running Csound instance and call the relevant
> API function from python. In this page there are instructions on how to access the
> Csound instance.
> 
> http://www.csounds.com/manual/html/pyinit.html
> 
> 
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
> 
> > On 31 Dec 2015, at 11:11, Alex Weiss  wrote:
> >
> > Hello,
> >
> > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> >
> > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> >
> > Thanks,
> > Alex
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2015-12-31 19:00
FromAlex Weiss
SubjectRe: Python string variables in csound
Already tried that to no avail, unfortunately.

Alex

On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Try using

c.csoundSetStringChannel()

regards
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
>
> pyruni {{
> import os, random, csnd6
> filename = random.choice(os.listdir("."))
> c = csnd6.csoundGetInstance(_CSOUND_)
> c.SetChannel("filename", filename)
> }}
>
> The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
>
> Thanks,
> Alex
>
> On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> You could use a string channel. Take the running Csound instance and call the relevant
> API function from python. In this page there are instructions on how to access the
> Csound instance.
>
> http://www.csounds.com/manual/html/pyinit.html
>
>
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Hello,
> >
> > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> >
> > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> >
> > Thanks,
> > Alex
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 19:08
FromHlöðver Sigurðsson
SubjectRe: Python string variables in csound
Yes, looks like you are calling to samples? As a rule of thumb for API's is to try to use the API's functionalities as much as possible. So if you call a file, store it in a table, and you could do a random choose on table number, or what I usually do, store then in a csound array and call just the array with index number (can be done with random of course too). Maybe if you describe what you want to do, there may be a better way to solve it. I use API a lot but never nedded to send strings in between, the casting could be slow as well, dont know.



2015-12-31 20:00 GMT+01:00 Alex Weiss <alexweiss86@gmail.com>:
Already tried that to no avail, unfortunately.

Alex

On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Try using

c.csoundSetStringChannel()

regards
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
>
> pyruni {{
> import os, random, csnd6
> filename = random.choice(os.listdir("."))
> c = csnd6.csoundGetInstance(_CSOUND_)
> c.SetChannel("filename", filename)
> }}
>
> The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
>
> Thanks,
> Alex
>
> On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> You could use a string channel. Take the running Csound instance and call the relevant
> API function from python. In this page there are instructions on how to access the
> Csound instance.
>
> http://www.csounds.com/manual/html/pyinit.html
>
>
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Hello,
> >
> > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> >
> > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> >
> > Thanks,
> > Alex
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 19:19
FromVictor Lazzarini
SubjectRe: Python string variables in csound
Sorry, I should have said

 csnd6.csoundSetStringChannel(c, "filename", filename)

That’ll work.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 31 Dec 2015, at 19:00, Alex Weiss  wrote:
> 
> Already tried that to no avail, unfortunately.
> 
> Alex
> 
> On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini  wrote:
> Try using
> 
> c.csoundSetStringChannel()
> 
> regards
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
> 
> > On 31 Dec 2015, at 18:02, Alex Weiss  wrote:
> >
> > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
> >
> > pyruni {{
> > import os, random, csnd6
> > filename = random.choice(os.listdir("."))
> > c = csnd6.csoundGetInstance(_CSOUND_)
> > c.SetChannel("filename", filename)
> > }}
> >
> > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> >
> > Thanks,
> > Alex
> >
> > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini  wrote:
> > You could use a string channel. Take the running Csound instance and call the relevant
> > API function from python. In this page there are instructions on how to access the
> > Csound instance.
> >
> > http://www.csounds.com/manual/html/pyinit.html
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Dean of Arts, Celtic Studies and Philosophy,
> > Maynooth University,
> > Maynooth, Co Kildare, Ireland
> > Tel: 00 353 7086936
> > Fax: 00 353 1 7086952
> >
> > > On 31 Dec 2015, at 11:11, Alex Weiss  wrote:
> > >
> > > Hello,
> > >
> > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> > >
> > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> > >
> > > Thanks,
> > > Alex
> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-01-01 09:10
FromRory Walsh
SubjectRe: Python string variables in csound
Attachmentsftsamplebank.cpp  
In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.

;ftsamplebank will load all samples in a given directory into function
;tables, and return the number of table created
;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
;iSkipTime, iFormat, iChannel,

instr 1000
   iFirstTableNumber = 60;
   iTrig = 1
   i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
endin

On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Sorry, I should have said

 csnd6.csoundSetStringChannel(c, "filename", filename)

That’ll work.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Already tried that to no avail, unfortunately.
>
> Alex
>
> On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Try using
>
> c.csoundSetStringChannel()
>
> regards
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
> >
> > pyruni {{
> > import os, random, csnd6
> > filename = random.choice(os.listdir("."))
> > c = csnd6.csoundGetInstance(_CSOUND_)
> > c.SetChannel("filename", filename)
> > }}
> >
> > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> >
> > Thanks,
> > Alex
> >
> > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > You could use a string channel. Take the running Csound instance and call the relevant
> > API function from python. In this page there are instructions on how to access the
> > Csound instance.
> >
> > http://www.csounds.com/manual/html/pyinit.html
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Dean of Arts, Celtic Studies and Philosophy,
> > Maynooth University,
> > Maynooth, Co Kildare, Ireland
> > Tel: 00 353 7086936
> > Fax: 00 353 1 7086952
> >
> > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> > >
> > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> > >
> > > Thanks,
> > > Alex
> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-01 11:50
FromAlex Weiss
SubjectRe: Python string variables in csound
Great opcode. But I would prefer not to have to load all files into tables, as there are a lot of them (some fairly big), and each performance only uses a few of them. Victor's channel method is working now, though.

Thanks everybody and happy new year,
Alex

On Fri, Jan 1, 2016 at 10:11 AM Rory Walsh <rorywalsh@ear.ie> wrote:
In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.

;ftsamplebank will load all samples in a given directory into function
;tables, and return the number of table created
;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
;iSkipTime, iFormat, iChannel,

instr 1000
   iFirstTableNumber = 60;
   iTrig = 1
   i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
endin

On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Sorry, I should have said

 csnd6.csoundSetStringChannel(c, "filename", filename)

That’ll work.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Already tried that to no avail, unfortunately.
>
> Alex
>
> On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Try using
>
> c.csoundSetStringChannel()
>
> regards
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
> >
> > pyruni {{
> > import os, random, csnd6
> > filename = random.choice(os.listdir("."))
> > c = csnd6.csoundGetInstance(_CSOUND_)
> > c.SetChannel("filename", filename)
> > }}
> >
> > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> >
> > Thanks,
> > Alex
> >
> > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > You could use a string channel. Take the running Csound instance and call the relevant
> > API function from python. In this page there are instructions on how to access the
> > Csound instance.
> >
> > http://www.csounds.com/manual/html/pyinit.html
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Dean of Arts, Celtic Studies and Philosophy,
> > Maynooth University,
> > Maynooth, Co Kildare, Ireland
> > Tel: 00 353 7086936
> > Fax: 00 353 1 7086952
> >
> > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> > >
> > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> > >
> > > Thanks,
> > > Alex
> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-01 11:57
FromVictor Lazzarini
SubjectRe: Python string variables in csound
Is there any reason for this not to be included in the Csound sources? 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 1 Jan 2016, at 09:10, Rory Walsh <rorywalsh@EAR.IE> wrote:

In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.

;ftsamplebank will load all samples in a given directory into function
;tables, and return the number of table created
;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
;iSkipTime, iFormat, iChannel,

instr 1000
   iFirstTableNumber = 60;
   iTrig = 1
   i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
endin

On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Sorry, I should have said

 csnd6.csoundSetStringChannel(c, "filename", filename)

That’ll work.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Already tried that to no avail, unfortunately.
>
> Alex
>
> On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Try using
>
> c.csoundSetStringChannel()
>
> regards
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
> >
> > pyruni {{
> > import os, random, csnd6
> > filename = random.choice(os.listdir("."))
> > c = csnd6.csoundGetInstance(_CSOUND_)
> > c.SetChannel("filename", filename)
> > }}
> >
> > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> >
> > Thanks,
> > Alex
> >
> > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > You could use a string channel. Take the running Csound instance and call the relevant
> > API function from python. In this page there are instructions on how to access the
> > Csound instance.
> >
> > http://www.csounds.com/manual/html/pyinit.html
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Dean of Arts, Celtic Studies and Philosophy,
> > Maynooth University,
> > Maynooth, Co Kildare, Ireland
> > Tel: 00 353 7086936
> > Fax: 00 353 1 7086952
> >
> > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> > >
> > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> > >
> > > Thanks,
> > > Alex
> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
<ftsamplebank.cpp>

Date2016-01-01 12:02
FromRory Walsh
SubjectRe: Python string variables in csound
Feel free to drop it in. I will write a manual page.

On 1 January 2016 at 11:57, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Is there any reason for this not to be included in the Csound sources? 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 1 Jan 2016, at 09:10, Rory Walsh <rorywalsh@EAR.IE> wrote:

In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.

;ftsamplebank will load all samples in a given directory into function
;tables, and return the number of table created
;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
;iSkipTime, iFormat, iChannel,

instr 1000
   iFirstTableNumber = 60;
   iTrig = 1
   i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
endin

On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Sorry, I should have said

 csnd6.csoundSetStringChannel(c, "filename", filename)

That’ll work.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>
> Already tried that to no avail, unfortunately.
>
> Alex
>
> On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Try using
>
> c.csoundSetStringChannel()
>
> regards
> ========================
> Dr Victor Lazzarini
> Dean of Arts, Celtic Studies and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
> >
> > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
> >
> > pyruni {{
> > import os, random, csnd6
> > filename = random.choice(os.listdir("."))
> > c = csnd6.csoundGetInstance(_CSOUND_)
> > c.SetChannel("filename", filename)
> > }}
> >
> > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
> >
> > Thanks,
> > Alex
> >
> > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > You could use a string channel. Take the running Csound instance and call the relevant
> > API function from python. In this page there are instructions on how to access the
> > Csound instance.
> >
> > http://www.csounds.com/manual/html/pyinit.html
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Dean of Arts, Celtic Studies and Philosophy,
> > Maynooth University,
> > Maynooth, Co Kildare, Ireland
> > Tel: 00 353 7086936
> > Fax: 00 353 1 7086952
> >
> > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
> > >
> > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
> > >
> > > Thanks,
> > > Alex
> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
<ftsamplebank.cpp>
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-01 12:29
FromVictor Lazzarini
SubjectRe: Python string variables in csound
done. 
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 1 Jan 2016, at 12:02, Rory Walsh  wrote:
> 
> Feel free to drop it in. I will write a manual page. 
> 
> On 1 January 2016 at 11:57, Victor Lazzarini  wrote:
> Is there any reason for this not to be included in the Csound sources? 
> 
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
> 
> On 1 Jan 2016, at 09:10, Rory Walsh  wrote:
> 
>> In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use. 
>> 
>> ;ftsamplebank will load all samples in a given directory into function 
>> ;tables, and return the number of table created 
>> ;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber, 
>> ;iSkipTime, iFormat, iChannel, 
>> 
>> instr 1000 
>>    iFirstTableNumber = 60; 
>>    iTrig = 1 
>>    i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1 
>> endin 
>> 
>> On 31 December 2015 at 19:19, Victor Lazzarini  wrote:
>> Sorry, I should have said
>> 
>>  csnd6.csoundSetStringChannel(c, "filename", filename)
>> 
>> That’ll work.
>> ========================
>> Dr Victor Lazzarini
>> Dean of Arts, Celtic Studies and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>> 
>> > On 31 Dec 2015, at 19:00, Alex Weiss  wrote:
>> >
>> > Already tried that to no avail, unfortunately.
>> >
>> > Alex
>> >
>> > On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini  wrote:
>> > Try using
>> >
>> > c.csoundSetStringChannel()
>> >
>> > regards
>> > ========================
>> > Dr Victor Lazzarini
>> > Dean of Arts, Celtic Studies and Philosophy,
>> > Maynooth University,
>> > Maynooth, Co Kildare, Ireland
>> > Tel: 00 353 7086936
>> > Fax: 00 353 1 7086952
>> >
>> > > On 31 Dec 2015, at 18:02, Alex Weiss  wrote:
>> > >
>> > > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
>> > >
>> > > pyruni {{
>> > > import os, random, csnd6
>> > > filename = random.choice(os.listdir("."))
>> > > c = csnd6.csoundGetInstance(_CSOUND_)
>> > > c.SetChannel("filename", filename)
>> > > }}
>> > >
>> > > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
>> > >
>> > > Thanks,
>> > > Alex
>> > >
>> > > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini  wrote:
>> > > You could use a string channel. Take the running Csound instance and call the relevant
>> > > API function from python. In this page there are instructions on how to access the
>> > > Csound instance.
>> > >
>> > > http://www.csounds.com/manual/html/pyinit.html
>> > >
>> > >
>> > > ========================
>> > > Dr Victor Lazzarini
>> > > Dean of Arts, Celtic Studies and Philosophy,
>> > > Maynooth University,
>> > > Maynooth, Co Kildare, Ireland
>> > > Tel: 00 353 7086936
>> > > Fax: 00 353 1 7086952
>> > >
>> > > > On 31 Dec 2015, at 11:11, Alex Weiss  wrote:
>> > > >
>> > > > Hello,
>> > > >
>> > > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
>> > > >
>> > > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
>> > > >
>> > > > Thanks,
>> > > > Alex
>> > > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> > >
>> > > Csound mailing list
>> > > Csound@listserv.heanet.ie
>> > > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > > Send bugs reports to
>> > >         https://github.com/csound/csound/issues
>> > > Discussions of bugs and features can be posted here
>> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> >
>> > Csound mailing list
>> > Csound@listserv.heanet.ie
>> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > Send bugs reports to
>> >         https://github.com/csound/csound/issues
>> > Discussions of bugs and features can be posted here
>> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> 
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>> 
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-01-01 13:30
FromRory Walsh
SubjectRe: Python string variables in csound
Attachmentsftsamplebank.cpp  ftsamplebank.csd  ftsamplebank.xml  
Attached is a manual .xml entry, a simple example of the opcode in use and an updated version of the source code. Thanks.  

On 1 January 2016 at 12:29, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
done.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 1 Jan 2016, at 12:02, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> Feel free to drop it in. I will write a manual page.
>
> On 1 January 2016 at 11:57, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Is there any reason for this not to be included in the Csound sources?
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
> On 1 Jan 2016, at 09:10, Rory Walsh <rorywalsh@EAR.IE> wrote:
>
>> In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.
>>
>> ;ftsamplebank will load all samples in a given directory into function
>> ;tables, and return the number of table created
>> ;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
>> ;iSkipTime, iFormat, iChannel,
>>
>> instr 1000
>>    iFirstTableNumber = 60;
>>    iTrig = 1
>>    i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
>> endin
>>
>> On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> Sorry, I should have said
>>
>>  csnd6.csoundSetStringChannel(c, "filename", filename)
>>
>> That’ll work.
>> ========================
>> Dr Victor Lazzarini
>> Dean of Arts, Celtic Studies and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>>
>> > On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>> >
>> > Already tried that to no avail, unfortunately.
>> >
>> > Alex
>> >
>> > On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> > Try using
>> >
>> > c.csoundSetStringChannel()
>> >
>> > regards
>> > ========================
>> > Dr Victor Lazzarini
>> > Dean of Arts, Celtic Studies and Philosophy,
>> > Maynooth University,
>> > Maynooth, Co Kildare, Ireland
>> > Tel: 00 353 7086936
>> > Fax: 00 353 1 7086952
>> >
>> > > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
>> > >
>> > > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
>> > >
>> > > pyruni {{
>> > > import os, random, csnd6
>> > > filename = random.choice(os.listdir("."))
>> > > c = csnd6.csoundGetInstance(_CSOUND_)
>> > > c.SetChannel("filename", filename)
>> > > }}
>> > >
>> > > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
>> > >
>> > > Thanks,
>> > > Alex
>> > >
>> > > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> > > You could use a string channel. Take the running Csound instance and call the relevant
>> > > API function from python. In this page there are instructions on how to access the
>> > > Csound instance.
>> > >
>> > > http://www.csounds.com/manual/html/pyinit.html
>> > >
>> > >
>> > > ========================
>> > > Dr Victor Lazzarini
>> > > Dean of Arts, Celtic Studies and Philosophy,
>> > > Maynooth University,
>> > > Maynooth, Co Kildare, Ireland
>> > > Tel: 00 353 7086936
>> > > Fax: 00 353 1 7086952
>> > >
>> > > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
>> > > >
>> > > > Hello,
>> > > >
>> > > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
>> > > >
>> > > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
>> > > >
>> > > > Thanks,
>> > > > Alex
>> > > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> > >
>> > > Csound mailing list
>> > > Csound@listserv.heanet.ie
>> > > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > > Send bugs reports to
>> > >         https://github.com/csound/csound/issues
>> > > Discussions of bugs and features can be posted here
>> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> >
>> > Csound mailing list
>> > Csound@listserv.heanet.ie
>> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > Send bugs reports to
>> >         https://github.com/csound/csound/issues
>> > Discussions of bugs and features can be posted here
>> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> <ftsamplebank.cpp>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-01 17:47
Fromjoachim heintz
SubjectRe: Python string variables in csound
hi -

i see it's already solved.  just to note a csound-internal solution:  if 
you have your filename in a string like 
"/my/file/one.wav|/my/file/two.wav|/my/file/three.wav|/my/file/four.wav"[1], 
then you can use the udo StrToArr [2] to convert to an array of strings, 
and then (as hlödver mentioned) easily get one filename or path by a 
random opcode:

seed 0
instr 1
  S_InStr = 
"/my/file/one.wav|/my/file/two.wav|/my/file/three.wav|/my/file/four.wav"
  S_arr[], iLen StrToArr S_InStr, "|"
  S_rand = S_arr[random:i(0, iLen+.999)]
  puts S_rand, 1
endin

	joachim


[1] the seperator can be anything, including space
[2] 
https://github.com/csudo/csudo/blob/master/strings/conversion/StrToArr.csd


On 31/12/15 12:11, Alex Weiss wrote:
> Hello,
>
> I'm running into a problem with some of the python opcodes.
> Specifically, I have a python function that saves its return value into
> a python string. I then want to assign that string to a S-variable in
> csound. But it appears that none of the pyeval* opcodes can handle
> strings, only kvars. Any suggestions?
>
> Maybe there's also a way to bypass python altogether. All I'm trying to
> do is to pick a random filename from a directory.
>
> Thanks,
> Alex
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-03-01 23:35
From"Dr. Richard Boulanger"
SubjectRe: Python string variables in csound
Can't wait for the next release and to explore and use this new opcode.
-dB

_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design
Professional Writing and Music Technology Division


On Fri, Jan 1, 2016 at 8:30 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
Attached is a manual .xml entry, a simple example of the opcode in use and an updated version of the source code. Thanks.  

On 1 January 2016 at 12:29, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
done.
========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 1 Jan 2016, at 12:02, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> Feel free to drop it in. I will write a manual page.
>
> On 1 January 2016 at 11:57, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> Is there any reason for this not to be included in the Csound sources?
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
> On 1 Jan 2016, at 09:10, Rory Walsh <rorywalsh@EAR.IE> wrote:
>
>> In case you are looking to load random samples from a directory as Hlöðver suggested, you can try the attached opcode. Place it into your Csound build Opcodes folder and add make_plugin(ftsamplebank ftsamplebank.cpp) to the CMakeLists.txt in that same folder. Then run make in your build dir and away you go. Just pass it a directory, and it will automatically load all sound files into corresponding function tables. Below is a simple example of it in use.
>>
>> ;ftsamplebank will load all samples in a given directory into function
>> ;tables, and return the number of table created
>> ;iNumberOfFile ftsamplebank SDirectory, iTrigger, iFirstTableNumber,
>> ;iSkipTime, iFormat, iChannel,
>>
>> instr 1000
>>    iFirstTableNumber = 60;
>>    iTrig = 1
>>    i1 ftsamplebank "/home/rory/NiMPTi/Drums1", iTrig, iFirstTableNumber, 0, 4, 1
>> endin
>>
>> On 31 December 2015 at 19:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> Sorry, I should have said
>>
>>  csnd6.csoundSetStringChannel(c, "filename", filename)
>>
>> That’ll work.
>> ========================
>> Dr Victor Lazzarini
>> Dean of Arts, Celtic Studies and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>>
>> > On 31 Dec 2015, at 19:00, Alex Weiss <alexweiss86@gmail.com> wrote:
>> >
>> > Already tried that to no avail, unfortunately.
>> >
>> > Alex
>> >
>> > On Thu, Dec 31, 2015 at 7:15 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> > Try using
>> >
>> > c.csoundSetStringChannel()
>> >
>> > regards
>> > ========================
>> > Dr Victor Lazzarini
>> > Dean of Arts, Celtic Studies and Philosophy,
>> > Maynooth University,
>> > Maynooth, Co Kildare, Ireland
>> > Tel: 00 353 7086936
>> > Fax: 00 353 1 7086952
>> >
>> > > On 31 Dec 2015, at 18:02, Alex Weiss <alexweiss86@gmail.com> wrote:
>> > >
>> > > Thanks Victor. Getting closer, but I'm getting an error now. Here's the python code:
>> > >
>> > > pyruni {{
>> > > import os, random, csnd6
>> > > filename = random.choice(os.listdir("."))
>> > > c = csnd6.csoundGetInstance(_CSOUND_)
>> > > c.SetChannel("filename", filename)
>> > > }}
>> > >
>> > > The error message I'm getting is "AttributeError: 'SwigPyObject' object has no attribute 'SetChannel'". Any suggestions?
>> > >
>> > > Thanks,
>> > > Alex
>> > >
>> > > On Thu, Dec 31, 2015 at 4:34 PM Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>> > > You could use a string channel. Take the running Csound instance and call the relevant
>> > > API function from python. In this page there are instructions on how to access the
>> > > Csound instance.
>> > >
>> > > http://www.csounds.com/manual/html/pyinit.html
>> > >
>> > >
>> > > ========================
>> > > Dr Victor Lazzarini
>> > > Dean of Arts, Celtic Studies and Philosophy,
>> > > Maynooth University,
>> > > Maynooth, Co Kildare, Ireland
>> > > Tel: 00 353 7086936
>> > > Fax: 00 353 1 7086952
>> > >
>> > > > On 31 Dec 2015, at 11:11, Alex Weiss <alexweiss86@gmail.com> wrote:
>> > > >
>> > > > Hello,
>> > > >
>> > > > I'm running into a problem with some of the python opcodes. Specifically, I have a python function that saves its return value into a python string. I then want to assign that string to a S-variable in csound. But it appears that none of the pyeval* opcodes can handle strings, only kvars. Any suggestions?
>> > > >
>> > > > Maybe there's also a way to bypass python altogether. All I'm trying to do is to pick a random filename from a directory.
>> > > >
>> > > > Thanks,
>> > > > Alex
>> > > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> > >
>> > > Csound mailing list
>> > > Csound@listserv.heanet.ie
>> > > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > > Send bugs reports to
>> > >         https://github.com/csound/csound/issues
>> > > Discussions of bugs and features can be posted here
>> > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> >
>> > Csound mailing list
>> > Csound@listserv.heanet.ie
>> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> > Send bugs reports to
>> >         https://github.com/csound/csound/issues
>> > Discussions of bugs and features can be posted here
>> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> <ftsamplebank.cpp>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here