MCPcopy Create free account
hub / github.com/GuitarML/NeuralPi / processBlock

Method processBlock

Source/PluginProcessor.cpp:176–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174
175
176void NeuralPiAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
177{
178 ScopedNoDenormals noDenormals;
179
180 // Setup Audio Data
181 const int numSamples = buffer.getNumSamples();
182 const int numInputChannels = getTotalNumInputChannels();
183 const int sampleRate = getSampleRate();
184
185 auto block = dsp::AudioBlock<float>(buffer).getSingleChannelBlock(0);
186 auto context = juce::dsp::ProcessContextReplacing<float>(block);
187
188 // Amp =============================================================================
189 if (amp_state == 1) {
190 auto gain = static_cast<float> (gainParam->get());
191 auto master = static_cast<float> (masterParam->get());
192 // Note: Default 0.0 -> 1.0 param range is converted to +-12.0 here
193 auto bass = (static_cast<float> (bassParam->get() - 0.5) * 24.0);
194 auto mid = (static_cast<float> (midParam->get() - 0.5) * 24.0);
195 auto treble = (static_cast<float> (trebleParam->get() - 0.5) * 24.0);
196 auto presence = (static_cast<float> (presenceParam->get() - 0.5) * 24.0);
197
198 auto delay = (static_cast<float> (delayParam->get()));
199 auto reverb = (static_cast<float> (reverbParam->get()));
200
201 auto model = static_cast<float> (modelParam->get());
202 model_index = getModelIndex(model);
203
204 auto ir = static_cast<float> (irParam->get());
205 ir_index = getIrIndex(ir);
206
207 // Applying gain adjustment for snapshot models
208 if (LSTM.input_size == 1) {
209 buffer.applyGain(gain * 2.0);
210 }
211
212 // Process EQ
213 eq4band.setParameters(bass, mid, treble, presence);// Better to move this somewhere else? Only need to set when value changes
214 eq4band.process(buffer.getReadPointer(0), buffer.getWritePointer(0), midiMessages, numSamples, numInputChannels, sampleRate);
215
216 // Apply LSTM model
217 if (model_loaded == 1 && lstm_state == true) {
218 if (current_model_index != model_index) {
219 loadConfig(jsonFiles[model_index]);
220 current_model_index = model_index;
221 }
222
223 // Process LSTM based on input_size (snapshot model or conditioned model)
224 if (LSTM.input_size == 1) {
225 LSTM.process(buffer.getReadPointer(0), buffer.getWritePointer(0), numSamples);
226 } else {
227 LSTM.process(buffer.getReadPointer(0), gain, buffer.getWritePointer(0), numSamples);
228 }
229 }
230
231 // Process IR
232 if (ir_state == true && num_irs > 0) {
233 if (current_ir_index != ir_index) {

Callers

nothing calls this directly

Calls 4

getMethod · 0.80
setParametersMethod · 0.80
getNumChannelsMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected