#include "FileWvIn.h" #include "FileWvOut.h" #include "BiQuad.h" using namespace stk; int main( int argc, char *argv[] ) { FileWvIn input; FileWvOut output; if ( argc != 2 ) { std::cout << "usage: " << argv[0] << " file" << std::endl; std::cout << " where 'file' is an input soundfile to process" << std::endl; exit(0); } try { // Load the input file input.openFile( argv[1] ); } catch ( StkError & ) { exit(0); } // Set the global STK sample rate to the input file sample rate. Stk::setSampleRate( input.getFileRate() ); // Reset the input file reader increment to 1.0 input.setRate( 1.0 ); try { // Define and open a 16-bit, one-channel WAV formatted output file output.openFile( "filter2", 2, FileWrite::FILE_AIF, Stk::STK_SINT16 ); } catch ( StkError & ) { input.closeFile(); exit(0); } BiQuad filter; filter.setResonance( 1000.0, 0.999, true ); // set resonance to 1000 Hz, pole radius = 0.999, and normalize gain StkFrames frame( 1, 2 ); // one frame of 2 channels int i; i = input.getSize(); // in sample frames while ( i-- >= 0 ) { try { // single frame computations frame[0] = input.tick(); frame[1] = filter.tick( frame[0] ); output.tick( frame ); } catch ( StkError & ) { goto cleanup; } } cleanup: input.closeFile(); output.closeFile(); return 0; }
![]() | ©2004-2024 McGill University. All Rights Reserved. Maintained by Gary P. Scavone. |