MCPcopy Create free account
hub / github.com/LMMS/lmms / processAudioBuffer

Method processAudioBuffer

plugins/Amplifier/Amplifier.cpp:67–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
68{
69 if( !isEnabled() || !isRunning () )
70 {
71 return( false );
72 }
73
74 double outSum = 0.0;
75 const float d = dryLevel();
76 const float w = wetLevel();
77
78 const ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer();
79 const ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer();
80 const ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer();
81 const ValueBuffer * rightBuf = m_ampControls.m_rightModel.valueBuffer();
82
83 for( fpp_t f = 0; f < frames; ++f )
84 {
85// qDebug( "offset %d, value %f", f, m_ampControls.m_volumeModel.value( f ) );
86
87 sample_t s[2] = { buf[f][0], buf[f][1] };
88
89 // vol knob
90 if( volBuf )
91 {
92 s[0] *= volBuf->value( f ) * 0.01f;
93 s[1] *= volBuf->value( f ) * 0.01f;
94 }
95 else
96 {
97 s[0] *= m_ampControls.m_volumeModel.value() * 0.01f;
98 s[1] *= m_ampControls.m_volumeModel.value() * 0.01f;
99 }
100
101 // convert pan values to left/right values
102 const float pan = panBuf
103 ? panBuf->value( f )
104 : m_ampControls.m_panModel.value();
105 const float left1 = pan <= 0
106 ? 1.0
107 : 1.0 - pan * 0.01f;
108 const float right1 = pan >= 0
109 ? 1.0
110 : 1.0 + pan * 0.01f;
111
112 // second stage amplification
113 const float left2 = leftBuf
114 ? leftBuf->value( f )
115 : m_ampControls.m_leftModel.value();
116 const float right2 = rightBuf
117 ? rightBuf->value( f )
118 : m_ampControls.m_rightModel.value();
119
120 s[0] *= left1 * left2 * 0.01;
121 s[1] *= right1 * right2 * 0.01;
122
123 buf[f][0] = d * buf[f][0] + w * s[0];
124 buf[f][1] = d * buf[f][1] + w * s[1];

Callers

nothing calls this directly

Calls 6

isEnabledFunction · 0.85
dryLevelFunction · 0.85
wetLevelFunction · 0.85
isRunningFunction · 0.50
valueBufferMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected