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

Method selectSample

plugins/patman/patman.cpp:393–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391
392
393void patmanInstrument::selectSample( NotePlayHandle * _n )
394{
395 const float freq = _n->frequency();
396
397 float min_dist = HUGE_VALF;
398 SampleBuffer* sample = NULL;
399
400 for( QVector<SampleBuffer *>::iterator it = m_patchSamples.begin(); it != m_patchSamples.end(); ++it )
401 {
402 float patch_freq = ( *it )->frequency();
403 float dist = freq >= patch_freq ? freq / patch_freq :
404 patch_freq / freq;
405
406 if( dist < min_dist )
407 {
408 min_dist = dist;
409 sample = *it;
410 }
411 }
412
413 handle_data * hdata = new handle_data;
414 hdata->tuned = m_tunedModel.value();
415 if( sample )
416 {
417 hdata->sample = sharedObject::ref( sample );
418 }
419 else
420 {
421 hdata->sample = new SampleBuffer( NULL, 0 );
422 }
423 hdata->state = new SampleBuffer::handleState( _n->hasDetuningInfo() );
424
425 _n->m_pluginData = hdata;
426}
427
428
429

Callers

nothing calls this directly

Calls 5

frequencyMethod · 0.80
hasDetuningInfoMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected