MCPcopy Create free account
hub / github.com/LabSound/LabSound / play

Method play

examples/src/Examples.hpp:1602–1639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1600struct ex_split_merge : public labsound_example
1601{
1602 virtual void play(int argc, char ** argv) override final
1603 {
1604 _nodes.clear();
1605
1606 std::unique_ptr<lab::AudioContext> context;
1607 const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration();
1608 context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first);
1609 lab::AudioContext & ac = *context.get();
1610
1611 std::shared_ptr<ChannelSplitterNode> splitter = std::make_shared<ChannelSplitterNode>(ac,6);
1612 std::shared_ptr<ChannelMergerNode> merger = std::make_shared<ChannelMergerNode>(ac,6);
1613 std::shared_ptr<GainNode> gain = std::make_shared<GainNode>(ac);
1614 gain->gain()->setValueAtTime(.5f,(float)ac.currentTime());
1615
1616 auto chan6_source = MakeBusFromSampleFile("samples/6_Channel_ID.wav", argc, argv);
1617 std::shared_ptr<SampledAudioNode> musicClipNode;
1618 musicClipNode = std::make_shared<SampledAudioNode>(ac);
1619 {
1620 ContextRenderLock r(context.get(), "ex_split_merge");
1621 musicClipNode->setBus(r, chan6_source);
1622 }
1623
1624 context->connect(splitter, musicClipNode);
1625 context->connect(merger, splitter, 0, 1); // swap front-left
1626 context->connect(merger, splitter, 1, 0); // and front right to demonstrate channels can be swapped
1627 context->connect(gain, merger, 0, 0);
1628 context->connect(context->device(), gain, 0, 0);
1629 musicClipNode->schedule(0.0);
1630
1631 // ensure nodes last until the end of the demo
1632 _nodes.push_back(musicClipNode);
1633 _nodes.push_back(gain);
1634 _nodes.push_back(merger);
1635 _nodes.push_back(splitter);
1636
1637 const uint32_t delay_time_ms = 2000;
1638 Wait(delay_time_ms);
1639 }
1640};

Callers

nothing calls this directly

Calls 11

MakeRealtimeAudioContextFunction · 0.85
clearMethod · 0.80
getMethod · 0.80
setValueAtTimeMethod · 0.80
deviceMethod · 0.80
scheduleMethod · 0.80
gainMethod · 0.45
currentTimeMethod · 0.45
setBusMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected