comparison layer/SpectrogramLayer.cpp @ 279:47fe0352861e

* add pitch label to spectrogram harmonic cursor as well
author Chris Cannam
date Tue, 03 Jul 2007 18:56:27 +0000
parents a078aa2932cc
children 3c402c6052f6
comparison
equal deleted inserted replaced
278:a078aa2932cc 279:47fe0352861e
2465 extents.push_back(horizontal); 2465 extents.push_back(horizontal);
2466 2466
2467 int sw = getVerticalScaleWidth(v, paint); 2467 int sw = getVerticalScaleWidth(v, paint);
2468 2468
2469 QRect label(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2, 2469 QRect label(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
2470 paint.fontMetrics().width("123456 Hz") + sw + 2, 2470 paint.fontMetrics().width("123456 Hz") + 2,
2471 paint.fontMetrics().height()); 2471 paint.fontMetrics().height());
2472 extents.push_back(label); 2472 extents.push_back(label);
2473
2474 QRect pitch(sw, cursorPos.y() + 2,
2475 paint.fontMetrics().width("C#10+50c") + 2,
2476 paint.fontMetrics().height());
2477 extents.push_back(pitch);
2473 2478
2474 return true; 2479 return true;
2475 } 2480 }
2476 2481
2477 void 2482 void
2491 sw + 2, 2496 sw + 2,
2492 cursorPos.y() - 2, 2497 cursorPos.y() - 2,
2493 QString("%1 Hz").arg(fundamental), 2498 QString("%1 Hz").arg(fundamental),
2494 View::OutlinedText); 2499 View::OutlinedText);
2495 2500
2496 //!!! and pitch label 2501 if (Pitch::isFrequencyInMidiRange(fundamental)) {
2502 QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental);
2503 v->drawVisibleText(paint,
2504 sw + 2,
2505 cursorPos.y() + paint.fontMetrics().ascent() + 2,
2506 pitchLabel,
2507 View::OutlinedText);
2508 }
2509
2510 /*!!!
2511 long frame = getFrameForX(cursorPos.x());
2512 RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate());
2513 QString timeLabel = rt.toText(true).c_str();
2514 ...
2515 */
2497 2516
2498 int harmonic = 2; 2517 int harmonic = 2;
2499 2518
2500 while (harmonic < 100) { 2519 while (harmonic < 100) {
2501 2520