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

Method play

examples/src/Examples.hpp:132–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130struct ex_play_file : public labsound_example
131{
132 virtual void play(int argc, char ** argv) override final
133 {
134 const auto defaultAudioDeviceConfigurations = GetDefaultAudioDeviceConfiguration();
135 context = lab::MakeRealtimeAudioContext(defaultAudioDeviceConfigurations.second, defaultAudioDeviceConfigurations.first);
136 lab::AudioContext & ac = *context.get();
137
138 //auto musicClip = MakeBusFromSampleFile("samples/voice.ogg", argc, argv);
139 auto musicClip = MakeBusFromSampleFile("samples/stereo-music-clip.wav", argc, argv);
140 if (!musicClip)
141 return;
142
143 std::shared_ptr<SampledAudioNode> musicClipNode;
144 std::shared_ptr<GainNode> gain;
145
146 gain = std::make_shared<GainNode>(ac);
147 gain->gain()->setValue(0.5f);
148
149 musicClipNode = std::make_shared<SampledAudioNode>(ac);
150 {
151 ContextRenderLock r(context.get(), "ex_simple");
152 musicClipNode->setBus(r, musicClip);
153 }
154 context->connect(context->device(), musicClipNode, 0, 0);
155 musicClipNode->schedule(0.0);
156
157 // osc -> gain -> destination
158 context->connect(gain, musicClipNode, 0, 0);
159 context->connect(context->device(), gain, 0, 0);
160
161 _nodes.push_back(musicClipNode);
162 _nodes.push_back(gain);
163
164 Wait(6000);
165 }
166};
167
168

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected