LCOV - code coverage report
Current view: top level - src/audio/effects - octaver.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 75.0 % 4 3
Test Date: 2026-06-03 09:13:19 Functions: 66.7 % 3 2

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : // Octave generator for sub-octave and upper-octave guitar tones.
       4              : // Sub-octave generation derives a period-doubled component from zero-crossing
       5              : // state, while the upper octave emphasizes rectified/nonlinear content; output
       6              : // blends dry, sub, and upper components by their mix gains.
       7              : 
       8              : #include "audio/effects/effect.h"
       9              : 
      10              : namespace Amplitron {
      11              : 
      12              : /**
      13              :  * Monophonic Octaver — generates sub-octave (Oct-1) and upper-octave (Oct+1)
      14              :  * signals blended with the dry input.
      15              :  *
      16              :  * Oct-1: Zero-crossing flip-flop divider produces a square wave at half the
      17              :  *        input frequency, shaped by the input envelope for a warm, organ-like tone.
      18              :  * Oct+1: Full-wave rectification (|x|) doubles the fundamental frequency,
      19              :  *        followed by DC removal and envelope shaping.
      20              :  *
      21              :  * Classic references: Boss OC-2, EHX Octave Multiplexer.
      22              :  */
      23            7 : class Octaver : public Effect {
      24              : public:
      25              :     Octaver();
      26              :     void process(float* buffer, int num_samples) override;
      27              :     void set_sample_rate(int sample_rate) override;
      28              :     void reset() override;
      29            0 :     const char* name() const override { return "Octaver"; }
      30            3 :     const char* type_id() const override { return "Octaver"; }
      31          194 :     std::vector<EffectParam>& params() override { return params_; }
      32              : 
      33              : private:
      34              :     std::vector<EffectParam> params_;
      35              : 
      36              :     // Oct-1 state: flip-flop divider
      37              :     float prev_sample_ = 0.0f;       // previous sample for zero-crossing detection
      38              :     float flipflop_ = 1.0f;          // +1 or -1, toggles on hysteresis-gated positive zero crossings
      39              : 
      40              :     // Oct+1 state: DC blocker for full-wave rectified signal
      41              :     float dc_x1_ = 0.0f;             // previous input to DC blocker
      42              :     float dc_y1_ = 0.0f;             // previous output of DC blocker
      43              : 
      44              :     // Envelope follower for shaping synthesized octave signals
      45              :     float envelope_ = 0.0f;
      46              : 
      47              :     // Parameter smoothing
      48              :     float oct_down_smooth_ = 0.0f;
      49              :     float oct_up_smooth_ = 0.0f;
      50              :     float dry_smooth_ = 0.0f;
      51              : };
      52              : 
      53              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1