LCOV - code coverage report
Current view: top level - src/audio/effects/pitch - octaver.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 60.0 % 5 3
Test Date: 2026-06-07 15:51:50 Functions: 50.0 % 4 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/core/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            0 :     const std::vector<EffectParam>& params() const override { return params_; }
      33              : 
      34              :    private:
      35              :     std::vector<EffectParam> params_;
      36              : 
      37              :     // Oct-1 state: flip-flop divider
      38              :     float prev_sample_ = 0.0f;  // previous sample for zero-crossing detection
      39              :     float flipflop_ = 1.0f;     // +1 or -1, toggles on hysteresis-gated positive zero crossings
      40              : 
      41              :     // Oct+1 state: DC blocker for full-wave rectified signal
      42              :     float dc_x1_ = 0.0f;  // previous input to DC blocker
      43              :     float dc_y1_ = 0.0f;  // previous output of DC blocker
      44              : 
      45              :     // Envelope follower for shaping synthesized octave signals
      46              :     float envelope_ = 0.0f;
      47              : 
      48              :     // Parameter smoothing
      49              :     float oct_down_smooth_ = 0.0f;
      50              :     float oct_up_smooth_ = 0.0f;
      51              :     float dry_smooth_ = 0.0f;
      52              : };
      53              : 
      54              : }  // namespace Amplitron
        

Generated by: LCOV version 2.0-1