mirror of
https://github.com/thestk/stk
synced 2026-01-13 13:01:52 +00:00
Version 4.4.1
This commit is contained in:
committed by
Stephen Sinclair
parent
eccd8c9981
commit
b6a2202011
56
projects/examples/test.cpp
Normal file
56
projects/examples/test.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// sineosc.cpp STK tutorial program
|
||||
|
||||
#include "FileWvIn.h"
|
||||
#include "RtWvOut.h"
|
||||
using namespace stk;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
int nFrames = 100000;
|
||||
WvIn *input;
|
||||
// FileWvOut output;
|
||||
WvOut *output;
|
||||
|
||||
try {
|
||||
// Load the sine wave file.
|
||||
input = new FileWvIn( "hellosine.wav" );
|
||||
|
||||
// Open a 16-bit, one-channel WAV formatted output file
|
||||
// output = new FileWvOut( "hellosine.wav", 1, FileWrite::FILE_WAV, Stk::STK_SINT16 );
|
||||
output = new RtWvOut();
|
||||
}
|
||||
catch ( StkError & ) {
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
//input.setFrequency( 440.0 );
|
||||
|
||||
// Option 1: Use StkFrames
|
||||
/*
|
||||
StkFrames frames( nFrames, 1 );
|
||||
try {
|
||||
output->tick( input->tick( frames ) );
|
||||
}
|
||||
catch ( StkError & ) {
|
||||
exit( 1 );
|
||||
}
|
||||
*/
|
||||
|
||||
// Option 2: Single-sample computations
|
||||
for ( int i=0; i<nFrames; i++ ) {
|
||||
try {
|
||||
output->tick( input->tick() );
|
||||
}
|
||||
catch ( StkError & ) {
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
delete output;
|
||||
delete input;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user