| 1494 | struct ex_granulation_node : public labsound_example |
| 1495 | { |
| 1496 | virtual void play(int argc, char** argv) override final |
| 1497 | { |
| 1498 | const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration(); |
| 1499 | context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first); |
| 1500 | lab::AudioContext& ac = *context.get(); |
| 1501 | |
| 1502 | auto grain_source = MakeBusFromSampleFile("samples/voice.ogg", argc, argv); |
| 1503 | if (!grain_source) |
| 1504 | return; |
| 1505 | |
| 1506 | std::shared_ptr<GranulationNode> granulation_node(new GranulationNode(ac)); |
| 1507 | std::shared_ptr<GainNode> gain(new GainNode(ac)); |
| 1508 | std::shared_ptr<RecorderNode> recorder; |
| 1509 | gain->gain()->setValue(0.75f); |
| 1510 | granulation_node->numGrains->setValue(20.f); |
| 1511 | |
| 1512 | { |
| 1513 | ContextRenderLock r(context.get(), "ex_granulation_node"); |
| 1514 | recorder = std::make_shared<RecorderNode>(ac, defaultAudioDeviceConfigurations.second); |
| 1515 | context->addAutomaticPullNode(recorder); |
| 1516 | recorder->startRecording(); |
| 1517 | granulation_node->setGrainSource(r, grain_source); |
| 1518 | } |
| 1519 | |
| 1520 | context->connect(gain, granulation_node, 0, 0); |
| 1521 | context->connect(context->device(), gain, 0, 0); |
| 1522 | context->connect(recorder, gain, 0, 0); |
| 1523 | |
| 1524 | granulation_node->start(0.0f); |
| 1525 | |
| 1526 | _nodes.push_back(granulation_node); |
| 1527 | _nodes.push_back(gain); |
| 1528 | _nodes.push_back(recorder); |
| 1529 | |
| 1530 | //AddMonitorNodes(); // testing |
| 1531 | Wait(10000); |
| 1532 | |
| 1533 | recorder->stopRecording(); |
| 1534 | context->removeAutomaticPullNode(recorder); |
| 1535 | recorder->writeRecordingToWav("ex_granulation_node.wav", false); |
| 1536 | } |
| 1537 | }; |
| 1538 | |
| 1539 | //////////////////////// |
nothing calls this directly
no test coverage detected