Re: [Csnd-dev] [EXTERNAL] [Csnd-dev] New API progress report

Victor Lazzarini <[email protected]>
Newsgroups gmane.comp.audio.csound.devel
Message-ID <[email protected]>
Thanks for this. Responses below

> On 26 Jul 2024, at 20:29, Tarmo Johannes <[email protected]> wrote:
> Hi!
> 
> I tried out the new API from feature/newapi branch.
> 
> Building csound7 went fine, I installed it to $HOME/.local (Linux) and added  $HOME/.local/lib to ldconfig libraries' path. 
> 
> First I tried it with a relatively simple Qt project using Csound C++ API (csound.hpp). After some changes everything worked fine. One question:
> 
> when before there was Csound::stop() / csoundStop() , how is it now the proper way to end Csound's work? Also csoundCleanup() is gone. is csoundReset() it that does it all?

csoundStop() was only needed if we were running csoundPerform(), but since that’s gone, we do not need it.
Also csoundCleanup() is not really necessary now, csoundReset() suffices.

Also I am enforcing csoundStart() at all times now (before it was confusing that sometimes we did not need it).

> Then I went to CsoundQt and of course that is much, much more complex  case.
> 
> First -  I guess libcsnd7 is not  is built by default? Is it still existing, how should I configure it?  CsoundQt uses that for recording. Maybe there is now a better way to rewrite the recording part. 

There is only one library, and CsPerformanceThread is included in it, so you can use it directly now. I guess that is the only class in
that library that was consistently used.

> CsoundQt used the following functions that are not to be there any more:
> 
> csoundGetModule
> csoundSetMIDIModule
> csoundSetRTAudioModule
> 
> I commented these lines out for now to move on. What covers their functionality?

Normally, I would have thought that the command line options were sufficient for module setting, but if you
use these functions, I will put them back

> There is no more circular buffer functions:
> csoundCreateCircularBuffer
> csoundReadCircularBuffer
> etc
> 
> CsoundQt leaned heavily on them for internal MIDI handling. What is the correct way to handle it now?
> For example reading MIDI data one should set the callback like:
>         csoundSetExternalMidiReadCallback(ud->csound, &midiReadCb);
> 
> CsoundQt used to have such a function for the callback:
> 
> int CsoundEngine::midiReadCb(CSOUND *csound, void *ud_, unsigned char *buf, int nBytes)
> {
>     CsoundUserData *ud = (CsoundUserData *) ud_;
>     Q_UNUSED(csound);
>     int count, countVirtual;
>     count =  csoundReadCircularBuffer(ud->csound, ud->midiBuffer, buf, nBytes);
>     countVirtual =  csoundReadCircularBuffer(ud->csound, ud->virtualMidiBuffer, buf + count, nBytes - count);
>     return count + countVirtual;
> }
> 
> Should the host implement writing to the buffer and handling the index itself?

I can put them back, I did not know they were used. No point on re-writing them if they worked for you.

> 
> Is it so that csoundSetHostImplementedMIDIIO is replaced now with   
> PUBLIC void csoundSetHostMIDIIO(CSOUND *csound);
> 

yes

> How to deal with global variables?
> csoundQueryGlobalVariable
> csoundCreateGlobalVariable
> are gone,

The “global variables” that these functions refer to are variables added to the CSOUND data structure
dynamically so that opcodes can share data. Hosts should not need them as you can hold anything in
your hostdata etc.

I removed these because they really only make sense for the module API.

What is your use case for those?

> csoundGetEnv is there but no csoundSetEnv, csoundSetGlobalEnv or similar?
> 
> at the moment I replaced them with Qt specific functions to deal with environment variables.

I think that is a good idea, but if you need csoundSetEnv() I can add it back

> 
> What is the correct environment variable for the plugins directory, OPCODE7DIR64?

yes, OPCODE7DIR64 and OPCODE7DIR (for floats)

> I got CsoundQt building but it crashes when I run a file. I did not have time yet to dig into it,  there are many possible reasons.  I hope to continue tomorrow.

Keep me posted.

> Exciting!
> tarmo
> 
> Kontakt Victor Lazzarini (<[email protected]>) kirjutas kuupäeval N, 25. juuli 2024 kell 18:27:
> 
> Just another progress report for the feature/newapi branch
> 
> - I have now mainlined the new API in csound.h
> - Updated the csound.hpp wrapper 
> - Updated the csPerformanceThread code 
> - Modified frontends to use it 
> - Modified the C++ test suite
> 
> It is all working, I guess frontend developers can take a look and see what they
> think. 
> 
> François: could you take a look at the Python wrapper? It is out of sync now.
> 
> Victor
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.