[Stk] Proper way to code file-based output using FileWvOut?

Rich M rmarsch at bu.edu
Fri Apr 10 14:19:18 PDT 2009


Hi,

to this point I have been using Real-Time output with the applications I 
have been writing using the STK libraries. I have tried searching for 
good examples of File-Based output using FileWvOut, but could not find 
any. The best example I found was the example sineosc.cpp at 
http://ccrma.stanford.edu/software/stk/hello.html where the 
output.tick(  StkFrames ) function is used. When I try a similar method 
in my program using tickFrames( StkFrames ), I get a heap error as well 
as the following error message from WvOut:

WvOut: data value(s) outside +-1.0 detected . . . clamping at outer bound!

Then Microsoft Visual C++ Debug Library brings up a Debug Assertion 
Failed at line 1317 of dbgheap.c complaining about an invalid heap pointer.

In the tick function I use to pass the StkFrames to the FileWvOut 
object, I implemented per-sample limiting to keep the values of each 
sample x within the bounds -1 < x < 1. I thought the error was because I 
was not preventing clipping of the audio signal, and thus WvOut 
complained. In real-time output the per-sample limiting works to keep 
the audio from clipping, so I don't see why it would all of a sudden not 
prevent clipping in the FileWvOut application.

Does anyone have some insight on this issue? I have included the excerpt 
of code I use to to initialize and build the output file below.

Thanks,
Rich


//File-based output branch
    if(outType == fileOutput){
        Stk::StkFormat format = ( sizeof(StkFloat) == 8 ) ? 
Stk::STK_FLOAT64 : Stk::STK_FLOAT32;

        string file;
        cout << "Enter the name for the output file (do not include 
.wav): ";
        cin >> file;
        file += ".wav";

        flout.openFile(file, AudioHandler::nChannels, 
FileWrite::FILE_WAV, format);

        for ( unsigned int i=0; i<in.getSize(); i++ ){
            flout.tickFrame( chorus.tick(&in, AudioHandler::bufferFrames) );
        }

        AudioHandler::done = true;

    }



More information about the Stk mailing list