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

Method play

examples/src/Examples.hpp:82–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80struct ex_simple : public labsound_example
81{
82 virtual void play(int argc, char** argv) override final
83 {
84 const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration();
85 context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first);
86 lab::AudioContext& ac = *context.get();
87
88 auto musicClip = MakeBusFromSampleFile("samples/stereo-music-clip.wav", argc, argv);
89 if (!musicClip)
90 return;
91
92 std::shared_ptr<OscillatorNode> oscillator;
93 std::shared_ptr<SampledAudioNode> musicClipNode;
94 std::shared_ptr<GainNode> gain;
95
96 oscillator = std::make_shared<OscillatorNode>(ac);
97 gain = std::make_shared<GainNode>(ac);
98 gain->gain()->setValue(0.5f);
99
100 musicClipNode = std::make_shared<SampledAudioNode>(ac);
101 {
102 ContextRenderLock r(context.get(), "ex_simple");
103 musicClipNode->setBus(r, musicClip);
104 }
105 context->connect(context->device(), musicClipNode, 0, 0);
106 musicClipNode->schedule(0.0);
107
108 // osc -> gain -> destination
109 context->connect(gain, oscillator, 0, 0);
110 context->connect(context->device(), gain, 0, 0);
111
112 oscillator->frequency()->setValue(440.f);
113 oscillator->setType(OscillatorType::SINE);
114 oscillator->start(0.0f);
115
116 _nodes.push_back(oscillator);
117 _nodes.push_back(musicClipNode);
118 _nodes.push_back(gain);
119
120 Wait(6000);
121 }
122};
123
124

Callers

nothing calls this directly

Calls 12

MakeRealtimeAudioContextFunction · 0.85
getMethod · 0.80
setValueMethod · 0.80
deviceMethod · 0.80
scheduleMethod · 0.80
gainMethod · 0.45
setBusMethod · 0.45
connectMethod · 0.45
frequencyMethod · 0.45
setTypeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected