Hi,
I’m in the process of writing csound plugins to prototype/test a standalone dsp library I’ve been developing to good effect, but am running into some trouble being able to verify sample accurate offsets from the engine.
I will try not to paste too much code in here but I think I’m grabbing the recommended stuff in my process_block function:
...
uint32_t nsmps = GetLocalKsmps(&obj->h);
uint32_t offset = obj->h.insdshead->ksmps_offset;
uint32_t early = obj->h.insdshead->ksmps_no_end;
// testing the sample accurate API
if (UNLIKELY(offset)) {
memset(out, '\0', offset * sizeof(MYFLT));
}
if (UNLIKELY(early)) {
nsmps -= early;
memset(&out[nsmps], '\0', early * sizeof(MYFLT));
}
csound->Message(csound, "nsmps=%u offset=%u early=%u\n", nsmps, offset, early);
...
In my score I am testing the opcode in instruments using this event timing:
<CsoundSynthesizer>
<CsOptions>
--opcode-lib=./build/csnd/libblpcsnd.so
--opcode-lib=./build/csnd/libblpcsnd.dylib
-t 60
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 64
nchnls = 1
0dbfs = 1
; ddelay -- test static delay line
instr 1
aenv linseg 1, 0.05, 0
asig oscili 0.7 * aenv, 440
kdel init p4
kfb init p5
adel = kdel ; milliseconds
afb = kfb ; 0 - 1
idelmax = 1.0
aout ddelay2 asig, adel, afb, idelmax
out aout * 0.5 + asig * 0.5
endin
; ddelay -- test modulation
instr 2
; test input
aenv linseg 1, 0.05, 0
asig oscili 0.4 * aenv, 440
adel linseg p4, p3, p5
afb linseg p6, p3, p7
idelmax = 1.0
aout ddelay2 asig, adel, afb, idelmax
out aout * 0.5 + asig * 0.5
endin
</CsInstruments>
<CsScore>
i1 0.0127 2 200 0.6
i2 2.0123 3 100 800 0.7 0.3
i2 5.742 2 200 10 0.6 0.8
</CsScore>
</CsoundSynthesizer>
which I would expect to give me offset/early at the start and end of the events… however I only get nsmps=64 offset=0 early=0 reported for each kblock…
I’ve run the cli like:
csound --sample-accurate -o dac ./script.csd
csound --sample-accurate ./script.csd
There are no issues with the rest of my plugin’s process_block and I get good audio output from the plugin so really it seems that the engine is just not reporting the timing for me for some reason i can’t figure out and falling back to the ksmps block.
Here’s the version I’m using btw (compiled with floats on ubuntu 22):
--Csound version 7.0 (float samples) Jul 6 2025
[commit: 13e86532f568b6c148fbff180a8bf934f97dec5b]
Please let me know if I’m overlooking something obvious… I’m a bit stumped. If there is any other relevent code/config needed from my build to figure it out just let me know and I’ll reply with it
thanks! happy holidaze!
-johnny