| 391 | |
| 392 | |
| 393 | void 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 |
nothing calls this directly
no test coverage detected