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

Method processNote

src/core/InstrumentFunctions.cpp:229–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n )
230{
231 const int base_note_key = _n->key();
232 const ChordTable & chord_table = ChordTable::getInstance();
233 // we add chord-subnotes to note if either note is a base-note and
234 // arpeggio is not used or note is part of an arpeggio
235 // at the same time we only add sub-notes if nothing of the note was
236 // played yet, because otherwise we would add chord-subnotes every
237 // time an audio-buffer is rendered...
238 if( ( _n->origin() == NotePlayHandle::OriginArpeggio || ( _n->hasParent() == false && _n->instrumentTrack()->isArpeggioEnabled() == false ) ) &&
239 _n->totalFramesPlayed() == 0 &&
240 m_chordsEnabledModel.value() == true && ! _n->isReleased() )
241 {
242 // then insert sub-notes for chord
243 const int selected_chord = m_chordsModel.value();
244
245 for( int octave_cnt = 0; octave_cnt < m_chordRangeModel.value(); ++octave_cnt )
246 {
247 const int sub_note_key_base = base_note_key + octave_cnt * KeysPerOctave;
248
249 // process all notes in the chord
250 for( int i = 0; i < chord_table[selected_chord].size(); ++i )
251 {
252 // add interval to sub-note-key
253 const int sub_note_key = sub_note_key_base + (int) chord_table[selected_chord][i];
254 // maybe we're out of range -> let's get outta
255 // here!
256 if( sub_note_key > NumKeys )
257 {
258 break;
259 }
260 // create copy of base-note
261 Note note_copy( _n->length(), 0, sub_note_key, _n->getVolume(), _n->getPanning(), _n->detuning() );
262
263 // create sub-note-play-handle, only note is
264 // different
265 Engine::mixer()->addPlayHandle(
266 NotePlayHandleManager::acquire( _n->instrumentTrack(), _n->offset(), _n->frames(), note_copy,
267 _n, -1, NotePlayHandle::OriginNoteStacking )
268 );
269 }
270 }
271 }
272}
273
274
275

Callers 1

playNoteMethod · 0.45

Calls 14

mixerFunction · 0.85
MidiTimeClass · 0.85
keyMethod · 0.80
instrumentTrackMethod · 0.80
framesMethod · 0.80
processingSampleRateMethod · 0.80
firstMethod · 0.80
indexMethod · 0.80
criticalXRunsMethod · 0.80
valueMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected