[Csnd] Data buuffer between csound and host program ?
Date | 2024-05-06 18:24 |
From | Risto Kuusisto |
Subject | [Csnd] Data buuffer between csound and host program ? |
Hello, Piece by piece learning about communication between a host program (java/python/...) and csound. The examples show the channel-method for that purpose. Anyway if i like to do something like this: - the host reads a vector of values e.g. at every 10ms => 480 values in a buffer if the sampling frequency is 48 kHz - the host is using those values increase real-time trend buffer in order to show the trend - during each 10 ms csound needs to fill some buffer with new new values for the next read from the host I have seen only simple examples, where only a single value (or scalar), not a vector, is updated. Can the vector-based communication also be implemented with csound itself and through csound-api ? And what if the data is midi-messages instead of audio ? (= integer values) --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 |
Date | 2024-05-06 19:32 |
From | vlz |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
yes, you can use an audio bus channel. Access it using csoundGetChannelPtr() audio channels handle vectors of ksmps samples alternatively you can access the main IO buffers, spin and spout these will give you vectors of ksmps frames, interleaved. Prof. Victor Lazzarini Maynooth University Ireland On 6 May 2024, at 18:24, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-06 20:03 |
From | Risto Kuusisto |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
Ok I try to understand those. But how about midi ? If I understand correctly, those mentioned ones are reserved for audio (float). In the case of midi the usual keyboard-case would not require buffering. My case is related to a guitar effect pedal. When you change the patch, the device sends a program change number followed with the patch parameters as control change values. These I would like to get to the UI-host without loosing any of these. --Risto ma 6. toukok. 2024 klo 21.32 vlz <viclazzarini@gmail.com> kirjoitti:
|
Date | 2024-05-07 16:24 |
From | Risto Kuusisto |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
It seems that the idea of having enough time-resolution to catch every midi-message and keep the k-rate at some mild value, e.g. 5ms, is not doable. The stopper is already in Csound. If i try to do something like: akStatus, akChan, akData1, akData2 midiin , I get complaints from csound. This is not allowed, because midiin accepts only k-variables. If I use k-variables there, it means that I need to speed-up the k-rate to a value that is not practical for the host-UI program. And actually I don't know how fast rate would be needed if the connection is not a midi-cable but an Ethernet-midi connection instead. --risto ma 6. toukok. 2024 klo 22.03 Risto Kuusisto (rjzkuusisto@gmail.com) kirjoitti:
|
Date | 2024-05-07 17:03 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
Absolutely no idea what you are going on about. All frontends, hosts, whatever, using Csound work perfectly fine with midi and do not lose a single message. This has been the case since about 1992 when midi was first introduced to Csound.
If that weren't the case we would have know by now over 30 years later.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 7 May 2024, at 16:24, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-07 18:38 |
From | Risto Kuusisto |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
If i understand correctly midi-messages are read at k-rate ? How about if k-rate corresponds to e.g. 5ms ? One midiCC-message could consist of 2 bytes, which corresponds to 16 bits. The standard wired midi-connection speed is 31.25 kHz. This means that the required time for one midiCC-message is 16/31250 s = 0.000512 s. This means that during 5ms time there could be place for almost 10 of these. So if you read the messages at every 5ms, you could loose almost 9 of these, because you can read only (probably) the last one of those arrived during this 5ms period. The situation is worse if the connection is e.g. Ethernet-midi, where the speed is something else. --Risto ti 7. toukok. 2024 klo 19.03 Victor Lazzarini (Victor.Lazzarini@mu.ie) kirjoitti:
|
Date | 2024-05-07 18:58 |
From | vlz |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
You don't get only single midi message in a k-cycle. You can have as many as you need. Why are you making all these absurd assumptions without knowing how the system works? If there was such a ridiculous bottleneck, would you not think people could not notice it? It would be unusuable. Prof. Victor Lazzarini Maynooth University Ireland On 7 May 2024, at 18:38, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-07 19:05 |
From | Michael Gogins |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
You could write code to parse MIDI events to Csound "i" statements and send them to Csound using csoundReadScore. Csound will handle all the scheduling as with any other score events. On Tue, May 7, 2024, 13:58 vlz <viclazzarini@gmail.com> wrote:
|
Date | 2024-05-07 19:22 |
From | vlz |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
While one could do that, if you have a midi stream you can just pass it to Csound via the API callbacks and let the engine deal with it. No need for any further complication. Prof. Victor Lazzarini Maynooth University Ireland On 7 May 2024, at 19:06, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2024-05-07 19:42 |
From | Risto Kuusisto |
Subject | Re: [Csnd] Data buuffer between csound and host program ? |
As I have earlier mentioned I'm a newcomer in csound-world. The functional logic is not that clear to me yet. In the case of audio I understood that the a-variables are actually vectors that store ksmps-amount of values in them for each k-cycle and then you can read the whole vector to host-UI at the same interval. With my limited understanding I didn't find a way how to do the same with midi-messages. (from Csound Journal - Issue 10; An Overview of Csound Variable Types. ... "k-type: These variables hold scalar values which are updated
only once per control period." ) --Risto ti 7. toukok. 2024 klo 20.58 vlz (viclazzarini@gmail.com) kirjoitti:
|