Csound Csound-dev Csound-tekno Search About

[Csnd] Pass strings from python to csound

Date2018-10-14 10:29
FromAndreas Bergsland
Subject[Csnd] Pass strings from python to csound

Hi

I would like to propose expanding the pyeval and pycall family of opcodes so that strings can be passed from python to csound, e.g. maybe with type as an optional parameter

Sarg       pyeval   “String”, “s”

Sresult     pycall1  "callable", karg1, “s”

Right now I am searching for a method to extract the names of the folders to a string array in csound. I tried different paths, e.g. doing a ascii conversion using floats from python, but it tends to be buggy.

Earlier I have also tried the write to file from python and then reading it from csound. But I have not found a way to read strings from a file other than by #include, which created it own set of problems.

Any tips on this issue is also appreciated.

Best,

Andreas

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/artec


Date2018-10-14 11:39
FromTarmo Johannes
SubjectRe: [Csnd] Pass strings from python to csound
+1
I have missed passing strings very much.
Tarmo

P, 14. oktoober 2018 12:29 Andreas Bergsland <andreas.bergsland@ntnu.no> kirjutas:

Hi

I would like to propose expanding the pyeval and pycall family of opcodes so that strings can be passed from python to csound, e.g. maybe with type as an optional parameter

Sarg       pyeval   “String”, “s”

Sresult     pycall1  "callable", karg1, “s”

Right now I am searching for a method to extract the names of the folders to a string array in csound. I tried different paths, e.g. doing a ascii conversion using floats from python, but it tends to be buggy.

Earlier I have also tried the write to file from python and then reading it from csound. But I have not found a way to read strings from a file other than by #include, which created it own set of problems.

Any tips on this issue is also appreciated.

Best,

Andreas

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/artec

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

Date2018-10-14 12:14
FromVictor Lazzarini
SubjectRe: [Csnd] Pass strings from python to csound
No problem with this particular proposal, however we need to have a discussion about
the future of these opcodes, especially in Csound 7. The fact is that maintaining them might
become problematic, as moving to Python 3 in the context of embedding via ctcsound 
is the norm. I am also not sure whether Python 2 will be retired in later versions of MacOS
as well. 

So whatever we do, they should be ported to Python 3. Ideally we would want these opcodes
to be more easily maintained. My impression is that originally the C code auto generated from
Python code, but it is not the case anymore, although there *.py files there that were the original
sources (not sure if they are still usable).

These opcodes bring a dependency to the Csound project that might not be desirable
in the long run. Our plan would be to move all opcode libraries with external dependencies
to separate projects/repos and this is one slated for that. I think that would also facilitate
finding maintainers and thus freeing the core developers to think about the system rather
than multiple components and their dependencies.

========================
Prof. 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 14 Oct 2018, at 10:29, Andreas Bergsland  wrote:
> 
> Hi
> 
> I would like to propose expanding the pyeval and pycall family of opcodes so that strings can be passed from python to csound, e.g. maybe with type as an optional parameter
> 
> Sarg       pyeval   “String”, “s”
> 
> Sresult     pycall1  "callable", karg1, “s”
> 
> Right now I am searching for a method to extract the names of the folders to a string array in csound. I tried different paths, e.g. doing a ascii conversion using floats from python, but it tends to be buggy.
> 
> Earlier I have also tried the write to file from python and then reading it from csound. But I have not found a way to read strings from a file other than by #include, which created it own set of problems.
> 
> Any tips on this issue is also appreciated.
> 
> Best,
> 
> Andreas
> 
>  
> 
> -- 
> 
> Andreas Bergsland
> 
>  
> 
> Associate professor - førsteamanuensis
> 
> Study Programme Leader - studieprogramleder
> 
> Music Technology Programme - Musikkteknologiseksjonen
> 
> Department of Music - Institutt for musikk
> 
> Olavskvartalet
> 
> NTNU (Norwegian University of Science and Technology)
> 
> 7491 Trondheim, NORWAY
> 
>  
> 
> Visiting address/besøksadresse: Fjordgt.1 (3.etg.)
> 
> e-mail: andreas.bergsland@ntnu.no
> 
> Office phone (Skype for business):7359 0096
> 
> Mobil: 4566 3316
> 
> http://folk.ntnu.no/andbe
> 
> https://www.vibra.no/
> 
> https://www.ntnu.edu/artec
> 
> 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

