Stk Library |top| -
STK is the blueprint, the toolbox, and the teacher, all rolled into one elegant C++ library. It is, and will remain, a classic.
int main() { Plucked pluck(440.0); // A4 note pluck.noteOn(0.7); // 70% amplitude stk library
// Let it ring for 2 seconds sleep(2); pluck.noteOff(0.1); // Release with 0.1s decay sleep(1); dac.stopStream(); return 0; } STK is the blueprint, the toolbox, and the
#include "Plucked.h" #include "RtAudio.h" #include <iostream> // Audio callback function int tick(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData) { Plucked *pluck = (Plucked *)userData; double *out = (double *)outputBuffer; for (unsigned int i = 0; i < nBufferFrames; i++) { *out++ = pluck->tick(); // Left channel *out++ = pluck->tick(); // Right channel } return 0; } STK is the blueprint
RtAudio dac; RtAudio::StreamParameters params; params.deviceId = dac.getDefaultOutputDevice(); params.nChannels = 2;