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

Method Process

Source/ControllingSong.cpp:144–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144void ControllingSong::Process(double time)
145{
146 PROFILER(ControllingSong);
147
148 IAudioReceiver* target = GetTarget();
149 if (!mEnabled || target == nullptr)
150 return;
151
152 ComputeSliders(0);
153
154 int bufferSize = target->GetBuffer()->BufferSize();
155 float* out = target->GetBuffer()->GetChannel(0);
156 assert(bufferSize == gBufferSize);
157
158 float volSq = mVolume * mVolume * .5f;
159
160 mSample.SetRate(mSpeed);
161
162 for (int i = 0; i < mFollowSongs.size(); ++i)
163 {
164 mFollowSongs[i]->SetPlaybackInfo(mPlay, mSample.GetPlayPosition(), mSpeed, mVolume);
165 }
166
167 if (!mLoadingSong && mPlay)
168 {
169 mLoadSongMutex.lock();
170
171 double ms = mSample.GetPlayPosition() / mSample.GetSampleRateRatio() / double(gSampleRate) * 1000.0;
172 if (ms >= 0)
173 {
174 TheTransport->SetTempo(MIN(200, mMidiReader.GetTempo(ms)) * mSpeed);
175 int measure;
176 float measurePos;
177 mMidiReader.GetMeasurePos(ms, measure, measurePos);
178 TheTransport->SetMeasureTime(measure + measurePos);
179 }
180
181 gWorkChannelBuffer.SetNumActiveChannels(1);
182 if (mSample.ConsumeData(time, &gWorkChannelBuffer, bufferSize, true))
183 {
184 for (int i = 0; i < bufferSize; ++i)
185 {
186 float sample = gWorkChannelBuffer.GetChannel(0)[i] * volSq;
187 if (mMute)
188 sample = 0;
189 out[i] += sample;
190 GetVizBuffer()->Write(sample, 0);
191 }
192 }
193 else
194 {
195 //mNeedNewSong = true;
196 GetVizBuffer()->WriteChunk(gZeroBuffer, bufferSize, 0);
197 }
198 mLoadSongMutex.unlock();
199 }
200 else
201 {

Callers

nothing calls this directly

Calls 15

BufferSizeMethod · 0.80
GetBufferMethod · 0.80
GetChannelMethod · 0.80
sizeMethod · 0.80
SetPlaybackInfoMethod · 0.80
GetPlayPositionMethod · 0.80
SetTempoMethod · 0.80
SetMeasureTimeMethod · 0.80
SetNumActiveChannelsMethod · 0.80
ConsumeDataMethod · 0.80
WriteChunkMethod · 0.80
SetRateMethod · 0.45

Tested by

no test coverage detected