| 142 | } |
| 143 | |
| 144 | void 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 | { |
nothing calls this directly
no test coverage detected