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

Method processAudioBuffer

plugins/stereo_enhancer/stereo_enhancer.cpp:81–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf,
82 const fpp_t _frames )
83{
84
85 // This appears to be used for determining whether or not to continue processing
86 // audio with this effect
87 double out_sum = 0.0;
88
89 float width;
90 int frameIndex = 0;
91
92
93 if( !isEnabled() || !isRunning() )
94 {
95 return( false );
96 }
97
98 const float d = dryLevel();
99 const float w = wetLevel();
100
101 for( fpp_t f = 0; f < _frames; ++f )
102 {
103
104 // copy samples into the delay buffer
105 m_delayBuffer[m_currFrame][0] = _buf[f][0];
106 m_delayBuffer[m_currFrame][1] = _buf[f][1];
107
108 // Get the width knob value from the Stereo Enhancer effect
109 width = m_seFX.wideCoeff();
110
111 // Calculate the correct sample frame for processing
112 frameIndex = m_currFrame - width;
113
114 if( frameIndex < 0 )
115 {
116 // e.g. difference = -10, frameIndex = DBS - 10
117 frameIndex += DEFAULT_BUFFER_SIZE;
118 }
119
120 //sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla
121 sample_t s[2] = { _buf[f][0], m_delayBuffer[frameIndex][1] }; //Chocolate
122
123 m_seFX.nextSample( s[0], s[1] );
124
125 _buf[f][0] = d * _buf[f][0] + w * s[0];
126 _buf[f][1] = d * _buf[f][1] + w * s[1];
127 out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1];
128
129 // Update currFrame
130 m_currFrame += 1;
131 m_currFrame %= DEFAULT_BUFFER_SIZE;
132 }
133
134 checkGate( out_sum / _frames );
135 if( !isRunning() )
136 {
137 clearMyBuffer();
138 }

Callers

nothing calls this directly

Calls 6

isEnabledFunction · 0.85
dryLevelFunction · 0.85
wetLevelFunction · 0.85
wideCoeffMethod · 0.80
isRunningFunction · 0.50
nextSampleMethod · 0.45

Tested by

no test coverage detected