Csound Csound-dev Csound-tekno Search About

[Csnd] Booleans: goto vs then

Date2017-12-22 14:18
FromHlöðver Sigurðsson
Subject[Csnd] Booleans: goto vs then
Somehow I had the impression that `then` was just a syntatical sugar for igoto/kgoto (depending the rate of the comparator test). But I'm bit surprised that these two examples aren't eqivalent

gi1 ftgen 0, 0, 8192, 10, 1

instr ex1
  if (p5 == 0) igoto case_0
  igoto case_1
  case_0:
    a10 vco 0.1, p4, 1, 0, gi1
    igoto case_endif
  case_1:
    a10 poscil 0.1, p4, gi1
  case_endif:
    outs a10, a10
endin

instr ex2
  if (p5 == 0) then
    a10 vco 0.1, p4, 1, 0, gi1
  else
    a10 poscil 0.1, p4, gi1    
  endif
  outs a10, a10
endin

ex1 throws this error
PERF ERROR in instr 1: poscil: not initialised
a10 poscil.a 0.1 p4 gi1 0
   note aborted

ex2 works fine.
Some way to make ex1 work like this with gotos?
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

Date2017-12-22 15:00
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Booleans: goto vs then
ah nevermind, my misunderstanding. It should be kgoto here, since it needs to be on performance-time. Took it that the comparator could only be i or k rate and the decision made once.


On 22 December 2017 at 15:18, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Somehow I had the impression that `then` was just a syntatical sugar for igoto/kgoto (depending the rate of the comparator test). But I'm bit surprised that these two examples aren't eqivalent

gi1 ftgen 0, 0, 8192, 10, 1

instr ex1
  if (p5 == 0) igoto case_0
  igoto case_1
  case_0:
    a10 vco 0.1, p4, 1, 0, gi1
    igoto case_endif
  case_1:
    a10 poscil 0.1, p4, gi1
  case_endif:
    outs a10, a10
endin

instr ex2
  if (p5 == 0) then
    a10 vco 0.1, p4, 1, 0, gi1
  else
    a10 poscil 0.1, p4, gi1    
  endif
  outs a10, a10
endin

ex1 throws this error
PERF ERROR in instr 1: poscil: not initialised
a10 poscil.a 0.1 p4 gi1 0
   note aborted

ex2 works fine.
Some way to make ex1 work like this with gotos?

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