Skip to content

Commit

Permalink
Fix VST silent output
Browse files Browse the repository at this point in the history
  • Loading branch information
messmerd committed Dec 24, 2024
1 parent 5bd1ec3 commit 2a271fd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 6 additions & 4 deletions plugins/VstBase/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,18 +835,20 @@ void VstPlugin::updateBuffers(int channelsIn, int channelsOut)
void VstPlugin::bufferUpdated()
{
// Update the views into the RemotePlugin buffer
int idx = 0;
float* ptr = RemotePlugin::inputBuffer().data();
m_audioBufferIn.resize(channelsIn());
for (float* ptr = RemotePlugin::inputBuffer().data(); idx < channelsIn(); ++idx, ptr += frames())
for (pi_ch_t idx = 0; idx < channelsIn(); ++idx)
{
m_audioBufferIn[idx] = ptr;
ptr += frames();
}

idx = 0;
ptr = RemotePlugin::outputBuffer().data();
m_audioBufferOut.resize(channelsOut());
for (float* ptr = RemotePlugin::outputBuffer().data(); idx < channelsOut(); ++idx, ptr += frames())
for (pi_ch_t idx = 0; idx < channelsOut(); ++idx)
{
m_audioBufferOut[idx] = ptr;
ptr += frames();
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/core/RemotePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ bool RemotePlugin::process()

if (!m_audioBuffer)
{
// m_audioBuffer being zero means we didn't initialize everything so
// m_audioBuffer being null means we didn't initialize everything so
// far so process one message each time (and hope we get
// information like SHM-key etc.) until we process messages
// in a later stage of this procedure
Expand All @@ -353,8 +353,6 @@ bool RemotePlugin::process()
return false;
}

std::memset(m_audioBuffer.get(), 0, m_audioBufferSize);

lock();
sendMessage(IdStartProcessing);

Expand Down Expand Up @@ -382,6 +380,14 @@ void RemotePlugin::updateBuffer(int channelsIn, int channelsOut)
}

const auto frames = Engine::audioEngine()->framesPerPeriod();

if (channelsIn == static_cast<int>(m_channelsIn)
&& channelsOut == static_cast<int>(m_channelsOut)
&& frames == m_frames)
{
return;
}

const auto size = (channelsIn + channelsOut) * frames;

try
Expand All @@ -402,7 +408,7 @@ void RemotePlugin::updateBuffer(int channelsIn, int channelsOut)
m_channelsOut = static_cast<pi_ch_t>(channelsOut);

m_inputBuffer = Span<float>{m_audioBuffer.get(), m_channelsIn * m_frames};
m_outputBuffer = Span<float>{m_audioBuffer.get() + m_channelsIn * m_frames, m_channelsOut * m_frames};
m_outputBuffer = Span<float>{m_audioBuffer.get() + m_inputBuffer.size(), m_channelsOut * m_frames};

bufferUpdated();

Expand Down
6 changes: 3 additions & 3 deletions src/gui/EffectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :

if (auto pc = effect()->pinConnector())
{
constexpr auto formatString = "Pin connector\n%1";
const auto formatString = tr("Pin connector\n%1");

m_pinConnectorButton = new QPushButton(embed::getIconPixmap("tool", 20, 20), "", this);
m_pinConnectorButton->setToolTip(tr(formatString).arg(pc->getChannelCountText()));
m_pinConnectorButton->setToolTip(formatString.arg(pc->getChannelCountText()));

connect(pc, &PluginPinConnector::propertiesChanged, [=, this]() {
m_pinConnectorButton->setToolTip(tr(formatString).arg(effect()->pinConnector()->getChannelCountText()));
m_pinConnectorButton->setToolTip(formatString.arg(effect()->pinConnector()->getChannelCountText()));
});

m_pinConnectorButton->setGeometry(144 + 32, 12, 28, 28);
Expand Down

0 comments on commit 2a271fd

Please sign in to comment.