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

Method processInEvent

src/tracks/InstrumentTrack.cpp:243–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241
242
243void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
244{
245 if( Engine::getSong()->isExporting() )
246 {
247 return;
248 }
249
250 bool eventHandled = false;
251
252 switch( event.type() )
253 {
254 // we don't send MidiNoteOn, MidiNoteOff and MidiKeyPressure
255 // events to instrument as NotePlayHandle will send them on its
256 // own
257 case MidiNoteOn:
258 if( event.velocity() > 0 )
259 {
260 if( m_notes[event.key()] == NULL )
261 {
262 NotePlayHandle* nph =
263 NotePlayHandleManager::acquire(
264 this, offset,
265 typeInfo<f_cnt_t>::max() / 2,
266 Note( MidiTime(), MidiTime(), event.key(), event.volume( midiPort()->baseVelocity() ) ),
267 NULL, event.channel(),
268 NotePlayHandle::OriginMidiInput );
269 m_notes[event.key()] = nph;
270 if( ! Engine::mixer()->addPlayHandle( nph ) )
271 {
272 m_notes[event.key()] = NULL;
273 }
274 }
275 eventHandled = true;
276 break;
277 }
278
279 case MidiNoteOff:
280 if( m_notes[event.key()] != NULL )
281 {
282 // do actual note off and remove internal reference to NotePlayHandle (which itself will
283 // be deleted later automatically)
284 Engine::mixer()->requestChangeInModel();
285 m_notes[event.key()]->noteOff( offset );
286 if (isSustainPedalPressed() &&
287 m_notes[event.key()]->origin() ==
288 m_notes[event.key()]->OriginMidiInput)
289 {
290 m_sustainedNotes << m_notes[event.key()];
291 }
292 m_notes[event.key()] = NULL;
293 Engine::mixer()->doneChangeInModel();
294 }
295 eventHandled = true;
296 break;
297
298 case MidiKeyPressure:
299 if( m_notes[event.key()] != NULL )
300 {

Callers 2

Calls 15

getSongFunction · 0.85
MidiTimeClass · 0.85
midiPortFunction · 0.85
mixerFunction · 0.85
isSustainPedalPressedFunction · 0.85
framesPerTickFunction · 0.85
instrumentFunction · 0.85
velocityMethod · 0.80
keyMethod · 0.80
requestChangeInModelMethod · 0.80
doneChangeInModelMethod · 0.80
pitchBendMethod · 0.80

Tested by

no test coverage detected