Home
Nick Porcino edited this page Mar 3, 2018
·
10 revisions
Here's a LabSound Hello World. It plays A440 for one second.
int main()
{
auto context = lab::MakeRealtimeAudioContext();
auto oscillator = std::make_shared<OscillatorNode>(context->sampleRate());
auto gain = std::make_shared<GainNode>();
gain->gain()->setValue(0.0625f);
// osc -> gain -> destination
context->connect(gain, oscillator, 0, 0);
context->connect(context->destination(), gain, 0, 0);
oscillator->frequency()->setValue(440.f);
oscillator->setType(OscillatorType::SINE);
oscillator->start(0.0f);
std::this_thread::sleep_for(std::chrono::seconds(1));
return 0;
}