@@ -37,6 +37,7 @@ class ReNooicePlugin : public Plugin
3737 // whether we received enough latent audio frames
3838 bool processing;
3939
40+ #ifndef SIMPLIFIED_NOOICE
4041 // translate Grace Period param (ms) into 48kHz frames
4142 // updated when param changes
4243 uint32_t gracePeriodInFrames = 0 ;
@@ -101,6 +102,7 @@ class ReNooicePlugin : public Plugin
101102 running = false ;
102103 }
103104 } stats;
105+ #endif
104106
105107public:
106108 /* *
@@ -110,6 +112,7 @@ class ReNooicePlugin : public Plugin
110112 ReNooicePlugin ()
111113 : Plugin(kParamCount , 0 , 0 ) // parameters, programs, states
112114 {
115+ #ifndef SIMPLIFIED_NOOICE
113116 dryValue.setTimeConstant (0 .02f );
114117 dryValue.setTargetValue (0 .f );
115118
@@ -118,6 +121,7 @@ class ReNooicePlugin : public Plugin
118121
119122 parameters[kParamThreshold ] = 60 .f ;
120123 parameters[kParamMinimumVAD ] = 100 .f ;
124+ #endif
121125
122126 // initial sample rate setup
123127 sampleRateChanged (getSampleRate ());
@@ -183,6 +187,7 @@ class ReNooicePlugin : public Plugin
183187 Plugin::initAudioPort (input, index, port);
184188 }
185189
190+ #ifndef SIMPLIFIED_NOOICE
186191 /* *
187192 Initialize the parameter @a index.
188193 This function will be called once, shortly after the plugin is created.
@@ -291,6 +296,7 @@ class ReNooicePlugin : public Plugin
291296 break ;
292297 }
293298 }
299+ #endif
294300
295301 // ----------------------------------------------------------------------------------------------------------------
296302 // Audio/MIDI Processing
@@ -309,6 +315,7 @@ class ReNooicePlugin : public Plugin
309315 bufferInPos = 0 ;
310316 processing = false ;
311317
318+ #ifndef SIMPLIFIED_NOOICE
312319 parameters[kParamCurrentVAD ] = 0 .f ;
313320 parameters[kParamAverageVAD ] = 0 .f ;
314321 parameters[kParamMinimumVAD ] = 100 .f ;
@@ -320,6 +327,7 @@ class ReNooicePlugin : public Plugin
320327 muteValue.clearToTargetValue ();
321328
322329 stats.reset ();
330+ #endif
323331 }
324332
325333 /* *
@@ -343,6 +351,7 @@ class ReNooicePlugin : public Plugin
343351 const float * input = inputs[0 ];
344352 /* */ float * output = outputs[0 ];
345353
354+ #ifndef SIMPLIFIED_NOOICE
346355 // reset stats if enabled status changed
347356 const bool statsEnabled = parameters[kParamEnableStats ] > 0 .5f ;
348357 if (stats.enabled != statsEnabled)
@@ -353,6 +362,7 @@ class ReNooicePlugin : public Plugin
353362
354363 // pass this threshold to unmute
355364 const float threshold = parameters[kParamThreshold ] * 0 .01f ;
365+ #endif
356366
357367 // process audio a few frames at a time, so it always fits nicely into denoise blocks
358368 for (uint32_t offset = 0 ; offset != frames;)
@@ -376,6 +386,14 @@ class ReNooicePlugin : public Plugin
376386 for (uint32_t i = 0 ; i < denoiseFrameSize; ++i)
377387 bufferIn[i] *= kDenoiseScaling ;
378388
389+ #ifdef SIMPLIFIED_NOOICE
390+ // run denoise
391+ rnnoise_process_frame (denoise, bufferOut, bufferIn);
392+
393+ // scale back down to regular audio level
394+ for (uint32_t i = 0 ; i < denoiseFrameSize; ++i)
395+ bufferOut[i] *= kDenoiseScalingInv ;
396+ #else
379397 // run denoise
380398 const float vad = rnnoise_process_frame (denoise, bufferOut, bufferIn);
381399
@@ -409,6 +427,7 @@ class ReNooicePlugin : public Plugin
409427 parameters[kParamMinimumVAD ] = stats.min * 100 .f ;
410428 parameters[kParamMaximumVAD ] = stats.max * 100 .f ;
411429 }
430+ #endif
412431
413432 // write denoise output into ringbuffer
414433 ringBufferOut.writeCustomData (bufferOut, denoiseFrameSizeF);
@@ -418,6 +437,7 @@ class ReNooicePlugin : public Plugin
418437 // we have enough audio frames in the ring buffer, can give back audio to host
419438 if (processing)
420439 {
440+ #ifndef SIMPLIFIED_NOOICE
421441 // apply smooth bypass
422442 if (d_isNotEqual (dryValue.getCurrentValue (), dryValue.getTargetValue ()))
423443 {
@@ -434,17 +454,18 @@ class ReNooicePlugin : public Plugin
434454 output[i] = output[i] * wet + bufferOut[i] * dry;
435455 }
436456 }
437- // enabled (bypass off )
438- else if (d_isZero (dryValue.getTargetValue ()))
457+ // disable (bypass on )
458+ else if (d_isNotZero (dryValue.getTargetValue ()))
439459 {
440460 // copy processed buffer directly into output
441461 ringBufferOut.readCustomData (output, framesCycleF);
442462
443463 // retrieve dry buffer (doing nothing with it)
444464 ringBufferDry.readCustomData (bufferOut, framesCycleF);
445465 }
446- // disable (bypass on )
466+ // enabled (bypass off )
447467 else
468+ #endif
448469 {
449470 // copy dry buffer directly into output
450471 ringBufferDry.readCustomData (output, framesCycleF);
@@ -475,8 +496,10 @@ class ReNooicePlugin : public Plugin
475496 */
476497 void sampleRateChanged (const double sampleRate) override
477498 {
499+ #ifndef SIMPLIFIED_NOOICE
478500 dryValue.setSampleRate (sampleRate);
479501 muteValue.setSampleRate (sampleRate);
502+ #endif
480503 setLatency (d_roundToUnsignedInt (sampleRate / 48000.0 * denoiseFrameSize));
481504 }
482505
0 commit comments