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

Method playNote

plugins/audio_file_processor/audio_file_processor.cpp:120–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119
120void audioFileProcessor::playNote( NotePlayHandle * _n,
121 sampleFrame * _working_buffer )
122{
123 const fpp_t frames = _n->framesLeftForCurrentPeriod();
124 const f_cnt_t offset = _n->noteOffset();
125
126 // Magic key - a frequency < 20 (say, the bottom piano note if using
127 // a A4 base tuning) restarts the start point. The note is not actually
128 // played.
129 if( m_stutterModel.value() == true && _n->frequency() < 20.0 )
130 {
131 m_nextPlayStartPoint = m_sampleBuffer.startFrame();
132 m_nextPlayBackwards = false;
133 return;
134 }
135
136 if( !_n->m_pluginData )
137 {
138 if( m_stutterModel.value() == true && m_nextPlayStartPoint >= m_sampleBuffer.endFrame() )
139 {
140 // Restart playing the note if in stutter mode, not in loop mode,
141 // and we're at the end of the sample.
142 m_nextPlayStartPoint = m_sampleBuffer.startFrame();
143 m_nextPlayBackwards = false;
144 }
145 // set interpolation mode for libsamplerate
146 int srcmode = SRC_LINEAR;
147 switch( m_interpolationModel.value() )
148 {
149 case 0:
150 srcmode = SRC_ZERO_ORDER_HOLD;
151 break;
152 case 1:
153 srcmode = SRC_LINEAR;
154 break;
155 case 2:
156 srcmode = SRC_SINC_MEDIUM_QUALITY;
157 break;
158 }
159 _n->m_pluginData = new handleState( _n->hasDetuningInfo(), srcmode );
160 ((handleState *)_n->m_pluginData)->setFrameIndex( m_nextPlayStartPoint );
161 ((handleState *)_n->m_pluginData)->setBackwards( m_nextPlayBackwards );
162
163// debug code
164/* qDebug( "frames %d", m_sampleBuffer.frames() );
165 qDebug( "startframe %d", m_sampleBuffer.startFrame() );
166 qDebug( "nextPlayStartPoint %d", m_nextPlayStartPoint );*/
167 }
168
169 if( ! _n->isFinished() )
170 {
171 if( m_sampleBuffer.play( _working_buffer + offset,
172 (handleState *)_n->m_pluginData,
173 frames, _n->frequency(),
174 static_cast<SampleBuffer::LoopMode>( m_loopModel.value() ) ) )
175 {
176 applyRelease( _working_buffer, _n );
177 instrumentTrack()->processAudioBuffer( _working_buffer,

Callers

nothing calls this directly

Calls 8

frequencyMethod · 0.80
hasDetuningInfoMethod · 0.80
instrumentTrackFunction · 0.50
valueMethod · 0.45
isFinishedMethod · 0.45
playMethod · 0.45
processAudioBufferMethod · 0.45

Tested by

no test coverage detected