Csound Csound-dev Csound-tekno Search About

CSD Threading

Date2016-03-26 03:51
FromEmmett Palaima
SubjectCSD Threading
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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

Date2016-03-26 08:45
FromRory Walsh
SubjectRe: CSD Threading
I don't think there is such a mechanism for splitting up the processing across different threads. The problems you are experiencing are most likely the reason why all the Csound based RPI projects I've seen use Python to retrieve information from the Arduino, and then pass it on to Csound using channels.  

On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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

Date2016-03-26 15:50
FromEmmett Palaima
SubjectRe: CSD Threading
Do you know of any good examples of this? I  was looking at the floss manual article on the API but all the examples are in c/c++ and it doesn't clearly instruct on how to use Python. 

On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:

I don't think there is such a mechanism for splitting up the processing across different threads. The problems you are experiencing are most likely the reason why all the Csound based RPI projects I've seen use Python to retrieve information from the Arduino, and then pass it on to Csound using channels.  

On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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

Date2016-03-26 17:45
FromRory Walsh
SubjectRe: CSD Threading

I'm afraid I don't have code myself. But as far as I can remember Paul Bachelor did this with his Python Arduino projects, and COSMO also does this. If you can source some Arduino/Python code, we should be able to help you add Csound support to it. Says the man who rarely ever uses Python!

On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
Do you know of any good examples of this? I  was looking at the floss manual article on the API but all the examples are in c/c++ and it doesn't clearly instruct on how to use Python. 

On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:

I don't think there is such a mechanism for splitting up the processing across different threads. The problems you are experiencing are most likely the reason why all the Csound based RPI projects I've seen use Python to retrieve information from the Arduino, and then pass it on to Csound using channels.  

On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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
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

Date2016-03-26 20:18
FromFrancois PINOT
SubjectRe: CSD Threading
Maybe ctcsound can be of some use for you. The 3rd recipe in the cookbook is about threading. Beware that the CsoundPerformanceThread wrapper needs Csound 6.07 or higher.

Francois

2016-03-26 16:50 GMT+01:00 Emmett Palaima <epalaima@berklee.edu>:
Do you know of any good examples of this? I  was looking at the floss manual article on the API but all the examples are in c/c++ and it doesn't clearly instruct on how to use Python. 

On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:

I don't think there is such a mechanism for splitting up the processing across different threads. The problems you are experiencing are most likely the reason why all the Csound based RPI projects I've seen use Python to retrieve information from the Arduino, and then pass it on to Csound using channels.  

On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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

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

Date2016-03-26 20:21
FromFrancois PINOT
SubjectRe: CSD Threading

2016-03-26 21:18 GMT+01:00 Francois PINOT <fggpinot@gmail.com>:
Maybe ctcsound can be of some use for you. The 3rd recipe in the cookbook is about threading. Beware that the CsoundPerformanceThread wrapper needs Csound 6.07 or higher.

Francois

2016-03-26 16:50 GMT+01:00 Emmett Palaima <epalaima@berklee.edu>:
Do you know of any good examples of this? I  was looking at the floss manual article on the API but all the examples are in c/c++ and it doesn't clearly instruct on how to use Python. 

On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:

I don't think there is such a mechanism for splitting up the processing across different threads. The problems you are experiencing are most likely the reason why all the Csound based RPI projects I've seen use Python to retrieve information from the Arduino, and then pass it on to Csound using channels.  

On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I'm working on make a live audio processor using csound on the Rapsberry Pi, currently using the serial read opcodes with an arduino for external controls. I find that when I include this in my csd it often creates issues with buffer underruns, since csound has to process the serial input before it can process the audio. I was wondering if anyone knew a way to create threads within csound, where multiple parts of my code could run independently but communicate with one another. Please let me know if you have any advice on this topic. Mainly looking for ideas at this point. 

Thanks,
Emmett Palaima
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


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

Date2016-03-26 20:25
FromOeyvind Brandtsegg
SubjectRe: CSD Threading
That is nice,
and if you want to stick to a Csound-only approach, maybe you could
run two instances of Csound, one reading the serial data and
transmitting them via OSC to another Csound instance doing the actual
audio processing.

2016-03-26 21:21 GMT+01:00 Francois PINOT :
> I forgot the link: https://github.com/fggp/ctcsound
>
> 2016-03-26 21:18 GMT+01:00 Francois PINOT :
>>
>> Maybe ctcsound can be of some use for you. The 3rd recipe in the cookbook
>> is about threading. Beware that the CsoundPerformanceThread wrapper needs
>> Csound 6.07 or higher.
>>
>> Francois
>>
>> 2016-03-26 16:50 GMT+01:00 Emmett Palaima :
>>>
>>> Do you know of any good examples of this? I  was looking at the floss
>>> manual article on the API but all the examples are in c/c++ and it doesn't
>>> clearly instruct on how to use Python.
>>>
>>> On Mar 26, 2016, at 4:45 AM, Rory Walsh  wrote:
>>>
>>> I don't think there is such a mechanism for splitting up the processing
>>> across different threads. The problems you are experiencing are most likely
>>> the reason why all the Csound based RPI projects I've seen use Python to
>>> retrieve information from the Arduino, and then pass it on to Csound using
>>> channels.
>>>
>>> On 26 March 2016 at 03:51, Emmett Palaima  wrote:
>>>>
>>>> Hi, I'm working on make a live audio processor using csound on the
>>>> Rapsberry Pi, currently using the serial read opcodes with an arduino for
>>>> external controls. I find that when I include this in my csd it often
>>>> creates issues with buffer underruns, since csound has to process the serial
>>>> input before it can process the audio. I was wondering if anyone knew a way
>>>> to create threads within csound, where multiple parts of my code could run
>>>> independently but communicate with one another. Please let me know if you
>>>> have any advice on this topic. Mainly looking for ideas at this point.
>>>>
>>>> Thanks,
>>>> Emmett Palaima
>>>> 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
>>
>>
>
> 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


Date2016-03-26 20:30
FromRory Walsh
SubjectRe: CSD Threading
Good idea. I hadn't thought of that one. 

On 26 March 2016 at 20:25, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote:
That is nice,
and if you want to stick to a Csound-only approach, maybe you could
run two instances of Csound, one reading the serial data and
transmitting them via OSC to another Csound instance doing the actual
audio processing.

2016-03-26 21:21 GMT+01:00 Francois PINOT <fggpinot@gmail.com>:
> I forgot the link: https://github.com/fggp/ctcsound
>
> 2016-03-26 21:18 GMT+01:00 Francois PINOT <fggpinot@gmail.com>:
>>
>> Maybe ctcsound can be of some use for you. The 3rd recipe in the cookbook
>> is about threading. Beware that the CsoundPerformanceThread wrapper needs
>> Csound 6.07 or higher.
>>
>> Francois
>>
>> 2016-03-26 16:50 GMT+01:00 Emmett Palaima <epalaima@berklee.edu>:
>>>
>>> Do you know of any good examples of this? I  was looking at the floss
>>> manual article on the API but all the examples are in c/c++ and it doesn't
>>> clearly instruct on how to use Python.
>>>
>>> On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
>>>
>>> I don't think there is such a mechanism for splitting up the processing
>>> across different threads. The problems you are experiencing are most likely
>>> the reason why all the Csound based RPI projects I've seen use Python to
>>> retrieve information from the Arduino, and then pass it on to Csound using
>>> channels.
>>>
>>> On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
>>>>
>>>> Hi, I'm working on make a live audio processor using csound on the
>>>> Rapsberry Pi, currently using the serial read opcodes with an arduino for
>>>> external controls. I find that when I include this in my csd it often
>>>> creates issues with buffer underruns, since csound has to process the serial
>>>> input before it can process the audio. I was wondering if anyone knew a way
>>>> to create threads within csound, where multiple parts of my code could run
>>>> independently but communicate with one another. Please let me know if you
>>>> have any advice on this topic. Mainly looking for ideas at this point.
>>>>
>>>> Thanks,
>>>> Emmett Palaima
>>>> 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
>>
>>
>
> 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



--

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://flyndresang.no/
http://soundcloud.com/t-emp

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

Date2016-03-26 20:58
FromTarmo Johannes
SubjectRe: CSD Threading
Attachmentsinstallatsioon.py  
Hi,

