Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ?
Date | 2024-05-07 21:52 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
As a newcomer you have to first assume it works (and it does). Then learn the system.
midiin will deliver all channel messages received. If you have a blocksize that is too large, then you should loop over the opcode to pick up all messages until the buffer is empty. That is what the manual says: "Normally (i.e., when no messages are pending)
kstatus is zero, only when MIDI data are present in the MIDI IN buffer, is kstatus set to the type of the relevant messages."
There are manual examples showing that for occasions when this might be relevant:
This is exactly the case also for OSClisten.
Typical ksmps are 32, 64, which is around 1ms at 44.1k. While theoretically usb midi may deliver messages at a faster rate, the 3125 bytes/s gives us a limit of around 1ms per 3 byte midi message. Software midi of course may run faster, however there has
been no indication from VST plugin users of any difficulties with Csound responding to midi from a DAW. Hadron for example was reported to have had 1/4 M downloads by 2019. You would think that if there was a problem, it would have been noted. Csound will
respond to as many channel messages it receives.
You can run Csound with ksmps = 1 and pick up a message per sample if you wished. You can loop to oversample the midi read. That's all of course an edge case if at all possible with current midi hardware and APIs.
If there is a bug, then a ticket is opened with a well documented demonstration and diagnostics. Then it is worked on and fixed.
No ifs or buts or wrong poorly informed assumptions.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 7 May 2024, at 19:43, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-08 11:39 |
From | Risto Kuusisto |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
Sorry, my purpose was not to claim any bug in csound. If there is a bug it is in my own understanding. That fluidSynth-link showed how to read midi-in buffer to csound during the k-cycle. I suppose when the status-value (kst) is 0, that means that the buffer is empty ? That solved the midi-in -> csound part. Still having problems to implement the csound -> java communication. Here's some kind of thought-example, how I would do it. If the loop would be done in java, I would add something like this in the loop: kDataBuffer[ j++ ] = kData; // kData represents some value of the midi-message Now after the k-cycle is over I would read both kDataBuffer and j to java. If e.g. 3 messages had arrived in the csound, then j=3 and java-code would know that there are 3 elements in the vector. But how to do that using csound functions and syntax ? Again it is quite clear that I don't understand, so no idea how to proceed. --Risto ti 7. toukok. 2024 klo 23.52 Victor Lazzarini (Victor.Lazzarini@mu.ie) kirjoitti:
|
Date | 2024-05-08 13:59 |
From | Rory Walsh |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
Can you explain if you are using Java to communicate with the audio IO drivers, or Csound. I'm unclear exactly who's in charge of outputting audio. In my typical setup, I use an audio library to output samples to the sound card, and I use Csound to process those samples. If this is what you're doing, then check out the Csound API MIDI callbacks. Have a look at how they work in Cabbage: The read midi callback gets passed a pointer to Csound's midi buffer. Cabbage fills this buffer with MIDI data from the host. I'm not sure this is helpful at all. If you are only providing a UI to Csound then things should be simpler. On Wed, 8 May 2024 at 11:39, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-08 15:23 |
From | Risto Kuusisto |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
Thanks for a hint. My c++-understanding is not the best, but I guess you read the csound input midi-buffer directly? How does this show in the corresponding csound source-code ? Or does it show there at all? My case is for a guitar effect unit. When I change the patch there (with the included mechanical buttons or with an external midi-controller), the device sends midi: 1. The corresponding program change number 2. All related controllable patch parameters as midiCC-messages. (Typical parameters e.g. delay length, flanger frequency, pre-gain before amplifier simulator, post-gain, treble, bass, middle etc.) I want to read all of those midi-messages into csound. Then feed midiCC-values to java-UI as starting values for corresponding sliders. After that it would be possible to move the sliders in the UI and write new values back to csound. (future addition: to a file) This part should be a typical case, only scalar values at a time and transformation of integer values to suitable k-variable values in csound. And from csound to midi-out. In this first case csound would not touch the audio all. --Risto ke 8. toukok. 2024 klo 16.00 Rory Walsh (rorywalsh@ear.ie) kirjoitti:
|
Date | 2024-05-08 15:38 |
From | Rory Walsh |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
This is trivial, no matter what language you use. When the MIDI messages come in from your device you can use the chnset opcode to send data to your host, which will then update the UI accordingly. You will need to run some kind of loop in your host app to pick up channel data.
This will be done using the SetControlChannel() API method. The channel data you send there can be picked up in Csound using the chnget opcode. :+1: |
Date | 2024-05-08 18:27 |
From | Risto Kuusisto |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
Do you think that the speed requirement for the loop at the host side is not a problem if it has to poll the chn-data all the time ? Or is there any possibility to construct the loop in a way that it waits for the next chnset on the csound side before the next round instead of running as fast as possible? The messages come in bursts and there should be no reason to do anything until the next burst arrives. --Risto ke 8. toukok. 2024 klo 17.38 Rory Walsh (rorywalsh@ear.ie) kirjoitti:
|
Date | 2024-05-09 07:02 |
From | Rory Walsh |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
It's not a problem to poll for the data. You can do this on a background thread. There is a callback system too using the invalue/outvalue opcodes but in my experience polling works better. 👍 On Wed 8 May 2024, 6:28 p.m. Risto Kuusisto, <rjzkuusisto@gmail.com> wrote:
|
Date | 2024-05-09 07:08 |
From | Risto Kuusisto |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] Data buuffer between csound and host program ? |
Thanks, I will proceed according to this advice. --Risto to 9. toukok. 2024 klo 9.02 Rory Walsh <rorywalsh@ear.ie> kirjoitti:
|