Csound Csound-dev Csound-tekno Search About

[Csnd] Installing the python plugins on Linux

Date2023-06-04 15:54
FromPrent Rodgers
Subject[Csnd] Installing the python plugins on Linux
I'm struggling with calling a python function I've written from csound. The pyinit and pyirun opcodes look like they would help here. But the challenge is that they need to be built, and I don't know how to do that. 

My goal is the be able to play a midi keyboard, process the midi through csound midi opcodes, and call the python function to transform the midi notes into cent values that I can play with csound. I've successfully processed midi files with the python function, which creates a .csd file. But I want to perform on a MIDI keyboard and hear the results. 

If it makes more sense I could switch the design to use ctcsound, which I have used before. I just can't get my head around how I would read a MIDI keystroke, send the note information to my python function, and then send the result of the python function to a running ctcsound instance. Do I need two separate ctcsound instances, one to read the midi input, and the other to execute a csound orchestra?

By the way, here is some of the recent work I've done with automatic just intonation of Bach chorales, realized with a large ensemble of Csound sampled instruments. 

http://ripnread.com/sample-page/code/fantasias-on-bach-chorales-from-the-st-john-passion-for-large-ensembles/

I took MIDI files of Bach chorales, then optimized the intervals in cents to use the lowest possible integer ratios for numerator and denominator, while maintaining reasonable distance from the 12 tone equal temperament cent values. My next step is to be able to play chords on a midi keyboard and hear what each one sounds like to build my own chord progressions. 

Prent Rodgers

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

Date2023-06-04 16:53
FromDave Seidel
SubjectRe: [Csnd] Installing the python plugins on Linux
You might consider the approach I use, which entirely in Csound, which is to get the MIDI data and use the note number to index into a table of frequencies built by GEN51. The table is built when Csound starts up, and has a (microtonal) frequency for every possible MIDI note. This works very well. 

On Sun, Jun 4, 2023, 10:54 AM Prent Rodgers <prent.rodgers@gmail.com> wrote:
I'm struggling with calling a python function I've written from csound. The pyinit and pyirun opcodes look like they would help here. But the challenge is that they need to be built, and I don't know how to do that.

My goal is the be able to play a midi keyboard, process the midi through csound midi opcodes, and call the python function to transform the midi notes into cent values that I can play with csound. I've successfully processed midi files with the python function, which creates a .csd file. But I want to perform on a MIDI keyboard and hear the results.

If it makes more sense I could switch the design to use ctcsound, which I have used before. I just can't get my head around how I would read a MIDI keystroke, send the note information to my python function, and then send the result of the python function to a running ctcsound instance. Do I need two separate ctcsound instances, one to read the midi input, and the other to execute a csound orchestra?

By the way, here is some of the recent work I've done with automatic just intonation of Bach chorales, realized with a large ensemble of Csound sampled instruments.

http://ripnread.com/sample-page/code/fantasias-on-bach-chorales-from-the-st-john-passion-for-large-ensembles/

I took MIDI files of Bach chorales, then optimized the intervals in cents to use the lowest possible integer ratios for numerator and denominator, while maintaining reasonable distance from the 12 tone equal temperament cent values. My next step is to be able to play chords on a midi keyboard and hear what each one sounds like to build my own chord progressions.

Prent Rodgers

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

Date2023-06-04 16:55
FromDave Seidel
SubjectRe: [Csnd] Installing the python plugins on Linux
See https://csound.com/site/news/2020/01/05/implication_organ_40 (click through to the code on Github).

On Sun, Jun 4, 2023, 11:53 AM Dave Seidel <dave.seidel@gmail.com> wrote:
You might consider the approach I use, which entirely in Csound, which is to get the MIDI data and use the note number to index into a table of frequencies built by GEN51. The table is built when Csound starts up, and has a (microtonal) frequency for every possible MIDI note. This works very well. 

On Sun, Jun 4, 2023, 10:54 AM Prent Rodgers <prent.rodgers@gmail.com> wrote:
I'm struggling with calling a python function I've written from csound. The pyinit and pyirun opcodes look like they would help here. But the challenge is that they need to be built, and I don't know how to do that.

My goal is the be able to play a midi keyboard, process the midi through csound midi opcodes, and call the python function to transform the midi notes into cent values that I can play with csound. I've successfully processed midi files with the python function, which creates a .csd file. But I want to perform on a MIDI keyboard and hear the results.

If it makes more sense I could switch the design to use ctcsound, which I have used before. I just can't get my head around how I would read a MIDI keystroke, send the note information to my python function, and then send the result of the python function to a running ctcsound instance. Do I need two separate ctcsound instances, one to read the midi input, and the other to execute a csound orchestra?

By the way, here is some of the recent work I've done with automatic just intonation of Bach chorales, realized with a large ensemble of Csound sampled instruments.

http://ripnread.com/sample-page/code/fantasias-on-bach-chorales-from-the-st-john-passion-for-large-ensembles/

I took MIDI files of Bach chorales, then optimized the intervals in cents to use the lowest possible integer ratios for numerator and denominator, while maintaining reasonable distance from the 12 tone equal temperament cent values. My next step is to be able to play chords on a midi keyboard and hear what each one sounds like to build my own chord progressions.

