| 80 | struct 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 |
nothing calls this directly
no test coverage detected