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

Method play

examples/src/Examples.hpp:916–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914struct ex_misc : public labsound_example
915{
916 virtual void play(int argc, char ** argv) override
917 {
918 const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration();
919 context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first);
920 lab::AudioContext& ac = *context.get();
921
922 std::array<int, 8> majorScale = {0, 2, 4, 5, 7, 9, 11, 12};
923 std::array<int, 8> naturalMinorScale = {0, 2, 3, 5, 7, 9, 11, 12};
924 std::array<int, 6> pentatonicMajor = {0, 2, 4, 7, 9, 12};
925 std::array<int, 8> pentatonicMinor = {0, 3, 5, 7, 10, 12};
926 std::array<int, 8> delayTimes = {266, 533, 399};
927
928 auto randomFloat = std::uniform_real_distribution<float>(0, 1);
929 auto randomScaleDegree = std::uniform_int_distribution<int>(0, int(pentatonicMajor.size()) - 1);
930 auto randomTimeIndex = std::uniform_int_distribution<int>(0, static_cast<int>(delayTimes.size()) - 1);
931
932 auto audioClip = MakeBusFromSampleFile("samples/voice.ogg", argc, argv);
933 std::shared_ptr<SampledAudioNode> audioClipNode = std::make_shared<SampledAudioNode>(ac);
934 std::shared_ptr<PingPongDelayNode> pingping = std::make_shared<PingPongDelayNode>(ac, 240.0f);
935
936 {
937 ContextRenderLock r(context.get(), "ex_misc");
938
939 pingping->BuildSubgraph(*context.get());
940 pingping->SetFeedback(.75f);
941 pingping->SetDelayIndex(lab::TempoSync::TS_16);
942
943 context->connect(context->device(), pingping->output, 0, 0);
944
945 audioClipNode->setBus(r, audioClip);
946
947 context->connect(pingping->input, audioClipNode, 0, 0);
948
949 audioClipNode->schedule(0.25);
950 }
951
952 _nodes.push_back(audioClipNode);
953
954 _nodes.push_back(pingping->output);
955 _nodes.push_back(pingping->input);
956 _nodes.push_back(pingping->leftDelay);
957 _nodes.push_back(pingping->rightDelay);
958 _nodes.push_back(pingping->splitterGain);
959 _nodes.push_back(pingping->wetGain);
960 _nodes.push_back(pingping->feedbackGain);
961 _nodes.push_back(pingping->merger);
962 _nodes.push_back(pingping->splitter);
963
964 Wait(10000);
965 }
966};
967
968///////////////////////////

Callers 1

mainFunction · 0.45

Calls 11

MakeRealtimeAudioContextFunction · 0.85
getMethod · 0.80
sizeMethod · 0.80
BuildSubgraphMethod · 0.80
SetFeedbackMethod · 0.80
deviceMethod · 0.80
scheduleMethod · 0.80
SetDelayIndexMethod · 0.45
connectMethod · 0.45
setBusMethod · 0.45

Tested by

no test coverage detected