[Csnd] Csound and Python.

Hi All.

Reading last messages about this topic I hve got a little bit confuse.

I'm beginner and I don't known allmost nothing about Csound... I am just reading books and taking the first exercises but my goal is to learn enogh to be able to play with it also using python.

Could someone explain with easy words how many way are there available to use Csound from a python script and which is the best, more complete I mean, no restriction or features lost?

Tanks.

Gabe.

hi gabe -

eduardo has examples for his libcsound here: First Steps — libcsound documentation

examples for ctcsound are here: Cookbook — ctcsound 1.0 documentation
sources: ctcsound/cookbook at master · csound/ctcsound · GitHub

and there are python examples in the csound API collection for both, csound 6 and csound 7: GitHub - csound/csoundAPI_examples: Examples for learning the Csound API from various languages

hope this helps, best -
  joachim

There is also Victor’s book ‘Computer Music Instruments’(Springer) which uses Csound and Python extensively to explore a range of computer DSP topics.

Thank you both.

Do you know if this book is available also digitally?

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

Yes, and it’s currently available to buy for 28 euros. Maybe I can get a commission for the sale :rofl

Hello Gabriele,

There are several ways of combining Csound with Python. As far as I know, none of them limit the functionality of Csound or of Python in any way.

There is another method, which embeds a Python script inside a Csound .csd file. This method does not require ctcsound or any external libraries, just Csound and Python. The way it works is that a “bin” attribute of the .csd tag is specified, which can be e.g. “python3.” When Csound detects this attribute during performance, it creates two temporary filenames and then runs the contents of the tag as a Python script, passing the two filenames to Python. That script can read data from sys.argv[0], and should write generated Csound score events to sys.argv[1]. Csound will then read the file named in sys.argv[1] and perform it as a regular Csound score. I have attached a complete working example, with explanatory comments, to this email.

Regards,
Mike

simplest-score-bin.csd (33.5 KB)

Eduardo has an excellent library, Maelzel, that also uses Python and works in Jupyter notebooks:
https://github.com/gesellkammer/maelzel

Very easy to get running, well thought out and solves a number of problems for you.

Victor’s book is also excellent for so many reasons (and it’s huge - was really surprised when it arrived).

Wow guys, too much ways, it is confusing. I know that sometime more is better than less but here I don't know what I need yet, what is the best to work on.

I'd like to concentrate on a single solution that offers me to manage Csound from a python script like to define an instrument and pass it something to play.

And I would like something that pyinstaller will be able to compile so the users that run my script don't need to have Csound installed. Just that. :slight_smile:

Gabe.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        GitHub · Where software is built
Discussions of bugs and features can be posted here

Thank you Mike. I'm going to study carefully the example you provided.

Gabe.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        GitHub · Where software is built
Discussions of bugs and features can be posted here