Csound Csound-dev Csound-tekno Search About

[Csnd] Update global strings

Date2013-11-13 20:44
FromBernt Isak Wærstad
Subject[Csnd] Update global strings
I'm working on some logging functionality in Csound and I tried to separate time keeping from the rest of the code, but for some reason it seems my global string variable holding the date and time does not update when used from other instruments. Or perhaps I'm off with some of my timing? 

Here is the output when the same variable is printed from the time keeping instrument it self (instr 1) and the instrument (instr 2) that calls the time keeping instrument:

Time from instr 1: 2013_Nov_13_21_37_23
Time from instr 2: 2013_Nov_13_21_37_23
Time from instr 1: 2013_Nov_13_21_37_23
Time from instr 2: 2013_Nov_13_21_37_23
Time from instr 1: 2013_Nov_13_21_37_24
Time from instr 2: 2013_Nov_13_21_37_23
Time from instr 1: 2013_Nov_13_21_37_25
Time from instr 2: 2013_Nov_13_21_37_23

Here is the CSD:


<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-+rtaudio=jack -odac:system:playback_ -b512 -B2048
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
;;generating a different filename each time csound renders
itim     date
Stim     dates     itim
Syear    strsub    Stim, 20, 24
Smonth   strsub    Stim, 4, 7
Sday     strsub    Stim, 8, 10
iday     strtod    Sday
Shor     strsub    Stim, 11, 13
Smin     strsub    Stim, 14, 16
Ssec     strsub    Stim, 17, 19
gStime  sprintf  "%s_%s_%02d_%s_%s_%s\n", Syear, Smonth, iday, Shor,Smin, Ssec

printks "Time from instr 1: ", 1
printks gStime, 1

endin

instr 2

        kmetro metro 1

        if kmetro == 1 then
                schedkwhen kmetro, 0, 1, 1, 0, 1
                printks "Time from instr 2: ", 1
                printks  gStime, 1
        endif

endin

</CsInstruments>
<CsScore>
i 1 0 1
i 2 0 4
</CsScore>
</CsoundSynthesizer>


--
Mvh.

Bernt Isak Wærstad