Hi Guys, I’m working on a Csound code where I’m trying to convert local string variables to global float variables. I’ve been trying to use both strtodk
and strtod
, but I keep encountering an error where strtodk
reads an empty string. Could anyone help me figure out how these opcodes need to be used correctly to avoid this issue? Below is the code snippet I’ve been working on:
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1
instr 2
read:
Sline, kLineNum readf "config.txt"
printk 0,kLineNum
printf "Line %d: %s", kLineNum, kLineNum, Sline
if (kLineNum==1) then
printks "Sline(volume) : %s",1,Sline
kVol strtodk Sline
printks " kVol:%s\n", 1, kVol
gkVol = kVol
printks "global value(float): %f\n",8, gkVol
elseif (kLineNum==2) then
printks "Sline(pause) : %s\n",1,Sline
kPause strtodk Sline
printks "kPause : %s\n",1, kPause
gkPause = kPause
printks "global pause(float) :%f\n",8, gkPause
endif
if (kLineNum<2) kgoto read
turnoff
endin
</CsInstruments>
<CsScore>
i2 0 1 ; Read and store values
</CsScore>
</CsoundSynthesizer>
Here is the error message I’m receiving:
SECTION 1:
new alloc for instr 2:
INIT ERROR in instr 2 (opcode (null)) line 20: strtodk: empty string
from file arc54.csd (1)
kVol strtodk Sline
B 0.000 - note deleted. i2 had 1 init errors
End of Performance inactive allocs returned to freespace
overall amps: 0.00000 0.00000
overall samples out of range: 0 0
1 errors in performance
Elapsed time at end of performance: real: 0.184s, CPU: 0.004s
0 512 sample blks of 64-bit floats written to dac