MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Process

Method Process

Source/AudioRouter.cpp:49–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void AudioRouter::Process(double time)
50{
51 PROFILER(AudioRouter);
52
53 SyncBuffers();
54 mBlankVizBuffer.SetNumChannels(GetBuffer()->NumActiveChannels());
55
56 for (size_t i = 0; i < mDestinationCables.size(); ++i)
57 {
58 if ((int)i == mRouteIndex)
59 mDestinationCables[i]->SetOverrideVizBuffer(nullptr);
60 else
61 mDestinationCables[i]->SetOverrideVizBuffer(&mBlankVizBuffer);
62 }
63
64 bool doSwitchAndRamp = false;
65 if (mRouteIndex != mLastProcessedRouteIndex)
66 {
67 doSwitchAndRamp = true;
68 mLastProcessedRouteIndex = mRouteIndex;
69 }
70
71 IAudioReceiver* target = GetTarget(mRouteIndex + 1);
72
73 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
74 {
75 float* outputBuffer = GetBuffer()->GetChannel(ch);
76 if (doSwitchAndRamp)
77 mSwitchAndRampIn[ch].Start(time, outputBuffer[0], 0, time + 100);
78
79 if (abs(mSwitchAndRampIn[ch].Value(time)) > .01f)
80 {
81 BufferCopy(gWorkBuffer, outputBuffer, GetBuffer()->BufferSize());
82 outputBuffer = gWorkBuffer;
83 for (int i = 0; i < GetBuffer()->BufferSize(); ++i)
84 outputBuffer[i] -= mSwitchAndRampIn[ch].Value(time + i * gInvSampleRateMs);
85 }
86
87 if (target != nullptr)
88 {
89 Add(target->GetBuffer()->GetChannel(ch), outputBuffer, GetBuffer()->BufferSize());
90 GetVizBuffer()->WriteChunk(outputBuffer, GetBuffer()->BufferSize(), ch);
91 }
92 }
93
94 GetBuffer()->Reset();
95}
96
97void AudioRouter::Poll()
98{

Callers

nothing calls this directly

Calls 13

BufferCopyFunction · 0.85
AddFunction · 0.85
SetNumChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
sizeMethod · 0.80
SetOverrideVizBufferMethod · 0.80
GetChannelMethod · 0.80
BufferSizeMethod · 0.80
GetBufferMethod · 0.80
WriteChunkMethod · 0.80
StartMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected