comparison layer/SpectrogramLayer.cpp @ 589:7ebd5a21d74f sonification

Branch to handle audio feedback and metadata sonification interactively with the UI. Piano keyboard audio feedback: The midi pitch of a piano keyboard note is retrieved in SpectrogramLayer::processMouseEvent when a left click is made on the note in the Select tool mode (SpectrogramLayer with a log frequency scale). The same process should be applied to the Spectrum layer (log frequency scale) as well.
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Wed, 22 Jun 2011 00:04:21 +0100
parents 4806715f7a19
children 241929c5d57c
comparison
equal deleted inserted replaced
587:4806715f7a19 589:7ebd5a21d74f
3779 bool normalizeVisibleArea = 3779 bool normalizeVisibleArea =
3780 (attributes.value("normalizeVisibleArea").trimmed() == "true"); 3780 (attributes.value("normalizeVisibleArea").trimmed() == "true");
3781 setNormalizeVisibleArea(normalizeVisibleArea); 3781 setNormalizeVisibleArea(normalizeVisibleArea);
3782 } 3782 }
3783 3783
3784 void
3785 SpectrogramLayer::processMouseEvent(const View *v, QMouseEvent *e, int w)
3786 {
3787
3788 std::cerr<< "Mouse click detected in the layer: (" << e->x() << "," << e->y() << ")" << std::endl;
3789
3790 //is there a way to declare pkw and w may as class private variables?
3791
3792 int pkw = (m_frequencyScale == LogFrequencyScale ? 10 : 0);
3793
3794 int pianoKeyboardXLeft = w - pkw - 1;
3795 int pianoKeyboardXRight = w;
3796
3797 float freq;
3798 QString unit;
3799 float *centsOffsetReturn = 0;
3800 float concertA = 0.0;
3801 int midipitch;
3802
3803 if ((e->x() >= pianoKeyboardXLeft)&&(e->x() <= pianoKeyboardXRight))
3804 {
3805 std::cerr << "Piano keyboard left border: " << pianoKeyboardXLeft<<std::endl;
3806 std::cerr << "Piano keyboard right border: " << pianoKeyboardXRight<<std::endl;
3807 std::cerr<< "Mouse click detected within the piano keyboard: (" << e->x() << "," << e->y() << ")" << std::endl;
3808
3809 if (getYScaleValue(v, e->y(),freq, unit)) {
3810
3811 midipitch = Pitch::getPitchForFrequency(freq,centsOffsetReturn,concertA);
3812
3813 std::cerr<< "Frequency: " << freq << " " << unit.toStdString() << " (midi pitch = " << midipitch << ")" << std::endl;
3814 }
3815 }
3816 }