Date2018-10-14 16:55
FromAndreas Bergsland
SubjectRe: [Csnd] Pass strings from python to csound
I understand! So this kind of feature would only be short term, and perhaps not worth the while.
BTW, I found a workaround for my folder names => string array problem via the compileorc opcode:



-odac0


pyinit
gSFolders[] init	20
instr	1
pyruni {{
import	os
OrcBeg = """instr	2\n"""
OrcEnd = """endin\n"""
file = open('/Users/andber/Particles/particles/FolderNames.orc','w') 
Path = "/Users/andber/Particles/particles/Sets"
InDirList = os.listdir(Path)
file.write(OrcBeg)
j = 0
for i in InDirList:
	if	os.path.isdir(Path + "/"+ i) == True and i != '_Tmp':
		file.write("""gSFolders[%i] = \"%s\" \n""" %(j,i))
		j += 1
file.write(OrcEnd)
file.close()
}}
ires	compileorc	"/Users/andber/Particles/particles/FolderNames.orc"
if ires == 0 then
event_i "i", 2, 0, 0
endif
endin

instr 3
indx = 0
SEmpty = ""
until  strcmp(SEmpty,gSFolders[indx]) == 0 do
 prints gSFolders[indx]
 prints "\n"
 indx += 1
od
endin


i1	0	0
i3	0.1	0	; Has to wait a short while to work




On 14/10/2018, 13:15, "A discussion list for users of Csound on behalf of Victor Lazzarini"  wrote:

    No problem with this particular proposal, however we need to have a discussion about
    the future of these opcodes, especially in Csound 7. The fact is that maintaining them might
    become problematic, as moving to Python 3 in the context of embedding via ctcsound 
    is the norm. I am also not sure whether Python 2 will be retired in later versions of MacOS
    as well. 
    
    So whatever we do, they should be ported to Python 3. Ideally we would want these opcodes
    to be more easily maintained. My impression is that originally the C code auto generated from
    Python code, but it is not the case anymore, although there *.py files there that were the original
    sources (not sure if they are still usable).
    
    These opcodes bring a dependency to the Csound project that might not be desirable
    in the long run. Our plan would be to move all opcode libraries with external dependencies
    to separate projects/repos and this is one slated for that. I think that would also facilitate
    finding maintainers and thus freeing the core developers to think about the system rather
    than multiple components and their dependencies.
    
    ========================
    Prof. 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 14 Oct 2018, at 10:29, Andreas Bergsland  wrote:
    > 
    > Hi
    > 
    > I would like to propose expanding the pyeval and pycall family of opcodes so that strings can be passed from python to csound, e.g. maybe with type as an optional parameter
    > 
    > Sarg       pyeval   “String”, “s”
    > 
    > Sresult     pycall1  "callable", karg1, “s”
    > 
    > Right now I am searching for a method to extract the names of the folders to a string array in csound. I tried different paths, e.g. doing a ascii conversion using floats from python, but it tends to be buggy.
    > 
    > Earlier I have also tried the write to file from python and then reading it from csound. But I have not found a way to read strings from a file other than by #include, which created it own set of problems.
    > 
    > Any tips on this issue is also appreciated.
    > 
    > Best,
    > 
    > Andreas
    > 
    >  
    > 
    > -- 
    > 
    > Andreas Bergsland
    > 
    >  
    > 
    > Associate professor - førsteamanuensis
    > 
    > Study Programme Leader - studieprogramleder
    > 
    > Music Technology Programme - Musikkteknologiseksjonen
    > 
    > Department of Music - Institutt for musikk
    > 
    > Olavskvartalet
    > 
    > NTNU (Norwegian University of Science and Technology)
    > 
    > 7491 Trondheim, NORWAY
    > 
    >  
    > 
    > Visiting address/besøksadresse: Fjordgt.1 (3.etg.)
    > 
    > e-mail: andreas.bergsland@ntnu.no
    > 
    > Office phone (Skype for business):7359 0096
    > 
    > Mobil: 4566 3316
    > 
    > http://folk.ntnu.no/andbe
    > 
    > https://www.vibra.no/
    > 
    > https://www.ntnu.edu/artec
    > 
    > 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