Prent Rodgers

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

Date2023-06-04 17:17
FromDave Seidel
SubjectRe: [Csnd] Installing the python plugins on Linux
There's probably a similar approach that would use cent values instead of frequencies. Even if you have to code your own loop to populate the table (or array), that could easily be written to happen at Csound startup time. 

On Sun, Jun 4, 2023, 11:55 AM Dave Seidel <dave.seidel@gmail.com> wrote:
See https://csound.com/site/news/2020/01/05/implication_organ_40 (click through to the code on Github).

On Sun, Jun 4, 2023, 11:53 AM Dave Seidel <dave.seidel@gmail.com> wrote:
You might consider the approach I use, which entirely in Csound, which is to get the MIDI data and use the note number to index into a table of frequencies built by GEN51. The table is built when Csound starts up, and has a (microtonal) frequency for every possible MIDI note. This works very well. 

On Sun, Jun 4, 2023, 10:54 AM Prent Rodgers <prent.rodgers@gmail.com> wrote:
I'm struggling with calling a python function I've written from csound. The pyinit and pyirun opcodes look like they would help here. But the challenge is that they need to be built, and I don't know how to do that.

My goal is the be able to play a midi keyboard, process the midi through csound midi opcodes, and call the python function to transform the midi notes into cent values that I can play with csound. I've successfully processed midi files with the python function, which creates a .csd file. But I want to perform on a MIDI keyboard and hear the results.

If it makes more sense I could switch the design to use ctcsound, which I have used before. I just can't get my head around how I would read a MIDI keystroke, send the note information to my python function, and then send the result of the python function to a running ctcsound instance. Do I need two separate ctcsound instances, one to read the midi input, and the other to execute a csound orchestra?

By the way, here is some of the recent work I've done with automatic just intonation of Bach chorales, realized with a large ensemble of Csound sampled instruments.

http://ripnread.com/sample-page/code/fantasias-on-bach-chorales-from-the-st-john-passion-for-large-ensembles/

I took MIDI files of Bach chorales, then optimized the intervals in cents to use the lowest possible integer ratios for numerator and denominator, while maintaining reasonable distance from the 12 tone equal temperament cent values. My next step is to be able to play chords on a midi keyboard and hear what each one sounds like to build my own chord progressions.

Prent Rodgers

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

Date2023-06-04 17:19
FromMichael Gogins
SubjectRe: [Csnd] Installing the python plugins on Linux

I like what you're trying to do here. 

I advise doing this all purely in Csound, that way there are fewer things to break. I would use one or more user-defined opcodes.

The Python opcodes are getting old. The ctcsound facility works very well if Python calls Csound but I don't think ctcsound is designed to have Csound call Python.

If you can do any C or ++ coding, another option is to write your own dynamically loaded plugin opcode. If you can code this, do it all in just one .cpp or .c file with no header file and compile it. You can use a simple IDE or just a single compiler command on the command line, this would work on my Linux compiler: c++ -v --std=gnu++17 -lstdc++ -O3 -g -Wno-write-strings -I. -I/usr/local/include -I/usr/include/csound -I/usr/local/include/csound  -lcsound64  -lsndfile -lgc -lpthread -ldl -lm.

For building the Python opcodes yourself, clone https://github.com/csound/plugins and follow the instructions in the README. For the py opcodes, see additional instructions on https://github.com/csound/plugins/tree/develop/py. You can omit building the other opcodes in this repository, if necessary by commenting out the targets in CMakeLists.txt.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Sun, Jun 4, 2023 at 11:53 AM Dave Seidel <dave.seidel@gmail.com> wrote:
You might consider the approach I use, which entirely in Csound, which is to get the MIDI data and use the note number to index into a table of frequencies built by GEN51. The table is built when Csound starts up, and has a (microtonal) frequency for every possible MIDI note. This works very well. 

On Sun, Jun 4, 2023, 10:54 AM Prent Rodgers <prent.rodgers@gmail.com> wrote:
I'm struggling with calling a python function I've written from csound. The pyinit and pyirun opcodes look like they would help here. But the challenge is that they need to be built, and I don't know how to do that.

My goal is the be able to play a midi keyboard, process the midi through csound midi opcodes, and call the python function to transform the midi notes into cent values that I can play with csound. I've successfully processed midi files with the python function, which creates a .csd file. But I want to perform on a MIDI keyboard and hear the results.

If it makes more sense I could switch the design to use ctcsound, which I have used before. I just can't get my head around how I would read a MIDI keystroke, send the note information to my python function, and then send the result of the python function to a running ctcsound instance. Do I need two separate ctcsound instances, one to read the midi input, and the other to execute a csound orchestra?

By the way, here is some of the recent work I've done with automatic just intonation of Bach chorales, realized with a large ensemble of Csound sampled instruments.

http://ripnread.com/sample-page/code/fantasias-on-bach-chorales-from-the-st-john-passion-for-large-ensembles/

I took MIDI files of Bach chorales, then optimized the intervals in cents to use the lowest possible integer ratios for numerator and denominator, while maintaining reasonable distance from the 12 tone equal temperament cent values. My next step is to be able to play chords on a midi keyboard and hear what each one sounds like to build my own chord progressions.

Prent Rodgers

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