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

Method Process

Source/ClipLauncher.cpp:57–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void ClipLauncher::Process(double time)
58{
59 PROFILER(ClipLauncher);
60
61 IAudioReceiver* target = GetTarget();
62 if (!mEnabled || target == nullptr)
63 return;
64
65 ComputeSliders(0);
66
67 int bufferSize = target->GetBuffer()->BufferSize();
68 float* out = target->GetBuffer()->GetChannel(0);
69 assert(bufferSize == gBufferSize);
70
71 int sampleToPlay = -1;
72 for (int i = 0; i < mSamples.size(); ++i)
73 {
74 if (mSamples[i].mPlay)
75 sampleToPlay = i;
76 }
77
78 Sample* sample = nullptr;
79 float volSq = 1;
80 if (sampleToPlay != -1)
81 {
82 mSampleMutex.lock();
83
84 sample = mSamples[sampleToPlay].mSample;
85 volSq = mVolume * mSamples[sampleToPlay].mVolume;
86 volSq *= volSq;
87
88 float speed = sample->LengthInSamples() * gInvSampleRateMs / TheTransport->MsPerBar() / mSamples[sampleToPlay].mNumBars;
89 RecalcPos(time, sampleToPlay);
90 sample->SetRate(speed);
91 }
92
93 if (sample)
94 {
95 gWorkChannelBuffer.SetNumActiveChannels(1);
96 sample->ConsumeData(time, &gWorkChannelBuffer, bufferSize, true);
97 }
98
99 for (int i = 0; i < bufferSize; ++i)
100 {
101 float samp = 0;
102 if (sample)
103 samp = gWorkChannelBuffer.GetChannel(0)[i] * volSq;
104 samp = mJumpBlender.Process(samp, i);
105 out[i] += samp;
106 GetVizBuffer()->Write(samp, 0);
107 }
108
109 if (sampleToPlay != -1)
110 mSampleMutex.unlock();
111}
112
113void ClipLauncher::DropdownClicked(DropdownList* list)
114{

Callers

nothing calls this directly

Calls 10

BufferSizeMethod · 0.80
GetBufferMethod · 0.80
GetChannelMethod · 0.80
sizeMethod · 0.80
LengthInSamplesMethod · 0.80
MsPerBarMethod · 0.80
SetNumActiveChannelsMethod · 0.80
ConsumeDataMethod · 0.80
SetRateMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected