Csound Csound-dev Csound-tekno Search About

[Csnd] filelen problem on multiple schedule

Date2024-09-04 16:42
Fromfordelya <00000c641a512f08-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] filelen problem on multiple schedule
Hello,
I’m working on a simple sample based live coding instrument using the diskin and filelen opcode.
The setup is simple: I have a folder with samples like “samp1.wav, samp2.wav, samp3.wav”.
My code picks a sample based on a calculated icps, so it ends up like: aouts[] diskin sprintf("%ssamp%i.wav", Sdirectory, inum) with his relatively calculated length that replaces p3.

Everything works fine initially, even when i schedule the instrument multiple time and quickly, but for some reasons sometimes things start acting weird and filelen suddenly stop reading the path reporting:
INIT ERROR in instr 10 (opcode filelen) line 59: diskinfo cannot open /my_path/samp1.wav 

Steven Yi on Discord suggested that it could be a 'ulimit' problem on the OS.
https://apple.stackexchange.com/questions/366187/why-does-setting-the-hard-limit-for-maxfiles-to-unlimited-using-launchctl-lim

I tried setting 'sudo launchctl limit maxfiles 1024 unlimited' (from 256), but nothing seems changed.
I am on macos 14, m1.

I know that it could be better replacing path with a GEN01, but I wanted to test this way and really everything works until dont.. I cannot figure out why this problem.
Any ideas on what could be causing this issue? 
thank u

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

Date2024-09-04 22:04
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] filelen problem on multiple schedule
Sounds like a limit on open files.
Reading from disk is not the best approach for hard realtime audio (eventually you may get interruptions if pushing the system). 

I think tables offer a more robust solution.

Rory has introduced this opcode 

that is handy for generating tables for files.
It may be useful for you.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 4 Sep 2024, at 16:43, fordelya <00000c641a512f08-dmarc-request@listserv.heanet.ie> wrote:

*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Hello,
I’m working on a simple sample based live coding instrument using the diskin and filelen opcode.
The setup is simple: I have a folder with samples like “samp1.wav, samp2.wav, samp3.wav”.
My code picks a sample based on a calculated icps, so it ends up like: aouts[] diskin sprintf("%ssamp%i.wav", Sdirectory, inum) with his relatively calculated length that replaces p3.

Everything works fine initially, even when i schedule the instrument multiple time and quickly, but for some reasons sometimes things start acting weird and filelen suddenly stop reading the path reporting:
INIT ERROR in instr 10 (opcode filelen) line 59: diskinfo cannot open /my_path/samp1.wav

Steven Yi on Discord suggested that it could be a 'ulimit' problem on the OS.
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapple.stackexchange.com%2Fquestions%2F366187%2Fwhy-does-setting-the-hard-limit-for-maxfiles-to-unlimited-using-launchctl-lim&data=05%7C02%7CVictor.Lazzarini%40mu.ie%7C71d54b40819345352c1408dcccf843c0%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638610613869198363%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=Q0zgKE3tLu3mb2mMQgKSzWmEajVBInPdBBgYzCD4gdQ%3D&reserved=0

I tried setting 'sudo launchctl limit maxfiles 1024 unlimited' (from 256), but nothing seems changed.
I am on macos 14, m1.

I know that it could be better replacing path with a GEN01, but I wanted to test this way and really everything works until dont.. I cannot figure out why this problem.
Any ideas on what could be causing this issue?
thank u

Csound mailing list
Csound@listserv.heanet.ie
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C02%7CVictor.Lazzarini%40mu.ie%7C71d54b40819345352c1408dcccf843c0%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638610613869220135%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=bS1fj3sybidikaAignEL78ylWGA9%2BZcL474vNqnvD8U%3D&reserved=0
Send bugs reports to
       https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C02%7CVictor.Lazzarini%40mu.ie%7C71d54b40819345352c1408dcccf843c0%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638610613869234409%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=%2FVsbywzlYXGnyaSAgK7m7Rp9HgVt%2BXVDhWIRMHvWIGs%3D&reserved=0
Discussions of bugs and features can be posted here

Date2024-09-11 16:18
FromRisto Kuusisto
Subject[Csnd] Channel-related questions
Hello all,

I have been testing channels to communicate with java and partly also succeeded.
Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
1) Csound-side
If i have something like this in csd-code:
...

chn_k "Dat2", 2, 1

...

chnset kData2, "Dat2"


This works well. Now if I add a line:

chnset kStatus, "BBBB"

That works also without complaints although I haven't added any new chn_k-definition.

I would have expected some error-message at least during run-time because of the missing

channel definition.


So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?


2) Java-side

I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)

try {
c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
} catch(Exception ee) {
System.out.println("problemos");
}


So in this case I had a faulty definition for "Req1" in the csound-code but not the required

correct "Req".

As a surprise to me java-code was executed without any error-messages during run-time

and the execution did not reach the catch-part above.


Is the situation the same in the of python- or c++-case ?

Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?


--Risto



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

Date2024-09-11 17:56
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto  wrote:
> 
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
> 
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ... 
> chnset kData2, "Dat2"
> 
> This works well. Now if I add a line: 
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
> 
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
> 
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() | 
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  | 
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue()); 
> } catch(Exception ee) {
> System.out.println("problemos");
> }
> 
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
> 
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
> 
> --Risto
> 
> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-11 18:41
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-11 19:32
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-11 19:39
FromTarmo Johannes
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
Hi Risto,

Yes, you should not worry about the channel management, it is very solid.
If in some reason your code needs to check which channels are available, you can use

PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
(this is from C API, most likely it is exposed also to the Java API)

from the code of CsoundQt (it is C++ ) to get some idea how it could be used.

As much I know, csoundListChannels reports only the channels that are declared with chn_k/chn_S, so that's why those opcodes are can be necessary.

It all depends  from your own use case, what you need and what your host does.

Best!
tarmo

Kontakt vlz (<viclazzarini@gmail.com>) kirjutas kuupäeval K, 11. september 2024 kell 21:32:
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-11 19:42
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
csoundListChannels should report any channels existing at the time it is called, whichever way they were created.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 19:39, Tarmo Johannes <trmjhnns@gmail.com> wrote:


Hi Risto,

Yes, you should not worry about the channel management, it is very solid.
If in some reason your code needs to check which channels are available, you can use

PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
(this is from C API, most likely it is exposed also to the Java API)

from the code of CsoundQt (it is C++ ) to get some idea how it could be used.

As much I know, csoundListChannels reports only the channels that are declared with chn_k/chn_S, so that's why those opcodes are can be necessary.

It all depends  from your own use case, what you need and what your host does.

Best!
tarmo

Kontakt vlz (<viclazzarini@gmail.com>) kirjutas kuupäeval K, 11. september 2024 kell 21:32:
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-11 20:48
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
I was not saying that channel management doesn't work. It seems to work fine.
The problem is that when I myself make a mistake, "Req1" on java-code, "Req2" on csound-code, what then ?
Neither java nor Csound does give any kind of error message, not during compilation or during run-time.

Maybe this has to be learned  in a hard way in practice and start to suspect the channel-names immediately,
if the application doesn't work as expected.

There seems to be this method in java also for Csound-object:

ListChannels()

I can see this in Eclipse. The problem is the argument type which has been copied here manually
from the help-display in Eclipse.
So the required argument type seen in Eclipse-help is SWIGTYPE_p_p_ControlChannellnfo_s.
I went through the whole list of methods for csound-object, but none of those has this type as their result type.
So I suppose it's something not doable in java.
Seems to be quite hard to stay in java without documentation when trying to communicate with Csound .
And "translating" c++ to java is a bit too much for me.

--Risto

ke 11. syysk. 2024 klo 21.39 Tarmo Johannes (trmjhnns@gmail.com) kirjoitti:
Hi Risto,

Yes, you should not worry about the channel management, it is very solid.
If in some reason your code needs to check which channels are available, you can use

PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
(this is from C API, most likely it is exposed also to the Java API)

from the code of CsoundQt (it is C++ ) to get some idea how it could be used.

As much I know, csoundListChannels reports only the channels that are declared with chn_k/chn_S, so that's why those opcodes are can be necessary.

It all depends  from your own use case, what you need and what your host does.

Best!
tarmo

Kontakt vlz (<viclazzarini@gmail.com>) kirjutas kuupäeval K, 11. september 2024 kell 21:32:
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-25 14:00
FromSteven Yi
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
I missed this thread earlier, but for what it's worth, I'm using Java FFM now with Csound and have released a library called CsoundFFM:

https://central.sonatype.com/artifact/com.kunstmusik/csoundffm

It works with Java 22+. It's not fully compliant with Csound API yet but does work with both Csound 6 and 7. (Currently using it in one of Blue's development branches.) 

For channels, would you prefer to have something that can check if a channel exists? Seems like that'd be enough API-wise for you to do:

if(!csound.channelExists("test')) {
  throw Exception("Channel test did not exist");
}

and you could create some utility functions around that for your code. 

On Wed, Sep 11, 2024 at 3:49 PM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
I was not saying that channel management doesn't work. It seems to work fine.
The problem is that when I myself make a mistake, "Req1" on java-code, "Req2" on csound-code, what then ?
Neither java nor Csound does give any kind of error message, not during compilation or during run-time.

Maybe this has to be learned  in a hard way in practice and start to suspect the channel-names immediately,
if the application doesn't work as expected.

There seems to be this method in java also for Csound-object:

ListChannels()

I can see this in Eclipse. The problem is the argument type which has been copied here manually
from the help-display in Eclipse.
So the required argument type seen in Eclipse-help is SWIGTYPE_p_p_ControlChannellnfo_s.
I went through the whole list of methods for csound-object, but none of those has this type as their result type.
So I suppose it's something not doable in java.
Seems to be quite hard to stay in java without documentation when trying to communicate with Csound .
And "translating" c++ to java is a bit too much for me.

--Risto

ke 11. syysk. 2024 klo 21.39 Tarmo Johannes (trmjhnns@gmail.com) kirjoitti:
Hi Risto,

Yes, you should not worry about the channel management, it is very solid.
If in some reason your code needs to check which channels are available, you can use

PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
(this is from C API, most likely it is exposed also to the Java API)

from the code of CsoundQt (it is C++ ) to get some idea how it could be used.

As much I know, csoundListChannels reports only the channels that are declared with chn_k/chn_S, so that's why those opcodes are can be necessary.

It all depends  from your own use case, what you need and what your host does.

Best!
tarmo

Kontakt vlz (<viclazzarini@gmail.com>) kirjutas kuupäeval K, 11. september 2024 kell 21:32:
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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

Date2024-09-25 15:37
FromJohn ff
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
-------- Original Message --------
From: Steven Yi 
Sent: Wed Sep 25 14:00:27 GMT+01:00 2024
To: csound@listserv.heanet.ie
Subject: Re: [Csnd] [EXTERNAL] [Csnd] Channel-related questions

I missed this thread earlier, but for what it's worth, I'm using Java FFM
now with Csound and have released a library called CsoundFFM:

https://central.sonatype.com/artifact/com.kunstmusik/csoundffm

It works with Java 22+. It's not fully compliant with Csound API yet but
does work with both Csound 6 and 7. (Currently using it in one of Blue's
development branches.)

For channels, would you prefer to have something that can check if a
channel exists? Seems like that'd be enough API-wise for you to do:

if(!csound.channelExists("test')) {
  throw Exception("Channel test did not exist");
}

and you could create some utility functions around that for your code.

On Wed, Sep 11, 2024 at 3:49 PM Risto Kuusisto 
wrote:

> I was not saying that channel management doesn't work. It seems to work
> fine.
> The problem is that when I myself make a mistake, "Req1" on java-code,
> "Req2" on csound-code, what then ?
> Neither java nor Csound does give any kind of error message, not during
> compilation or during run-time.
>
> Maybe this has to be learned  in a hard way in practice and start to
> suspect the channel-names immediately,
> if the application doesn't work as expected.
>
> There seems to be this method in java also for Csound-object:
>
> ListChannels()
>
> I can see this in Eclipse. The problem is the argument type which has been
> copied here manually
> from the help-display in Eclipse.
> So the required argument type seen in Eclipse-help is
> SWIGTYPE_p_p_ControlChannellnfo_s.
> I went through the whole list of methods for csound-object, but none of
> those has this type as their result type.
> So I suppose it's something not doable in java.
> Seems to be quite hard to stay in java without documentation when trying
> to communicate with Csound .
> And "translating" c++ to java is a bit too much for me.
>
> --Risto
>
> ke 11. syysk. 2024 klo 21.39 Tarmo Johannes (trmjhnns@gmail.com)
> kirjoitti:
>
>> Hi Risto,
>>
>> Yes, you should not worry about the channel management, it is very solid.
>> If in some reason your code needs to check which channels are available,
>> you can use
>>
>> PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
>> (this is from C API, most likely it is exposed also to the Java API)
>>
>> see
>> https://github.com/CsoundQt/CsoundQt/blob/cbbcdaed5e002c280903e6c95d30a0d88ca4f858/src/csoundengine.cpp#L1043
>> from the code of CsoundQt (it is C++ ) to get some idea how it could be
>> used.
>>
>> As much I know, csoundListChannels reports only the channels that are
>> declared with chn_k/chn_S, so that's why those opcodes are can be necessary.
>>
>> It all depends  from your own use case, what you need and what your host
>> does.
>>
>> Best!
>> tarmo
>>
>> Kontakt vlz () kirjutas kuupäeval K, 11.
>> september 2024 kell 21:32:
>>
>>> There is no error to speak of in this case.
>>> This code has been used for over twenty years in numerous projects,
>>> including many commercial software that people pay money for and it has not
>>> been found that there is a design problem.
>>>
>>> Prof. Victor Lazzarini
>>> Maynooth University
>>> Ireland
>>>
>>> On 11 Sep 2024, at 18:41, Risto Kuusisto  wrote:
>>>
>>> 
>>> OK, it has been designed in that way to be as flexible as possible. From
>>> programming point of view you can't be sure if your code is correct.
>>> Neither compilation nor run-time doesn't give any indication of a
>>> possible error in your code.
>>> In small cases this may not be a problem, but how about the larger ones ?
>>>
>>> So there really isn't a method (in java/python/c++) that would tell the
>>> names of the available channels of the Csound-object in question?
>>>
>>> --Risto
>>>
>>>
>>> ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (
>>> 000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
>>>
>>>> Whenever you call chnset, if the channel does not exist, it will be
>>>> created. So in general, you may not need
>>>> to declare channels to start with.
>>>>
>>>> The API function GetChannelPtr() likewise creates a channel if there
>>>> isn’t one. From the API reference
>>>> (
>>>> https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db
>>>> )
>>>>
>>>> PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char *
>>>> name,int type )
>>>>
>>>> Stores a pointer to the specified channel of the bus in *p, creating
>>>> the channel first if it does not exist yet.
>>>>
>>>> So you can just create a channel with it too.
>>>> ========================
>>>> Prof. Victor Lazzarini
>>>> Maynooth University
>>>> Ireland
>>>>
>>>> > On 11 Sep 2024, at 16:18, Risto Kuusisto 
>>>> wrote:
>>>> >
>>>> > *Warning*
>>>> > This email originated from outside of Maynooth University's Mail
>>>> System. Do not reply, click links or open attachments unless you recognise
>>>> the sender and know the content is safe.
>>>> > Hello all,
>>>> >
>>>> > I have been testing channels to communicate with java and partly also
>>>> succeeded.
>>>> > Now I have noticed something, where I don't know if there is a
>>>> problem in the versions of Csound (6.17) or csnd6.jar that I use.
>>>> > 1) Csound-side
>>>> > If i have something like this in csd-code:
>>>> > ...
>>>> > chn_k "Dat2", 2, 1
>>>> > ...
>>>> > chnset kData2, "Dat2"
>>>> >
>>>> > This works well. Now if I add a line:
>>>> > chnset kStatus, "BBBB"
>>>> > That works also without complaints although I haven't added any new
>>>> chn_k-definition.
>>>> > I would have expected some error-message at least during run-time
>>>> because of the missing
>>>> > channel definition.
>>>> >
>>>> > So the code works without complaints but where does that
>>>> kStatus-value now go, when "BBBB" is not defined ?
>>>> >
>>>> > 2) Java-side
>>>> > I assumed that the following code would catch an exception, if the
>>>> Csound-counterpart can not be found: (Note c is a csound-object here)
>>>> > try {
>>>> > c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
>>>> > controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
>>>> > controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
>>>> > controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
>>>> > } catch(Exception ee) {
>>>> > System.out.println("problemos");
>>>> > }
>>>> >
>>>> > So in this case I had a faulty definition for "Req1" in the
>>>> csound-code but not the required
>>>> > correct "Req".
>>>> > As a surprise to me java-code was executed without any error-messages
>>>> during run-time
>>>> > and the execution did not reach the catch-part above.
>>>> >
>>>> > Is the situation the same in the of python- or c++-case ?
>>>> > Or can this be handled by some other means, e.g. is there a way to
>>>> check the existence of the channel somehow before trying to connec to that ?
>>>> >
>>>> > --Risto
>>>> >
>>>> >
>>>> > Csound mailing list Csound@listserv.heanet.ie
>>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>>> https://github.com/csound/csound/issues Discussions of bugs and
>>>> features can be posted here
>>>>
>>>>
>>>> Csound mailing list
>>>> Csound@listserv.heanet.ie
>>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>>> Send bugs reports to
>>>>         https://github.com/csound/csound/issues
>>>> Discussions of bugs and features can be posted here
>>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and
>>> features can be posted here
>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and
>>> features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

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

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

