[Stk] Hello, and a bug?

Richard Dobson richarddobson@blueyonder.co.uk
Fri, 23 Jan 2004 23:55:35 +0000


Hello,

I have just joined the list. By way of introduction, I am a core developer for 
the UK-based Composers Desktop Project (CDP). I have been enjoying the STK 
remotely, so to speak, via it's derivations in Csound, with which I have been 
involved for many years.

I am currently one of a number of co-authors contributing to a book on C and C++ 
programming for musicians, under the editorship of Richard Boulanger.  We have 
some advanced chapters (by Michael Gogins) which feature the use of the STK in 
the context of creating VST plugins, and in so doing seem to have identified a 
bug in WaveLoop. The presenting issue is that this was being used (loading a 
sine wave) to provide modulation of a simple interpolating variable delay line, 
and we were getting a lot of distortion. This proved to be because the guard 
point at the end of the sine table (to use the Csound terminology) was not being 
set appropriately, it duplicated the final table point (in WvIn), whereas for an 
oscillator we need it to be copy of the first point. My current solution is to 
add some code to the WaveLoop constructor, copied from ReadData():

WaveLoop :: WaveLoop( const char *fileName, bool raw )
   : WvIn( fileName, raw ), phaseOffset(0.0)
{	
   // If at end of file, copy first sample frame for interpolation.
   if (chunkPointer+bufferSize == fileSize ) {
     for (unsigned int j=0; j<channels; j++)
       data[bufferSize*channels+j] = data[j];			
   }
}

With this change we get lovely clean modulation. I assume that for audio-rate 
oscillators, the error is unnoticeable. Would this change be likely to break 
anything else? Other possibly better solutions are clearly possible.

(I note that for very short tables such as this, chunking is 0, so readData 
never gets called inside tickFrame().)

Regards to all,

Richard Dobson