if it helps you, here is a simple python script I used in RPi for reading 
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a 
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
> 
> On 26 Mar 2016 16:50, "Emmett Palaima"  wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> > 
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh  wrote:
> > 
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> > 
> > On 26 March 2016 at 03:51, Emmett Palaima  wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >> 
> >> Thanks,
> >> Emmett Palaima
> >> 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
> 
> 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

Date2016-03-28 12:38
FromBernt Isak Wærstad
SubjectRe: CSD Threading
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-03-28 19:29
FromEmmett Palaima
SubjectRe: CSD Threading
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-03-28 20:17
FromRory Walsh
SubjectRe: CSD Threading
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-03-28 21:10
FromEmmett Palaima
SubjectRe: CSD Threading
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

Date2016-03-28 21:46
FromRory Walsh
SubjectRe: CSD Threading

On 28 March 2016 at 21:10, Emmett Palaima <epalaima@berklee.edu> wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

Date2016-03-28 23:02
FromRichard
SubjectRe: CSD Threading
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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


Date2016-03-29 16:08
FromPaul Batchelor
SubjectRe: CSD Threading
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

Date2016-03-30 10:37
FromEmmett Palaima
SubjectRe: CSD Threading
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

Date2016-03-30 11:11
FromRory Walsh
SubjectRe: CSD Threading
Have you installed libcsound64? 

On 30 March 2016 at 10:37, Emmett Palaima <epalaima@berklee.edu> wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

Date2016-03-30 11:32
FromEmmett Palaima
SubjectRe: CSD Threading
No, I couldn't find it on my Pi, though I was looking for it. How do I install that?

On Wed, Mar 30, 2016 at 6:11 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
Have you installed libcsound64? 

On 30 March 2016 at 10:37, Emmett Palaima <epalaima@berklee.edu> wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

Date2016-03-30 11:49
FromTarmo Johannes
SubjectRe: CSD Threading

Hi,
I have built Csound6 on RPi and could look for the file but is always better to build yourself in your system - no conflicts. Have look at building Csound6 on debian.
Cheers,
Tarmo

30.03.2016 12:37 kirjutas kuupäeval "Emmett Palaima" <epalaima@berklee.edu>:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

Date2016-03-30 11:58
FromRory Walsh
SubjectRe: CSD Threading
Using apt-get, the same way you installed Csound? 

sudo apt-get install libcsound64

I'm not at a linux machine now so I can't test, but if you type that much and hit the tab key it should give you some options. 

On 30 March 2016 at 11:32, Emmett Palaima <epalaima@berklee.edu> wrote:
No, I couldn't find it on my Pi, though I was looking for it. How do I install that?

On Wed, Mar 30, 2016 at 6:11 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
Have you installed libcsound64? 

On 30 March 2016 at 10:37, Emmett Palaima <epalaima@berklee.edu> wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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

Date2016-03-30 12:49
FromRichard
SubjectRe: CSD Threading
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard

On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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


Date2016-03-30 13:59
FromEmmett Palaima
SubjectRe: CSD Threading
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

Date2016-03-30 18:30
FromPaul Batchelor
SubjectRe: CSD Threading
Just echoing what Tarmo has said already: it is always better to build from source on your Pi. You shoot yourself less in the foot that way.

-P

On Wed, Mar 30, 2016 at 5:59 AM, Emmett Palaima <epalaima@berklee.edu> wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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

Date2016-03-30 19:35
FromRichard
SubjectRe: CSD Threading
Attachments_csnd6.so  
Here it is...

Richard

On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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


Date2016-03-31 05:30
FromEmmett Palaima
SubjectRe: CSD Threading
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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

Date2016-03-31 06:54
FromFfanci Silvain
SubjectRe: CSD Threading
Hey hey,
does this whole threading issue also apply to orchestras, that use MIDI for 
input?

Assume an orchestra with one instrument to read MIDI and one or more 
instruments to actually generate and process sound on a machine with a 
multicore CPU and Csound started with the correct amount of jobs.

Ta-ta
----
Ffanci
* Homepage: https://freeshell.de/~silvain
* Twitter:  http://twitter.com/ffanci_silvain
* GitHub:   https://github.com/fsilvain

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

Date2016-03-31 13:37
FromBernt Isak Wærstad
SubjectRe: CSD Threading
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-03-31 18:19
FromEmmett Palaima
SubjectRe: CSD Threading
Its a simple API I put together that reads a couple variables from the serial port and passes them to a csound performance thread via channels. I works great on my mac, so I am pretty sure the problem is that my python dependencies are not set up correctly, and I'm really not sure how to fix that. 

On Thu, Mar 31, 2016 at 8:37 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-04-01 01:58
FromBernt Isak Wærstad
SubjectRe: CSD Threading
If you send your file(s), I could try running on a Pi here. 

On 31 March 2016 at 19:19, Emmett Palaima <epalaima@berklee.edu> wrote:
Its a simple API I put together that reads a couple variables from the serial port and passes them to a csound performance thread via channels. I works great on my mac, so I am pretty sure the problem is that my python dependencies are not set up correctly, and I'm really not sure how to fix that. 

On Thu, Mar 31, 2016 at 8:37 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-04-01 22:07
FromEmmett Palaima
SubjectRe: CSD Threading
Attachmentsserialapitest.zip  
That would be great! Here they are. The serial port is identified within the program, so just open the python file and change that to however it is name on your pi. Thanks, that will be a great help!



On Thu, Mar 31, 2016 at 8:58 PM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
If you send your file(s), I could try running on a Pi here. 

On 31 March 2016 at 19:19, Emmett Palaima <epalaima@berklee.edu> wrote:
Its a simple API I put together that reads a couple variables from the serial port and passes them to a csound performance thread via channels. I works great on my mac, so I am pretty sure the problem is that my python dependencies are not set up correctly, and I'm really not sure how to fix that. 

On Thu, Mar 31, 2016 at 8:37 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-04-02 01:07
FromEmmett Palaima
SubjectRe: CSD Threading
Hi, I am setting up a new sd card on my Pi. Just to be clear, if I have both Python and Swig installed using apt-get, csnd6.py and _csnd6.so should automatically install along with the other Python dependencies. Is this correct? 

On Fri, Apr 1, 2016 at 5:07 PM, Emmett Palaima <epalaima@berklee.edu> wrote:
That would be great! Here they are. The serial port is identified within the program, so just open the python file and change that to however it is name on your pi. Thanks, that will be a great help!



On Thu, Mar 31, 2016 at 8:58 PM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
If you send your file(s), I could try running on a Pi here. 

On 31 March 2016 at 19:19, Emmett Palaima <epalaima@berklee.edu> wrote:
Its a simple API I put together that reads a couple variables from the serial port and passes them to a csound performance thread via channels. I works great on my mac, so I am pretty sure the problem is that my python dependencies are not set up correctly, and I'm really not sure how to fix that. 

On Thu, Mar 31, 2016 at 8:37 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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



--
Mvh.

Bernt Isak Wærstad


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

Date2016-04-07 09:22
FromBernt Isak Wærstad
SubjectRe: CSD Threading
Your example runs fine on my pi here (I commented out the serial stuff since I didnt have that library installed). We've just built Csound from sources as it is described at the github page (in fact I think it was Alex who updated those a while ago). As long as you follow all of those steps, everything should work without any extra work, so perhaps it is something related to your distro then? We use wheezy, IIRC.

On 2 April 2016 at 02:07, Emmett Palaima <epalaima@berklee.edu> wrote:
Hi, I am setting up a new sd card on my Pi. Just to be clear, if I have both Python and Swig installed using apt-get, csnd6.py and _csnd6.so should automatically install along with the other Python dependencies. Is this correct? 

On Fri, Apr 1, 2016 at 5:07 PM, Emmett Palaima <epalaima@berklee.edu> wrote:
That would be great! Here they are. The serial port is identified within the program, so just open the python file and change that to however it is name on your pi. Thanks, that will be a great help!



On Thu, Mar 31, 2016 at 8:58 PM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
If you send your file(s), I could try running on a Pi here. 

On 31 March 2016 at 19:19, Emmett Palaima <epalaima@berklee.edu> wrote:
Its a simple API I put together that reads a couple variables from the serial port and passes them to a csound performance thread via channels. I works great on my mac, so I am pretty sure the problem is that my python dependencies are not set up correctly, and I'm really not sure how to fix that. 

On Thu, Mar 31, 2016 at 8:37 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
You've probably mentioned it, but what python file (one you are trying to run) are you referring to? 

On 31 March 2016 at 06:30, Emmett Palaima <epalaima@berklee.edu> wrote:
Thanks Richard, it actually returned another error, but it was worth a try, I really appreciate it. I tryed installing Csound again using the instructions for debian that Paul posted (https://github.com/csound/csound/blob/develop/BUILD.md). I tried running the python file and it returns the following error:

ImportError: /home/pi/.local/lib/python2.7/site-packages/_csnd6.so: undefined symbol: PyInstanceMethod_New

Could this be because I already had installed Csound once before? If so how would I go about cleaning up my file system so as to get a clean install? Or is it something else?

On Wed, Mar 30, 2016 at 2:35 PM, Richard <zappfinger@gmail.com> wrote:
Here it is...

Richard


On 30/03/16 14:59, Emmett Palaima wrote:
That will be much appreciated. Thank you for all your help.

On Wed, Mar 30, 2016 at 7:49 AM, Richard <zappfinger@gmail.com> wrote:
I have the .so file for csound 6.04 on my PI, maybe it works with your 6.03 version. But now I am at work and cannot access it. Tonight I will post it.

Richard


On 30/03/16 11:37, Emmett Palaima wrote:
Does anyone have a _csnd6.so file built for linux or the raspberry pi that they could share with me? I've been trying to run the python API on my Pi but I've been running into issues since somehow that file wasn't added while I was installing Csound. 

I get the following error when running the API:

ImportError: /usr/local/lib/python2.7/dist-packages/_csnd6.so: invalid ELF header

I think just getting the file should fix it, but I can't seem to find it anywhere online. If anyone could share it with me I would greatly appreciate it.  

Thanks,
Emmett Palaima

On Tue, Mar 29, 2016 at 11:08 AM, Paul Batchelor <ralphbluecoat@gmail.com> wrote:
More solutions!

As Rory mentioned, in the past I've used the Csound API in Python with some serial library (I don't remember) and that worked pretty well.

The main problem I think you're having is that the serial reads are blocking on the main thread. The solution to that is to give it it's own thread.
The Csound API does have it's own threading system, so you can
run Csound in the background and do things like send note messages (am I saying this right?).

My setups typically involved starting Csound up, pushing it onto it's performance thread in the background I could run other things. In this case, we'd want
a while loop reading messages from serial.

On Linux, the serial port is more or less abstracted as a file (yay unix), typically /dev/ttyACM0. You can actually open it (you may have to be root) and read it as any file.
It's not terribly difficult to parse the bytes that you write to serial via the arduino. If the values you are sending are 8-bit, you can just read one character at a time (though
I'd recommend having at least one other byte describing what the parameter is).

If you don't really need to use Python, you can do all of this in C pretty easily. Once you start Csound and the performance thread, you can build your while loop in a
few lines of code. While not, serial, I'm doing essentially the same thing here when I parse gamepad data from the f310 game controller in "process":

https://github.com/PaulBatchelor/Auria/blob/master/f310.c


Happy hacking,

-P


On Mon, Mar 28, 2016 at 3:02 PM, Richard <zappfinger@gmail.com> wrote:
Here's an example I used to convert serial integers to OSC messages. If time permits, I will create an example with the Csound API also, but the principle is the same.
(BTW in this example I open a serial port in OS X, in Windows you just have to use COM1 or whatever port is available)
You do need to install pyserial, that is imported here as 'import serial'.

#!/usr/local/bin/python2.7
#
#  basic serial to OSC, uses pyserial and pyosc libraries
#  expects serial data to be in the form:
#  <integer>;<integer>;....
#  so integers separated by an ASCII ';'
#
import serial,binascii,OSC,string
import thread

def play():
    #start csound first
    print 'playing csd'
    # start your csd in any way you like
    ....
   

def getSerial():
    ser = serial.Serial('/dev/tty.usbserial-A6004cLH',baudrate = 38400, bytesize = 8, parity = 'N', stopbits = 1)
    if ser.isOpen():
          ser.close()
    ser.open()
    print '\nserial2OSC\n'
    print 'connected to serial port'

    client = OSC.OSCClient()
    msg = OSC.OSCMessage()
    msg.setAddress("/freq")

    MAXINT = 65536
    val=''
    while 1:  # or use: while 1: to go on forever
        char = ser.read(1)
        while char<>';':
               val = val + char
               char = ser.read(1)
        print val;
        if val.isdigit():
            msg.clearData()
            #print float(val)
            msg.append(float(val))
            client.sendto(msg, ('127.0.0.1', 9000))
        val=''


