| 503 | struct ex_runtime_graph_update : public labsound_example |
| 504 | { |
| 505 | virtual void play(int argc, char ** argv) override |
| 506 | { |
| 507 | std::shared_ptr<OscillatorNode> oscillator1, oscillator2; |
| 508 | std::shared_ptr<GainNode> gain; |
| 509 | |
| 510 | { |
| 511 | const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration(); |
| 512 | context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first); |
| 513 | lab::AudioContext& ac = *context.get(); |
| 514 | |
| 515 | { |
| 516 | oscillator1 = std::make_shared<OscillatorNode>(ac); |
| 517 | oscillator2 = std::make_shared<OscillatorNode>(ac); |
| 518 | |
| 519 | gain = std::make_shared<GainNode>(ac); |
| 520 | gain->gain()->setValue(0.50); |
| 521 | |
| 522 | // osc -> gain -> destination |
| 523 | context->connect(gain, oscillator1, 0, 0); |
| 524 | context->connect(gain, oscillator2, 0, 0); |
| 525 | context->connect(context->device(), gain, 0, 0); |
| 526 | |
| 527 | oscillator1->setType(OscillatorType::SINE); |
| 528 | oscillator1->frequency()->setValue(220.f); |
| 529 | oscillator1->start(0.00f); |
| 530 | |
| 531 | oscillator2->setType(OscillatorType::SINE); |
| 532 | oscillator2->frequency()->setValue(440.f); |
| 533 | oscillator2->start(0.00); |
| 534 | } |
| 535 | |
| 536 | _nodes.push_back(oscillator1); |
| 537 | _nodes.push_back(oscillator2); |
| 538 | _nodes.push_back(gain); |
| 539 | |
| 540 | for (int i = 0; i < 4; ++i) |
| 541 | { |
| 542 | context->disconnect(nullptr, oscillator1, 0, 0); |
| 543 | context->connect(gain, oscillator2, 0, 0); |
| 544 | Wait(200); |
| 545 | |
| 546 | context->disconnect(nullptr, oscillator2, 0, 0); |
| 547 | context->connect(gain, oscillator1, 0, 0); |
| 548 | Wait(200); |
| 549 | } |
| 550 | |
| 551 | context->disconnect(nullptr, oscillator1, 0, 0); |
| 552 | context->disconnect(nullptr, oscillator2, 0, 0); |
| 553 | } |
| 554 | |
| 555 | std::cout << "OscillatorNode 1 use_count: " << oscillator1.use_count() << std::endl; |
| 556 | std::cout << "OscillatorNode 2 use_count: " << oscillator2.use_count() << std::endl; |
| 557 | std::cout << "GainNode use_count: " << gain.use_count() << std::endl; |
| 558 | } |
| 559 | }; |
| 560 | |
| 561 | ////////////////////////////////// |
nothing calls this directly
no test coverage detected