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

Method processAudioBuffer

plugins/Bitcrush/Bitcrush.cpp:98–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
99{
100 if( !isEnabled() || !isRunning () )
101 {
102 return( false );
103 }
104
105 // update values
106 if( m_needsUpdate || m_controls.m_rateEnabled.isValueChanged() )
107 {
108 m_rateEnabled = m_controls.m_rateEnabled.value();
109 m_bitCounterL = 0.0f;
110 m_bitCounterR = 0.0f;
111 }
112 if( m_needsUpdate || m_controls.m_depthEnabled.isValueChanged() )
113 {
114 m_depthEnabled = m_controls.m_depthEnabled.value();
115 }
116 if( m_needsUpdate || m_controls.m_rate.isValueChanged() || m_controls.m_stereoDiff.isValueChanged() )
117 {
118 const float rate = m_controls.m_rate.value();
119 const float diff = m_controls.m_stereoDiff.value() * 0.005 * rate;
120
121 m_rateCoeffL = ( m_sampleRate * OS_RATE ) / ( rate - diff );
122 m_rateCoeffR = ( m_sampleRate * OS_RATE ) / ( rate + diff );
123
124 m_bitCounterL = 0.0f;
125 m_bitCounterR = 0.0f;
126 }
127 if( m_needsUpdate || m_controls.m_levels.isValueChanged() )
128 {
129 m_levels = m_controls.m_levels.value();
130 m_levelsRatio = 1.0f / (float) m_levels;
131 }
132 if( m_needsUpdate || m_controls.m_inGain.isValueChanged() )
133 {
134 m_inGain = dbfsToAmp( m_controls.m_inGain.value() );
135 }
136 if( m_needsUpdate || m_controls.m_outGain.isValueChanged() )
137 {
138 m_outGain = dbfsToAmp( m_controls.m_outGain.value() );
139 }
140 if( m_needsUpdate || m_controls.m_outClip.isValueChanged() )
141 {
142 m_outClip = dbfsToAmp( m_controls.m_outClip.value() );
143 }
144 m_needsUpdate = false;
145
146 const float noiseAmt = m_controls.m_inNoise.value() * 0.01f;
147
148 // read input buffer and write it to oversampled buffer
149 if( m_rateEnabled ) // rate crushing enabled so do that
150 {
151 for( int f = 0; f < frames; ++f )
152 {
153 for( int o = 0; o < OS_RATE; ++o )
154 {
155 m_buffer[f * OS_RATE + o][0] = m_left;

Callers

nothing calls this directly

Calls 8

isEnabledFunction · 0.85
dbfsToAmpFunction · 0.85
noiseFunction · 0.85
dryLevelFunction · 0.85
wetLevelFunction · 0.85
isRunningFunction · 0.50
valueMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected