If you want to test this you can ask ChatGPT to create a JUCE vst plugin process block for you using tanh here’s the result:
Code: Select all
void YourAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
// Clear any output channels that are not being used
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
// Apply tanh distortion to each sample
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer(channel);
for (int sample = 0; sample < buffer.getNumSamples(); ++sample)
{
// Apply tanh to each sample for distortion
channelData[sample] = std::tanh(channelData[sample]);
}
}
}