comparison layer/SpectrogramLayer.cpp @ 594:5fa210337bee integration_library

Merge from branch "sonification"
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 18:56:28 +0100
parents a13aa5320221
children c080d14ff414
comparison
equal deleted inserted replaced
593:aaa3be825207 594:5fa210337bee
3272 m_model->getSampleRate() / 2)); 3272 m_model->getSampleRate() / 2));
3273 3273
3274 int fw = paint.fontMetrics().width(tr("43Hz")); 3274 int fw = paint.fontMetrics().width(tr("43Hz"));
3275 if (tw < fw) tw = fw; 3275 if (tw < fw) tw = fw;
3276 3276
3277 int tickw = (m_frequencyScale == LogFrequencyScale ? 10 : 4); 3277 //int tickw = (m_frequencyScale == LogFrequencyScale ? 10 : 4);
3278 int tickw = (m_frequencyScale == LogFrequencyScale ? 20 : 4);
3278 3279
3279 return cw + tickw + tw + 13; 3280 return cw + tickw + tw + 13;
3280 } 3281 }
3281 3282
3282 void 3283 void
3290 3291
3291 //!!! cache this? 3292 //!!! cache this?
3292 3293
3293 int h = rect.height(), w = rect.width(); 3294 int h = rect.height(), w = rect.width();
3294 3295
3295 int tickw = (m_frequencyScale == LogFrequencyScale ? 10 : 4); 3296 //int tickw = (m_frequencyScale == LogFrequencyScale ? 10 : 4);
3296 int pkw = (m_frequencyScale == LogFrequencyScale ? 10 : 0); 3297 //int pkw = (m_frequencyScale == LogFrequencyScale ? 10 : 0);
3298
3299 int tickw = (m_frequencyScale == LogFrequencyScale ? 20 : 4);
3300 int pkw = (m_frequencyScale == LogFrequencyScale ? 20 : 0);
3297 3301
3298 size_t bins = m_fftSize / 2; 3302 size_t bins = m_fftSize / 2;
3299 int sr = m_model->getSampleRate(); 3303 int sr = m_model->getSampleRate();
3300 3304
3301 if (m_maxFrequency > 0) { 3305 if (m_maxFrequency > 0) {
3779 bool normalizeVisibleArea = 3783 bool normalizeVisibleArea =
3780 (attributes.value("normalizeVisibleArea").trimmed() == "true"); 3784 (attributes.value("normalizeVisibleArea").trimmed() == "true");
3781 setNormalizeVisibleArea(normalizeVisibleArea); 3785 setNormalizeVisibleArea(normalizeVisibleArea);
3782 } 3786 }
3783 3787
3788 bool
3789 SpectrogramLayer::scaleClicked(const View *v, QMouseEvent *e)
3790 {
3791 std::cerr<< "Mouse click detected in the spectrogram scale area: (" << e->x() << "," << e->y() << ")" << std::endl;
3792
3793 float freq;
3794 QString unit;
3795 float *centsOffsetReturn = 0;
3796 float concertA = 0.0;
3797 int midipitch;
3798
3799 if (getYScaleValue(v, e->y(), freq, unit)) {
3800
3801 midipitch = Pitch::getPitchForFrequency(freq,centsOffsetReturn,concertA);
3802
3803 std::cerr<< "Frequency: " << freq << " " << unit.toStdString() << " (midi pitch = " << midipitch << ")" << std::endl;
3804
3805 if ((midipitch>=0)&&(midipitch<127)) {
3806 v->playExampleNote(midipitch);
3807 }
3808
3809 return true;
3810
3811 } else {
3812 return false;
3813 }
3814 }
3815