MCPcopy Create free account
hub / github.com/audacity/audacity / MakeInstances

Function MakeInstances

libraries/lib-mixer/EffectStage.cpp:20–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19namespace {
20std::vector<std::shared_ptr<EffectInstance>> MakeInstances(
21 const EffectStage::Factory& factory, EffectSettings& settings,
22 double sampleRate, std::optional<sampleCount> genLength, int channel,
23 int nInputChannels)
24{
25 std::vector<std::shared_ptr<EffectInstance>> instances;
26 // Make as many instances as needed for the channels of the source, which
27 // depends on how the instances report how many channels they accept
28 const auto nChannels = (channel < 0) ? nInputChannels : 1;
29 for (size_t ii = 0; ii < nChannels;)
30 {
31 auto pInstance = factory();
32 if (!pInstance)
33 // A constructor that can't satisfy its post should throw instead
34 throw std::exception{};
35 auto count = pInstance->GetAudioInCount();
36 ChannelName map[3]{ ChannelNameEOL, ChannelNameEOL, ChannelNameEOL };
37 MakeChannelMap(nInputChannels, channel, map);
38 // Give the plugin a chance to initialize
39 if (!pInstance->ProcessInitialize(settings, sampleRate, map))
40 throw std::exception{};
41 instances.resize(ii);
42
43 // Beware generators with zero in count
44 if (genLength)
45 count = nChannels;
46
47 instances.push_back(move(pInstance));
48
49 // Advance ii
50 if (count == 0)
51 // What? Can't make progress
52 throw std::exception();
53 ii += count;
54 }
55 return instances;
56}
57}
58
59EffectStage::EffectStage(

Callers 1

EffectStageMethod · 0.85

Calls 5

MakeChannelMapFunction · 0.85
moveFunction · 0.85
GetAudioInCountMethod · 0.45
ProcessInitializeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected