Csound Csound-dev Csound-tekno Search About

[Csnd] wrong line count when using macro

Date2024-10-22 08:26
Fromgiovanni damiani <00000f31ffed4c22-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] wrong line count when using macro
Hello everybody!

I often use the #define feature in the ‘orchestra’ and there is an issue with line count (very useful to track mistakes!): i tested that at the end of a macro recall, the line count restart to 1. Of course when I use more time a macro (that is the purpose to using it) it’s difficult to track the correct line number.

I attach the tested *.csd (the text at the end is intentionally wrong to count line numbered mistakes):

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0

#define d #
ii=1
kk=k(ii)
#

instr 1
kk linseg 0,p3,.5
aa poscil kk,440;,0
outch 1,aa
$d
endin
not line3 but 22...
</CsInstruments>
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>

Date2024-10-29 21:06
Fromgiovanni damiani <00000f31ffed4c22-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] wrong line count when using macro
Hi all,
I make some other tests about #define and macro in orchestra. Always Csound says:
error: syntax error, unexpected NEWLINE (token "") from file /Users/ada/Documents/csoundqt-temp.csd (1), line 3:
>>> linea <<<
The manual indeed is warning about some unexpected:
Performance

Some care is needed with textual replacement macros, as they can sometimes do strange things. They take no notice of any meaning, so spaces are significant.

I copy here my second test, where on my Mac Csound count line again from 3 after first macro recall, but the second restart to count from 5...

error: syntax error, unexpected NEWLINE (token "") from file /Users/ada/Documents/csoundqt-temp.csd (1), line 5:
And on windows 10 is this count far less predictable…

cheers,
Giovanni

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
#define macro#
ii=0
#

instr 1
$macro
linea ; intentional syntax error in order to count lines, LINE 16 not 3
endin

instr 2
$macro
linea ; intentional syntax error in order to count lines, LINE 21 not 5, as appear when I comment the former
endin
</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>

Il giorno 22 ott 2024, alle ore 09:26, giovanni damiani <giovdamiani@icloud.com> ha scritto:

Hello everybody!

I often use the #define feature in the ‘orchestra’ and there is an issue with line count (very useful to track mistakes!): i tested that at the end of a macro recall, the line count restart to 1. Of course when I use more time a macro (that is the purpose to using it) it’s difficult to track the correct line number.

I attach the tested *.csd (the text at the end is intentionally wrong to count line numbered mistakes):

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0

#define d #
ii=1
kk=k(ii)
#

instr 1
kk linseg 0,p3,.5
aa poscil kk,440;,0
outch 1,aa
$d
endin
not line3 but 22...
</CsInstruments>
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>