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

Method processAudioBuffer

src/tracks/InstrumentTrack.cpp:161–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159
160
161void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n )
162{
163 // we must not play the sound if this InstrumentTrack is muted...
164 if( isMuted() || ( Engine::getSong()->playMode() != Song::Mode_PlayPattern &&
165 n && n->isBbTrackMuted() ) || ! m_instrument )
166 {
167 return;
168 }
169
170 // Test for silent input data if instrument provides a single stream only (i.e. driven by InstrumentPlayHandle)
171 // We could do that in all other cases as well but the overhead for silence test is bigger than
172 // what we potentially save. While playing a note, a NotePlayHandle-driven instrument will produce sound in
173 // 99 of 100 cases so that test would be a waste of time.
174 if( m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) &&
175 MixHelpers::isSilent( buf, frames ) )
176 {
177 // at least pass one silent buffer to allow
178 if( m_silentBuffersProcessed )
179 {
180 // skip further processing
181 return;
182 }
183 m_silentBuffersProcessed = true;
184 }
185 else
186 {
187 m_silentBuffersProcessed = false;
188 }
189
190 // if effects "went to sleep" because there was no input, wake them up
191 // now
192 m_audioPort.effects()->startRunning();
193
194 // get volume knob data
195 static const float DefaultVolumeRatio = 1.0f / DefaultVolume;
196 /*ValueBuffer * volBuf = m_volumeModel.valueBuffer();
197 float v_scale = volBuf
198 ? 1.0f
199 : getVolume() * DefaultVolumeRatio;*/
200
201 // instruments using instrument-play-handles will call this method
202 // without any knowledge about notes, so they pass NULL for n, which
203 // is no problem for us since we just bypass the envelopes+LFOs
204 if( m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) == false && n != NULL )
205 {
206 const f_cnt_t offset = n->noteOffset();
207 m_soundShaping.processAudioBuffer( buf + offset, frames - offset, n );
208 const float vol = ( (float) n->getVolume() * DefaultVolumeRatio );
209 const panning_t pan = qBound( PanningLeft, n->getPanning(), PanningRight );
210 stereoVolumeVector vv = panningToVolumeVector( pan, vol );
211 for( f_cnt_t f = offset; f < frames; ++f )
212 {
213 for( int c = 0; c < 2; ++c )
214 {
215 buf[f][c] *= vv.vol[c];
216 }
217 }
218 }

Callers

nothing calls this directly

Calls 7

isMutedFunction · 0.85
getSongFunction · 0.85
isSilentFunction · 0.85
panningToVolumeVectorFunction · 0.85
startRunningMethod · 0.80
effectsMethod · 0.80
flagsMethod · 0.45

Tested by

no test coverage detected