Date2024-09-27 17:35
FromRisto Kuusisto
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Channel-related questions
Thanks Steven,

So that possibility is already there? Nice.

What about testing those in/out definitions ? Is it possible or is it worth to do ?
E.g. if I have this in java-code:

c.GetChannelPtr(CtNbrChannel.GetPtr(), "CtNbr",
    controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
    controlChannelType.CSOUND_INPUT_CHANNEL.swigValue() );

And the corresponding Csound:

chn_k CtNbr, 1

What happens if those doesn't match ? if i have CSOUND_OUTPUT_CHANNEL instead of CSOUND_INPUT_CHANNEL,
does the java-csound-combination still work ?


When using a channel in java  I have something like this:
  CtNbrChannel.SetValue(0, (double) Cnbr);

What does the first integer-parameter, 0, mean in this method ? I simply guessed that it means the first element in
some API-table and it works with the value 0 in a standard scalar-case, but what about if I put 55 there ?
Another guess is that it could be something to do with arrays. Is it possible to to create array-channels also ?
How do they show in Csound, if possible ?

--Risto

ke 25. syysk. 2024 klo 16.00 Steven Yi (stevenyi@gmail.com) kirjoitti:
I missed this thread earlier, but for what it's worth, I'm using Java FFM now with Csound and have released a library called CsoundFFM:

https://central.sonatype.com/artifact/com.kunstmusik/csoundffm

It works with Java 22+. It's not fully compliant with Csound API yet but does work with both Csound 6 and 7. (Currently using it in one of Blue's development branches.) 

For channels, would you prefer to have something that can check if a channel exists? Seems like that'd be enough API-wise for you to do:

if(!csound.channelExists("test')) {
  throw Exception("Channel test did not exist");
}

and you could create some utility functions around that for your code. 

On Wed, Sep 11, 2024 at 3:49 PM Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
I was not saying that channel management doesn't work. It seems to work fine.
The problem is that when I myself make a mistake, "Req1" on java-code, "Req2" on csound-code, what then ?
Neither java nor Csound does give any kind of error message, not during compilation or during run-time.

Maybe this has to be learned  in a hard way in practice and start to suspect the channel-names immediately,
if the application doesn't work as expected.

There seems to be this method in java also for Csound-object:

ListChannels()

I can see this in Eclipse. The problem is the argument type which has been copied here manually
from the help-display in Eclipse.
So the required argument type seen in Eclipse-help is SWIGTYPE_p_p_ControlChannellnfo_s.
I went through the whole list of methods for csound-object, but none of those has this type as their result type.
So I suppose it's something not doable in java.
Seems to be quite hard to stay in java without documentation when trying to communicate with Csound .
And "translating" c++ to java is a bit too much for me.

--Risto

ke 11. syysk. 2024 klo 21.39 Tarmo Johannes (trmjhnns@gmail.com) kirjoitti:
Hi Risto,

Yes, you should not worry about the channel management, it is very solid.
If in some reason your code needs to check which channels are available, you can use

PUBLIC int csoundListChannels(CSOUND *, controlChannelInfo_t **lst);
(this is from C API, most likely it is exposed also to the Java API)

from the code of CsoundQt (it is C++ ) to get some idea how it could be used.

As much I know, csoundListChannels reports only the channels that are declared with chn_k/chn_S, so that's why those opcodes are can be necessary.

It all depends  from your own use case, what you need and what your host does.

Best!
tarmo

Kontakt vlz (<viclazzarini@gmail.com>) kirjutas kuupäeval K, 11. september 2024 kell 21:32:
There is no error to speak of in this case.
This code has been used for over twenty years in numerous projects, including many commercial software that people pay money for and it has not been found that there is a design problem.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Sep 2024, at 18:41, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


OK, it has been designed in that way to be as flexible as possible. From programming point of view you can't be sure if your code is correct.
Neither compilation nor run-time doesn't give any indication of a possible error in your code.
In small cases this may not be a problem, but how about the larger ones ?

So there really isn't a method (in java/python/c++) that would tell the names of the available channels of the Csound-object in question?

--Risto


ke 11. syysk. 2024 klo 19.56 Victor Lazzarini (000010b17ddd988e-dmarc-request@listserv.heanet.ie) kirjoitti:
Whenever you call chnset, if the channel does not exist, it will be created. So in general, you may not need
to declare channels to start with.

The API function GetChannelPtr() likewise creates a channel if there isn’t one. From the API reference
(https://csound.com/docs/api/group__CONTROLEVENTS.html#gaeac3632d42e1d94d6d65a099f940a9db)

PUBLIC int csoundGetChannelPtr(CSOUND * ,MYFLT ** p,const char * name,int type )

Stores a pointer to the specified channel of the bus in *p, creating the channel first if it does not exist yet.

So you can just create a channel with it too.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Sep 2024, at 16:18, Risto Kuusisto <rjzkuusisto@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello all,
>
> I have been testing channels to communicate with java and partly also succeeded.
> Now I have noticed something, where I don't know if there is a problem in the versions of Csound (6.17) or csnd6.jar that I use.
> 1) Csound-side
> If i have something like this in csd-code:
> ...
> chn_k "Dat2", 2, 1
> ...
> chnset kData2, "Dat2"
>
> This works well. Now if I add a line:
> chnset kStatus, "BBBB"
> That works also without complaints although I haven't added any new chn_k-definition.
> I would have expected some error-message at least during run-time because of the missing
> channel definition.
>
> So the code works without complaints but where does that kStatus-value now go, when "BBBB" is not defined ?
>
> 2) Java-side
> I assumed that the following code would catch an exception, if the Csound-counterpart can not be found: (Note c is a csound-object here)
> try {
> c.GetChannelPtr(ReqChannel.GetPtr(), "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue()  |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catch(Exception ee) {
> System.out.println("problemos");
> }
>
> So in this case I had a faulty definition for "Req1" in the csound-code but not the required
> correct "Req".
> As a surprise to me java-code was executed without any error-messages during run-time
> and the execution did not reach the catch-part above.
>
> Is the situation the same in the of python- or c++-case ?
> Or can this be handled by some other means, e.g. is there a way to check the existence of the channel somehow before trying to connec to that ?
>
> --Risto
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


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