Date2018-10-14 20:34
Fromjoachim heintz
SubjectRe: [Csnd] Pass strings from python to csound
hi andreas -

i agree that the extension you proposed would be nice to have.

meanwhile, readf(i) might help to read a string from a file.

best -
	joachim



On 14/10/18 11:29, Andreas Bergsland wrote:
> Hi
>
> I would like to propose expanding the pyeval and pycall family of
> opcodes so that strings can be passed from python to csound, e.g. maybe
> with type as an optional parameter
>
> Sarg       pyeval   “String”, “s”
>
> Sresult     *pycall1*  "callable", karg1, “s”
>
> Right now I am searching for a method to extract the names of the
> folders to a string array in csound. I tried different paths, e.g. doing
> a ascii conversion using floats from python, but it tends to be buggy.
>
> Earlier I have also tried the write to file from python and then reading
> it from csound. But I have not found a way to read strings from a file
> other than by #include, which created it own set of problems.
>
> Any tips on this issue is also appreciated.
>
> Best,
>
> Andreas
>
>
>
> --
>
> Andreas Bergsland
>
>
>
> Associate professor - førsteamanuensis
>
> Study Programme Leader - studieprogramleder
>
> Music Technology Programme - Musikkteknologiseksjonen
>
> Department of Music - Institutt for musikk
>
> Olavskvartalet
>
> NTNU (Norwegian University of Science and Technology)
>
> 7491 Trondheim, NORWAY
>
>
>
> Visiting address/besøksadresse: Fjordgt.1 (3.etg.)
>
> e-mail: andreas.bergsland@ntnu.no 
>
> Office phone (Skype for business):7359 0096
>
> Mobil: 4566 3316
>
> http://folk.ntnu.no/andbe
>
> https://www.vibra.no/
>
> https://www.ntnu.edu/artec
>
> 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

Date2018-10-14 22:02
FromAndreas Bergsland
SubjectRe: [Csnd] Pass strings from python to csound
Ahh, thanks that was of great help. I was looking through the manual for something like that, but must have missed it.
best
Andreas

On 14/10/2018, 21:34, "A discussion list for users of Csound on behalf of joachim heintz"  wrote:

    hi andreas -
    
    i agree that the extension you proposed would be nice to have.
    
    meanwhile, readf(i) might help to read a string from a file.
    
    best -
    	joachim
    
    
    
    On 14/10/18 11:29, Andreas Bergsland wrote:
    > Hi
    >
    > I would like to propose expanding the pyeval and pycall family of
    > opcodes so that strings can be passed from python to csound, e.g. maybe
    > with type as an optional parameter
    >
    > Sarg       pyeval   “String”, “s”
    >
    > Sresult     *pycall1*  "callable", karg1, “s”
    >
    > Right now I am searching for a method to extract the names of the
    > folders to a string array in csound. I tried different paths, e.g. doing
    > a ascii conversion using floats from python, but it tends to be buggy.
    >
    > Earlier I have also tried the write to file from python and then reading
    > it from csound. But I have not found a way to read strings from a file
    > other than by #include, which created it own set of problems.
    >
    > Any tips on this issue is also appreciated.
    >
    > Best,
    >
    > Andreas
    >
    >
    >
    > --
    >
    > Andreas Bergsland
    >
    >
    >
    > Associate professor - førsteamanuensis
    >
    > Study Programme Leader - studieprogramleder
    >
    > Music Technology Programme - Musikkteknologiseksjonen
    >
    > Department of Music - Institutt for musikk
    >
    > Olavskvartalet
    >
    > NTNU (Norwegian University of Science and Technology)
    >
    > 7491 Trondheim, NORWAY
    >
    >
    >
    > Visiting address/besøksadresse: Fjordgt.1 (3.etg.)
    >
    > e-mail: andreas.bergsland@ntnu.no 
    >
    > Office phone (Skype for business):7359 0096
    >
    > Mobil: 4566 3316
    >
    > http://folk.ntnu.no/andbe
    >
    > https://www.vibra.no/
    >
    > https://www.ntnu.edu/artec
    >
    > 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