Csound Csound-dev Csound-tekno Search About

[Csnd] Master orc file, multiple python scripts (API question)

Date2020-04-16 17:24
FromJoshua Armenta
Subject[Csnd] Master orc file, multiple python scripts (API question)
I have a master orchestra file I want to use in multiple python scripts. When I do the following:

orc = "synth.orc"
c.compileOrc(orc)

I get an exception. When I copy and paste the entire orc file all the scripts run. Is there a different way of including an external orc only? The python script does the random generation of notes for the score, so I don't want to do a whole CSD, I just want to keep the instruments in a separate file so I can reuse the master library in multiple scripts.

-- 
Josh Armenta, M.Mus, M.Mus., B.Mus.
Composer & Conductor | Compositor y Director
Mexico City | Ciudad de Mexico

"If I cannot fly, let me sing." - Stephen Sondheim

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

Date2020-04-21 23:16
FromSyl Morrison
SubjectRe: [Csnd] Master orc file, multiple python scripts (API question)
Hey dude, looks like you're telling it to literally use "synth.orc" as the orchestra instead of the contents of that file, (check compileOrc's definition here https://csound.com/docs/ctcsound/ctcsound-API.html ), you could parse the orc into a string and then just use that string, or could you not just have a CSD with nothing in the score section? 

On Thu, Apr 16, 2020 at 5:24 PM Joshua Armenta <josharmenta@gmail.com> wrote:
I have a master orchestra file I want to use in multiple python scripts. When I do the following:

orc = "synth.orc"
c.compileOrc(orc)

I get an exception. When I copy and paste the entire orc file all the scripts run. Is there a different way of including an external orc only? The python script does the random generation of notes for the score, so I don't want to do a whole CSD, I just want to keep the instruments in a separate file so I can reuse the master library in multiple scripts.

-- 
Josh Armenta, M.Mus, M.Mus., B.Mus.
Composer & Conductor | Compositor y Director
Mexico City | Ciudad de Mexico

"If I cannot fly, let me sing." - Stephen Sondheim

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

Date2020-04-22 08:27
FromOeyvind Brandtsegg
SubjectRe: [Csnd] Master orc file, multiple python scripts (API question)
Hi,
Sorry for the late reply.
I think you need to use a pointer to the file object, instead of the filename string. Otherwise compileOrc will not know that you are referrring to a file.
Try this:

        orcfile = open('synth.orc', 'r')
        orc = orcfile.read()
        self.cs.compileOrc(orc)

best
Oeyvind

tor. 16. apr. 2020 kl. 18:24 skrev Joshua Armenta <josharmenta@gmail.com>:
I have a master orchestra file I want to use in multiple python scripts. When I do the following:

orc = "synth.orc"
c.compileOrc(orc)

I get an exception. When I copy and paste the entire orc file all the scripts run. Is there a different way of including an external orc only? The python script does the random generation of notes for the score, so I don't want to do a whole CSD, I just want to keep the instruments in a separate file so I can reuse the master library in multiple scripts.

-- 
Josh Armenta, M.Mus, M.Mus., B.Mus.
Composer & Conductor | Compositor y Director
Mexico City | Ciudad de Mexico

"If I cannot fly, let me sing." - Stephen Sondheim

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