if __name__ == '__main__':        
    # Create two threads as follows
    try:
           thread.start_new_thread( play, () )
           time.sleep(3)
           thread.start_new_thread( getSerial, () )
    except:
           print "Error: unable to start thread"

while 1:
   pass

On 28/03/16 22:10, Emmett Palaima wrote:
Does anyone have any examples of reading a serial input with python? I'm trying to figure out how to do that with integers rather than strings, which is what ser.read and ser.write normally return. 

On Mon, Mar 28, 2016 at 3:17 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
It ships with most flavours of Csound. The FLOSS manual has a little bit on using Csound with Python, and you can find some examples here:


This mailing list is probably your best resource! 

On 28 March 2016 at 19:29, Emmett Palaima <epalaima@berklee.edu> wrote:
Are their any dependencies I need to download/setup to make the Csound API work with Python? That was the main thing I am unclear on. Also is there anywhere that the Python API syntax is described in detail, or do I just need to pick it up from existing code? Thank you everyone for their examples. It is extremely helpful to have something to base my work off of. 

On Mon, Mar 28, 2016 at 7:38 AM, Bernt Isak Wærstad <berntisak@gmail.com> wrote:
We all our stuff on github. You can check our example python file here:


This uses a custom library specific for our COSMO HAT, but it should be pretty straight forward to change this code to either use GPIO or get serial values from the Arduino

We also have a dsp library that we're working on at the moment in case you want to check it out:


Hopefully it will be much more extensive in a couple of weeks (a long with a demo video). A basic explanation of our UDO based setup can be found here:

On 26 March 2016 at 22:58, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

if it helps you, here is a simple python script I used in RPi for reading
values from GPIO. I think you can adjust it to Arduino quite easily.

It is quite simple and works well, I think using Python and Csound API is a
good choice. Never tested Csound-ctypes though... Definitely worth to try!

Best!
tarmo

On Saturday 26 March 2016 17:45:23 you wrote:
> I'm afraid I don't have code myself. But as far as I can remember Paul
> Bachelor did this with his Python Arduino projects, and COSMO also does
> this. If you can source some Arduino/Python code, we should be able to help
> you add Csound support to it. Says the man who rarely ever uses Python!
>
> On 26 Mar 2016 16:50, "Emmett Palaima" <epalaima@berklee.edu> wrote:
> > Do you know of any good examples of this? I  was looking at the floss
> > manual article on the API but all the examples are in c/c++ and it doesn't
> > clearly instruct on how to use Python.
> >
> > On Mar 26, 2016, at 4:45 AM, Rory Walsh <rorywalsh@EAR.IE> wrote:
> >
> > I don't think there is such a mechanism for splitting up the processing
> > across different threads. The problems you are experiencing are most
> > likely
> > the reason why all the Csound based RPI projects I've seen use Python to
> > retrieve information from the Arduino, and then pass it on to Csound using
> > channels.
> >
> > On 26 March 2016 at 03:51, Emmett Palaima <epalaima@berklee.edu> wrote:
> >> Hi, I'm working on make a live audio processor using csound on the
> >> Rapsberry Pi, currently using the serial read opcodes with an arduino for
> >> external controls. I find that when I include this in my csd it often
> >> creates issues with buffer underruns, since csound has to process the
> >> serial input before it can process the audio. I was wondering if anyone
> >> knew a way to create threads within csound, where multiple parts of my
> >> code
> >> could run independently but communicate with one another. Please let me
> >> know if you have any advice on this topic. Mainly looking for ideas at
> >> this
> >> point.
> >>
> >> Thanks,
> >> Emmett Palaima
> >> 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
>
> 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



--
Mvh.

Bernt Isak Wærstad


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

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

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

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



--
Mvh.

Bernt Isak Wærstad


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



--
Mvh.

Bernt Isak Wærstad


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



--
Mvh.

Bernt Isak Wærstad


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