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.
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
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 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.
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 ?
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)
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?
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
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.
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 ?
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 ?
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
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)
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
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?
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
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.
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 ?
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 ?
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)
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
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?
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
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.
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 ?
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 ?
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.
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:
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.
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 csoundListChannelsCSOUND \*, controlChannelInfo\_t \*\*lst; this is from C API, most likely it is exposed also to the Java API
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
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.
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
>
> *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.GetChannelPtrReqChannel\.GetPtr\(, "Req",
> controlChannelType.CSOUND_CONTROL_CHANNEL.swigValue() |
> controlChannelType.CSOUND_INPUT_CHANNEL.swigValue() |
> controlChannelType.CSOUND_OUTPUT_CHANNEL.swigValue());
> } catchException 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 LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE Send bugs reports to Issues · csound/csound · GitHub Discussions of bugs and
features can be posted here
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 ?
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.
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)
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
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?
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
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.
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 ?
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 ?