comparison plugin/plugins/SamplePlayer.cpp @ 843:e802e550a1f2

Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author Chris Cannam
date Tue, 26 Nov 2013 13:35:08 +0000
parents 1424aa29ae95
children a299c4cec0f8
comparison
equal deleted inserted replaced
842:23d3a6eca5c3 843:e802e550a1f2
374 QFileInfo file(dir.filePath(dir[i])); 374 QFileInfo file(dir.filePath(dir[i]));
375 if (file.isReadable()) { 375 if (file.isReadable()) {
376 m_samples.push_back(std::pair<QString, QString> 376 m_samples.push_back(std::pair<QString, QString>
377 (file.baseName(), file.filePath())); 377 (file.baseName(), file.filePath()));
378 #ifdef DEBUG_SAMPLE_PLAYER 378 #ifdef DEBUG_SAMPLE_PLAYER
379 std::cerr << "Found: " << dir[i].toLocal8Bit().data() << std::endl; 379 cerr << "Found: " << dir[i].toLocal8Bit().data() << endl;
380 #endif 380 #endif
381 } 381 }
382 } 382 }
383 383
384 m_sampleSearchComplete = true; 384 m_sampleSearchComplete = true;
394 size_t i; 394 size_t i;
395 395
396 info.format = 0; 396 info.format = 0;
397 file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info); 397 file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info);
398 if (!file) { 398 if (!file) {
399 std::cerr << "SamplePlayer::loadSampleData: Failed to open file " 399 cerr << "SamplePlayer::loadSampleData: Failed to open file "
400 << path.toLocal8Bit().data() << ": " 400 << path.toLocal8Bit().data() << ": "
401 << sf_strerror(file) << std::endl; 401 << sf_strerror(file) << endl;
402 return; 402 return;
403 } 403 }
404 404
405 samples = info.frames; 405 samples = info.frames;
406 tmpFrames = (float *)malloc(info.frames * info.channels * sizeof(float)); 406 tmpFrames = (float *)malloc(info.frames * info.channels * sizeof(float));
502 while (event_pos < eventCount 502 while (event_pos < eventCount
503 && pos >= events[event_pos].time.tick) { 503 && pos >= events[event_pos].time.tick) {
504 504
505 if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) { 505 if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) {
506 #ifdef DEBUG_SAMPLE_PLAYER 506 #ifdef DEBUG_SAMPLE_PLAYER
507 std::cerr << "SamplePlayer: found NOTEON at time " 507 cerr << "SamplePlayer: found NOTEON at time "
508 << events[event_pos].time.tick << std::endl; 508 << events[event_pos].time.tick << endl;
509 #endif 509 #endif
510 snd_seq_ev_note_t n = events[event_pos].data.note; 510 snd_seq_ev_note_t n = events[event_pos].data.note;
511 if (n.velocity > 0) { 511 if (n.velocity > 0) {
512 m_ons[n.note] = 512 m_ons[n.note] =
513 m_sampleNo + events[event_pos].time.tick; 513 m_sampleNo + events[event_pos].time.tick;
520 } 520 }
521 } 521 }
522 } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF && 522 } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF &&
523 (!m_sustain || (*m_sustain < 0.001))) { 523 (!m_sustain || (*m_sustain < 0.001))) {
524 #ifdef DEBUG_SAMPLE_PLAYER 524 #ifdef DEBUG_SAMPLE_PLAYER
525 std::cerr << "SamplePlayer: found NOTEOFF at time " 525 cerr << "SamplePlayer: found NOTEOFF at time "
526 << events[event_pos].time.tick << std::endl; 526 << events[event_pos].time.tick << endl;
527 #endif 527 #endif
528 snd_seq_ev_note_t n = events[event_pos].data.note; 528 snd_seq_ev_note_t n = events[event_pos].data.note;
529 m_offs[n.note] = 529 m_offs[n.note] =
530 m_sampleNo + events[event_pos].time.tick; 530 m_sampleNo + events[event_pos].time.tick;
531 } 531 }
547 addSample(i, pos, count); 547 addSample(i, pos, count);
548 } 548 }
549 } 549 }
550 550
551 #ifdef DEBUG_SAMPLE_PLAYER 551 #ifdef DEBUG_SAMPLE_PLAYER
552 std::cerr << "SamplePlayer: have " << notecount << " note(s) sounding currently" << std::endl; 552 cerr << "SamplePlayer: have " << notecount << " note(s) sounding currently" << endl;
553 #endif 553 #endif
554 554
555 pos += count; 555 pos += count;
556 } 556 }
557 557
587 float rs = s * ratio; 587 float rs = s * ratio;
588 unsigned long rsi = lrintf(floor(rs)); 588 unsigned long rsi = lrintf(floor(rs));
589 589
590 if (rsi >= m_sampleCount) { 590 if (rsi >= m_sampleCount) {
591 #ifdef DEBUG_SAMPLE_PLAYER 591 #ifdef DEBUG_SAMPLE_PLAYER
592 std::cerr << "Note " << n << " has run out of samples (were " << m_sampleCount << " available at ratio " << ratio << "), ending" << std::endl; 592 cerr << "Note " << n << " has run out of samples (were " << m_sampleCount << " available at ratio " << ratio << "), ending" << endl;
593 #endif 593 #endif
594 m_ons[n] = -1; 594 m_ons[n] = -1;
595 break; 595 break;
596 } 596 }
597 597
606 releaseFrames = long(*m_release * m_sampleRate + 0.0001); 606 releaseFrames = long(*m_release * m_sampleRate + 0.0001);
607 } 607 }
608 608
609 if (dist > releaseFrames) { 609 if (dist > releaseFrames) {
610 #ifdef DEBUG_SAMPLE_PLAYER 610 #ifdef DEBUG_SAMPLE_PLAYER
611 std::cerr << "Note " << n << " has expired its release time (" << releaseFrames << " frames), ending" << std::endl; 611 cerr << "Note " << n << " has expired its release time (" << releaseFrames << " frames), ending" << endl;
612 #endif 612 #endif
613 m_ons[n] = -1; 613 m_ons[n] = -1;
614 break; 614 break;
615 } else { 615 } else {
616 lgain = lgain * (float)(releaseFrames - dist) / 616 lgain = lgain * (float)(releaseFrames - dist) /