| 55 | } |
| 56 | |
| 57 | void 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 | |
| 113 | void ClipLauncher::DropdownClicked(DropdownList* list) |
| 114 | { |
nothing calls this directly
no test coverage detected