Re: [Csnd-dev] Csound 7: csoundListChannels returns always 0

Tarmo Johannes <[email protected]>
Newsgroups gmane.comp.audio.csound.devel
Message-ID <CAPvdOzC3NAsGviLP8x4XTRYD-WMZQ9t3QiA_jGeq1vwFmiDbAg@mail.gmail.com>
Hi!

yes, it was csoundStart(), inserting it 'kind of' solved the problem - now
the channels are read correctly - but I am not certain how to do it
properly.

The function in question is  CsoundEngine::runCsound()
https://github.com/CsoundQt/CsoundQt/blob/cbbcdaed5e002c280903e6c95d30a0d88ca4f858/src/csoundengine.cpp#L762

This is how it was organized before:

csoundCreate
 / setting callbacks etc /
csoundCompile
setupChannels ( including csoundListChannels() )
new CsoundPerformanceThread
CsoundPerformanceThread::Play()


Now I tried to insert csoundStart() before and after csoundCompile. If
before, the csoundCompile fails, if after, csoundStart() returned -1 and
reported in the console "Csound is already started, call csoundReset()
before starting again."
If I ignore the error and just keep going, everythings seems to work fine
but I don't like the message in CsoundQt console and ignoring error code
also does not feel right.

Can you see how to solve it?

Tarmo

Kontakt vlz (<[email protected]>) kirjutas kuupäeval N, 5. september
2024 kell 13:09:

> Looking at this, I think the change is that csoundStart() *always* need to
> be called now (it was an anomaly that it didn’t in some cases).
> So in the past if you used csoundCompile(csound, argc, arg), then
> csoundStart() was called and so channels would be there because
> it starts Csound running.
>
> > On 5 Sep 2024, at 09:27, Tarmo Johannes <[email protected]> wrote:
> >
> > Hm,
> >
> > in CsoundQt with the latest pull from Csound feature/newapi still the
> same result:
> >
> > controlChannelInfo_t *channelList;
> > int numChannels = csoundListChannels(ud->csound, &channelList);
> >
> > the second lines sets channelList to 0x0 and returns 0 as numChannels.
> >
> > When I build CsoundQt (the non modified code) agains Csound6, it returns
> correct number of channels.
> >
> > I need to go now but will think have closer look later. Maybe it is when
> is  csoundStart() called.
> >
> > tarmo
> >
> >
> >
> >
> >
> > Kontakt vlz (<[email protected]>) kirjutas kuupäeval N, 5.
> september 2024 kell 10:59:
> > I tested it here and it is working. See the test program
> >
> > const char *code =
> >   "0dbfs = 1              \n"
> >   "chn_k \"pitch\",3  \n"
> >   "instr 1                \n"
> >   "kp chnget \"pitch\"    \n"
> >   "a1 expon p4,p3,0.001   \n"
> >   "a2 oscil a1,cpsmidinn(p5)*kp\n"
> >   "    out a2             \n"
> >   "endin                  \n";
> >
> > int main(int argc, const char *argv[]) {
> >   /* Create the Csound engine instance */
> >   CSOUND *csound = csoundCreate(NULL, NULL);
> >
> >   if(csound != NULL) {
> >     int res = CSOUND_SUCCESS, i;
> >     /* Set options checking for any errors */
> >     for(i = 1; i < argc; i++)
> >       res += csoundSetOption(csound, argv[i]);
> >     if(res == CSOUND_SUCCESS) {
> >       /* Compile code from string, synchronously */
> >       res = csoundCompileOrc(csound, code, 0);
> >       if(res == CSOUND_SUCCESS) {
> >         char evt[64];
> >         MYFLT dur = 5.;
> >         MYFLT pitch = 1., incr = 1./(dur*csoundGetKr(csound));
> >         /* Start engine */
> >         res = csoundStart(csound);
> >         controlChannelInfo_t *list;
> >         int chn = csoundListChannels(csound, &list);
> >         csoundMessage(csound, "%d channels\n", chn);
> >         /* send realtine event, synchronously */
> >         snprintf(evt, 64, "i1 0 %f 0.1 60\n", dur);
> >         csoundEventString(csound, evt, 0);
> >        /* compute audio blocks */
> >         csoundPerformKsmps(csound);
> >         while(res == CSOUND_SUCCESS) {
> >           csoundSetControlChannel(csound, "pitch", pitch);
> >           res = csoundPerformKsmps(csound);
> >           pitch += incr;
> >           if(pitch > 2)
> >            csoundEventString(csound, "e 0", 0);
> >         }
> >       }
> >     }
> >     /* Destroy the engine instance */
> >     csoundDestroy(csound);
> >     return 0;
> >   }
> >   return -1;
> > }
> >
> > It prints
> >
> > SECTION 1:
> > 1 channels
> > new alloc for instr 1:
> >   T  5.000 TT  5.000 M:  0.09989
> > End of Performance inactive allocs returned to freespace
> >   overall amps:  0.09989
> >   overall samples out of range:        0
> > 0 errors in performance
> >
> >
> > > On 5 Sep 2024, at 08:06, Tarmo Johannes <[email protected]> wrote:
> > >
> > > Hi,
> > >
> > > This is mostly meant for Victor:
> > >
> > > Testing CsoundQt with Csound7 I discovered that the inital values are
> not read any more from the widgets, chnget returns 0 until the the widget
> is moved.
> > >
> > > CsoudnQt goes through the channels declared with chn_k/chn_S and puts
> a value read from according widgets into the channels.
> > > see
> https://github.com/CsoundQt/CsoundQt/blob/5ca6f63a11a470575bc53fcdc3629cd8079df2b4/src/csoundengine.cpp#L1062
> > >
> > > The problem is that with Csound 7 (built from feature/newapi Augus 30)
> > >
> > > csoundListChannels()
> > >
> > > returns always 0, although there are declared channels:
> > >
> > > controlChannelInfo_t *channelList;
> > > int numChannels = csoundListChannels(ud->csound, &channelList);
> > >
> > > What has changed? Might be that I need to implement it differently on
> CsoundQt side.
> > >
> > > Should I file a bug report?
> > >
> > > tarmo
>
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.