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

Method Process

Source/VSTPlugin.cpp:707–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707void VSTPlugin::Process(double time)
708{
709 if (!mPluginReady)
710 {
711 //bypass
712 GetBuffer()->SetNumActiveChannels(2);
713 SyncBuffers();
714 for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch)
715 {
716 if (GetTarget())
717 Add(GetTarget()->GetBuffer()->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize());
718 GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize(), ch);
719 }
720
721 GetBuffer()->Clear();
722 }
723
724#if BESPOKE_LINUX //HACK: weird race condition, which this seems to fix for now
725 if (mPlugin == nullptr)
726 return;
727#endif
728
729 PROFILER(VSTPlugin);
730
731 int inputChannels = MAX(2, mNumInputChannels);
732 int outputChannels = MAX(2, mNumOutputChannels);
733 GetBuffer()->SetNumActiveChannels(inputChannels);
734 SyncBuffers();
735
736 /*
737 * Multi-out VSTs which can't disable those outputs will expect *something* in the
738 * buffer even though we don't read it.
739 */
740 int bufferChannels = MAX(MAX(inputChannels * mNumInBuses, outputChannels * mNumOutBuses), 2); // how much to allocate in the juce::AudioBuffer
741
742 const int kSafetyMaxChannels = 16; //hitting a crazy issue (memory stomp?) where numchannels is getting blown out sometimes
743
744 int bufferSize = GetBuffer()->BufferSize();
745 assert(bufferSize == gBufferSize);
746
747 juce::AudioBuffer<float> buffer(bufferChannels, bufferSize);
748 for (int i = 0; i < inputChannels && i < kSafetyMaxChannels; ++i)
749 buffer.copyFrom(i, 0, GetBuffer()->GetChannel(MIN(i, GetBuffer()->NumActiveChannels() - 1)), GetBuffer()->BufferSize());
750
751 IAudioReceiver* target = GetTarget();
752
753 if (mEnabled && mPlugin != nullptr)
754 {
755 mVSTMutex.lock();
756
757 ComputeSliders(0);
758
759 {
760 const juce::ScopedLock lock(mMidiInputLock);
761
762 for (int i = 0; i < mChannelModulations.size(); ++i)
763 {
764 ChannelModulations& mod = mChannelModulations[i];

Callers

nothing calls this directly

Calls 14

AddFunction · 0.85
ofMapFunction · 0.85
ofClampFunction · 0.85
SetNumActiveChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetBufferMethod · 0.80
BufferSizeMethod · 0.80
WriteChunkMethod · 0.80
sizeMethod · 0.80
PlayNoteOutputMethod · 0.80
SendCCOutputMethod · 0.80

Tested by

no test coverage detected