Csound Csound-dev Csound-tekno Search About

[Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound

Date2025-01-07 11:49
FromGabriele Battaglia <0000013f12e4daf0-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
Hello everyone,
Before committing to this project, I would like to ask for your opinion 
on its real feasibility.
Below, I present my idea and ask if, based on your experience, this can 
be implemented using Csound.
I want to create a Python function, to later import into my projects, 
which performs the task described below.


def sonify(data_list, duration, lower_note="C2", upper_note="C8", 
wave_form="sine", ptm=False, vol=0.5):

     '''
     sonify V6.0 Alpha, Jan 7th, 2025
     It sonifies a series of float data
     RX: a float list with values between 5 and 500k
         duration in ms
         lower and upper note define a note range to scale the values in
         wave_form determines the type of wave to play
         bool ptm: portamento, if true, a glissando will be applied 
between value transitions
     It returns nothing but audio
     '''
This is very important for understanding the trend of a series of 
numerical data if you cannot see the graphs.
What do you think? Can it be done with Csound?
I have already tried with pyo, obtaining subpar results, probably due to 
my limited skills with that library. Particularly when the data to be 
sonified was large, the results were disappointing. Then I tried again 
with sounddevice, improving the outcome but still experiencing some 
imprecision.
Now I would like to challenge myself with Csound.
Thank you very much in advance for your opinion.
Gabe

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

Date2025-01-07 12:05
FromEdith V
SubjectRe: [Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
Hi Gabe !

Glad to hear interest towards sonification : )

My understanding of your question is that you are asking if you can define a function in Csound to sonify data - is that correct ?

I am interested in the answer to this question, having done some sonifications in the last years, but I have no answer since I never used Python functions in Csound directly - usually what I do is to use Python to generate Csound partitions, that I then copy-paste into a .csd file, as demonstrated here: https://github.com/eviau/datasonification

I can see a few technical matters that might come up with large amount of data - such as figuring out the min/max values of the serie at hands... ? I am not so technical as to offer advice here, I hope there will be interest in this question.

Édith
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

Date2025-01-07 12:22
FromEdith V
SubjectRe: [Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
Also I do realize that the demo is in French - I wanted to share it because of the `generation.py` file, which is only Python code: https://github.com/eviau/datasonification/blob/main/generation.py

It is very raw and might not be so helpful - I'd be happy to work towards your original question : )

Le mar. 7 janv. 2025, à 07 h 05, Edith V <finartcialist@gmail.com> a écrit :
Hi Gabe !

Glad to hear interest towards sonification : )

My understanding of your question is that you are asking if you can define a function in Csound to sonify data - is that correct ?

I am interested in the answer to this question, having done some sonifications in the last years, but I have no answer since I never used Python functions in Csound directly - usually what I do is to use Python to generate Csound partitions, that I then copy-paste into a .csd file, as demonstrated here: https://github.com/eviau/datasonification

I can see a few technical matters that might come up with large amount of data - such as figuring out the min/max values of the serie at hands... ? I am not so technical as to offer advice here, I hope there will be interest in this question.

Édith
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

Date2025-01-07 12:30
FromMichael Gogins
SubjectRe: [Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
Csound is very well suited for this kind of project.

For the glissandos/portamentos, you can tie notes together in Csound scores using fractional instrument numbers, and set up a glissando, see https://csound.com/docs/manual/i.html about tied notes, and the manual pages for the tigoto and port opcodes.

For integrating Csound with Python, there are two main options:

<CsScore bin="python3 myrogram.py">
</CsScore>

Here, when Csound compiles the orchestra but just before it begins playing notes, Csound will invoke "myprogram.py" to generate Csound score statements, which are printed to stdout and read by Csound as notes to perform.

The other main option is to write your Python program to sonify your data, but your program would embed Csound using the ctcsound module. 

Both approaches would work for you. I would choose ctcsound as it provides some additional flexibility, allows one to print messages to the console, etc. But the first ("bin") approach is the easiest to start working with. You can always print messages to stderr instead of stdout.

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


On Tue, Jan 7, 2025 at 12:51 PM Gabriele Battaglia <0000013f12e4daf0-dmarc-request@listserv.heanet.ie> wrote:
Hello everyone,
Before committing to this project, I would like to ask for your opinion
on its real feasibility.
Below, I present my idea and ask if, based on your experience, this can
be implemented using Csound.
I want to create a Python function, to later import into my projects,
which performs the task described below.


def sonify(data_list, duration, lower_note="C2", upper_note="C8",
wave_form="sine", ptm=False, vol=0.5):

     '''
     sonify V6.0 Alpha, Jan 7th, 2025
     It sonifies a series of float data
     RX: a float list with values between 5 and 500k
         duration in ms
         lower and upper note define a note range to scale the values in
         wave_form determines the type of wave to play
         bool ptm: portamento, if true, a glissando will be applied
between value transitions
     It returns nothing but audio
     '''
This is very important for understanding the trend of a series of
numerical data if you cannot see the graphs.
What do you think? Can it be done with Csound?
I have already tried with pyo, obtaining subpar results, probably due to
my limited skills with that library. Particularly when the data to be
sonified was large, the results were disappointing. Then I tried again
with sounddevice, improving the outcome but still experiencing some
imprecision.
Now I would like to challenge myself with Csound.
Thank you very much in advance for your opinion.
Gabe

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

Date2025-01-07 12:37
Fromvlz
SubjectRe: [Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
Dave Worrall is one the main experts on Sonification (his book is an excellent reference) and he has worked with Csound

https://sonification.com.au/workshops/


> On 7 Jan 2025, at 12:22, Edith V  wrote:
> 
> Also I do realize that the demo is in French - I wanted to share it because of the `generation.py` file, which is only Python code: https://github.com/eviau/datasonification/blob/main/generation.py
> 
> It is very raw and might not be so helpful - I'd be happy to work towards your original question : )
> 
> Le mar. 7 janv. 2025, à 07 h 05, Edith V  a écrit :
> Hi Gabe !
> 
> Glad to hear interest towards sonification : )
> 
> My understanding of your question is that you are asking if you can define a function in Csound to sonify data - is that correct ?
> 
> I am interested in the answer to this question, having done some sonifications in the last years, but I have no answer since I never used Python functions in Csound directly - usually what I do is to use Python to generate Csound partitions, that I then copy-paste into a .csd file, as demonstrated here: https://github.com/eviau/datasonification
> 
> I can see a few technical matters that might come up with large amount of data - such as figuring out the min/max values of the serie at hands... ? I am not so technical as to offer advice here, I hope there will be interest in this question.
> 
> Édith
> 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

Date2025-01-07 12:53
FromMichael Gogins
SubjectRe: [Csnd] Seeking Feedback on the Feasibility of a Python Sonification Project with Csound
The Worrall reference is very much to the point, but this was in 2016 and he was using the csnd6 library as an interface to Csound from Python, and this is now better done with ctcsound.

Regards,
Mike

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


On Tue, Jan 7, 2025 at 1:37 PM vlz <viclazzarini@gmail.com> wrote:
Dave Worrall is one the main experts on Sonification (his book is an excellent reference) and he has worked with Csound

https://sonification.com.au/workshops/


> On 7 Jan 2025, at 12:22, Edith V <finartcialist@GMAIL.COM> wrote:
>
> Also I do realize that the demo is in French - I wanted to share it because of the `generation.py` file, which is only Python code: https://github.com/eviau/datasonification/blob/main/generation.py
>
> It is very raw and might not be so helpful - I'd be happy to work towards your original question : )
>
> Le mar. 7 janv. 2025, à 07 h 05, Edith V <finartcialist@gmail.com> a écrit :
> Hi Gabe !
>
> Glad to hear interest towards sonification : )
>
> My understanding of your question is that you are asking if you can define a function in Csound to sonify data - is that correct ?
>
> I am interested in the answer to this question, having done some sonifications in the last years, but I have no answer since I never used Python functions in Csound directly - usually what I do is to use Python to generate Csound partitions, that I then copy-paste into a .csd file, as demonstrated here: https://github.com/eviau/datasonification
>
> I can see a few technical matters that might come up with large amount of data - such as figuring out the min/max values of the serie at hands... ? I am not so technical as to offer advice here, I hope there will be interest in this question.
>
> Édith
> 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