summaryrefslogtreecommitdiffstats
path: root/src/engine/enginepregain.h
blob: 6248b40261830a75b319d043efab5cd4b8edc1e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "engine/engineobject.h"
#include "control/controlobject.h"
#include "util/performancetimer.h"

class ControlAudioTaperPot;
class ControlPotmeter;
class ControlObject;

// The pregain control alters the volume of the track based on several inputs,
// including user pregain adjustment, ReplayGain value, and vinyl-like
// adjustments in volume relative to playback speed.
class EnginePregain : public EngineObject {
  public:
    EnginePregain(QString group);
    ~EnginePregain() override;

    // If the user is scratching and the record reverses direction, the volume
    // will be ramped to zero and back up again to mimic a vinyl scratch.
    // If the user is not scratching and the direction is reversed
    // (e.g. reverse button is pressed), the audio will be immediately
    // reversed without a ramp to zero.
    void setSpeedAndScratching(double speed, bool scratching);

    void process(CSAMPLE* pInOut, const int iBufferSize) override;

    void collectFeatures(GroupFeatureState* pGroupFeatures) const override;

  private:
    double m_dSpeed;
    double m_dOldSpeed;
    double m_dNonScratchSpeed;
    bool m_scratching;
    CSAMPLE_GAIN m_fPrevGain;
    ControlAudioTaperPot* m_pPotmeterPregain;
    ControlObject* m_pTotalGain;
    ControlObject* m_pCOReplayGain;
    ControlObject* m_pPassthroughEnabled;
    static ControlPotmeter* s_pReplayGainBoost;
    static ControlPotmeter* s_pDefaultBoost;
    static ControlObject* s_pEnableReplayGain;
    bool m_bSmoothFade;
    PerformanceTimer m_timer;
};