Csound Csound-dev Csound-tekno Search About

[Csnd] SetChannel value not received by CSound?

Date2020-11-29 06:41
FromJarrad Hope
Subject[Csnd] SetChannel value not received by CSound?
I'm using the c++ api and embedding CSound into a software application. I have been attempting to pass a control parameter to Csound under a channel named "param1", but it is returning 0. However reading the string channel is fine, with the oscillator it also returns expected values over time.

Furthermore if I read csound->GetChannel("param1"), I see the value I set.

It's unclear to me what I am doing wrong?

// csound->SetControlChannel("param1", (MYFLT)0.5);
csound->SetChannel("param1", (MYFLT)0.5);
csound->PerformKsmps();
char tmp_string[4096] = { 0 };
csound->GetStringChannel("stringChannel", tmp_string);

my csd file is something like the following

<CsoundSynthesizer>
  <CsOptions> </CsOptions>
  <CsInstruments>
      sr = 44100 ; samplerate
      ksmps = 512 ; number of samples per control period
      nchnls = 2 ; number of I/O channels
   
      instr 1
        kParam chnget "param1"

      ; kParam oscil 1000, 1
      SText sprintfk "param1(\"%d\")", kParam
      chnset SText, "stringChannel"

      endin
  </CsInstruments>
  <CsScore>
      i1 0 10000 ; switch on instrument 1 for 10000 seconds
      ; f0 z ; run for 7000 years?
      e
  </CsScore>
</CsoundSynthesizer>

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

Date2020-11-29 08:05
FromEduardo Moguillansky
SubjectRe: [Csnd] SetChannel value not received by CSound?
Why do you use %d to receive 0.5?

On Sun, Nov 29, 2020, 07:51 Jarrad Hope <me@jarradhope.com> wrote:
I'm using the c++ api and embedding CSound into a software application. I have been attempting to pass a control parameter to Csound under a channel named "param1", but it is returning 0. However reading the string channel is fine, with the oscillator it also returns expected values over time.

Furthermore if I read csound->GetChannel("param1"), I see the value I set.

It's unclear to me what I am doing wrong?

// csound->SetControlChannel("param1", (MYFLT)0.5);
csound->SetChannel("param1", (MYFLT)0.5);
csound->PerformKsmps();
char tmp_string[4096] = { 0 };
csound->GetStringChannel("stringChannel", tmp_string);

my csd file is something like the following

<CsoundSynthesizer>
  <CsOptions> </CsOptions>
  <CsInstruments>
      sr = 44100 ; samplerate
      ksmps = 512 ; number of samples per control period
      nchnls = 2 ; number of I/O channels
   
      instr 1
        kParam chnget "param1"

      ; kParam oscil 1000, 1
      SText sprintfk "param1(\"%d\")", kParam
      chnset SText, "stringChannel"

      endin
  </CsInstruments>
  <CsScore>
      i1 0 10000 ; switch on instrument 1 for 10000 seconds
      ; f0 z ; run for 7000 years?
      e
  </CsScore>
</CsoundSynthesizer>

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
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