Mercurial > hg > svgui
comparison layer/SpectrumLayer.cpp @ 592:a13aa5320221 sonification
Extends the audio feedback of the piano scale to the Spectrum layer (horizontal piano keyboard).
Increase of the piano keyboard width (SpectrogramLayer) and height (SpectrumLayer) for layout purposes. A get method should be added to obtain the scale size parameter outside the layer class.
author | mathieub <mathieu.barthet@eecs.qmul.ac.uk> |
---|---|
date | Wed, 06 Jul 2011 18:05:42 +0100 |
parents | 4806715f7a19 |
children | c080d14ff414 |
comparison
equal
deleted
inserted
replaced
591:0946feb81b79 | 592:a13aa5320221 |
---|---|
23 #include "base/Pitch.h" | 23 #include "base/Pitch.h" |
24 #include "ColourMapper.h" | 24 #include "ColourMapper.h" |
25 | 25 |
26 #include <QPainter> | 26 #include <QPainter> |
27 #include <QTextStream> | 27 #include <QTextStream> |
28 | 28 #include <QMouseEvent> |
29 | 29 |
30 SpectrumLayer::SpectrumLayer() : | 30 SpectrumLayer::SpectrumLayer() : |
31 m_originModel(0), | 31 m_originModel(0), |
32 m_channel(-1), | 32 m_channel(-1), |
33 m_channelSet(false), | 33 m_channelSet(false), |
671 int xorigin = getVerticalScaleWidth(v, paint) + 1; | 671 int xorigin = getVerticalScaleWidth(v, paint) + 1; |
672 int w = v->width() - xorigin - 1; | 672 int w = v->width() - xorigin - 1; |
673 | 673 |
674 int pkh = 0; | 674 int pkh = 0; |
675 //!!! if (m_binScale == LogBins) { | 675 //!!! if (m_binScale == LogBins) { |
676 pkh = 10; | 676 //pkh = 10; //too small |
677 pkh = 20; | |
678 | |
677 //!!! } | 679 //!!! } |
678 | 680 |
679 paint.save(); | 681 paint.save(); |
680 | 682 |
681 if (fft && m_showPeaks) { | 683 if (fft && m_showPeaks) { |
821 // } | 823 // } |
822 | 824 |
823 paint.restore(); | 825 paint.restore(); |
824 } | 826 } |
825 | 827 |
828 /* | |
829 int | |
830 SpectrumLayer::getHorizontalScaleHeight(View *v, QPainter &paint) const | |
831 { | |
832 int h = v->height(); | |
833 int pkh = 10; | |
834 | |
835 return h - pkh - 1; | |
836 }*/ | |
837 | |
838 | |
826 void | 839 void |
827 SpectrumLayer::getBiasCurve(BiasCurve &curve) const | 840 SpectrumLayer::getBiasCurve(BiasCurve &curve) const |
828 { | 841 { |
829 curve = m_biasCurve; | 842 curve = m_biasCurve; |
830 } | 843 } |
858 | 871 |
859 bool showPeaks = (attributes.value("showPeaks").trimmed() == "true"); | 872 bool showPeaks = (attributes.value("showPeaks").trimmed() == "true"); |
860 setShowPeaks(showPeaks); | 873 setShowPeaks(showPeaks); |
861 } | 874 } |
862 | 875 |
863 | 876 bool |
877 SpectrumLayer::scaleClicked(const View *v, QMouseEvent *e) | |
878 { | |
879 std::cerr<< "Mouse click detected in the spectrum scale area: (" << e->x() << "," << e->y() << ")" << std::endl; | |
880 | |
881 float freq; | |
882 QString unit; | |
883 float *centsOffsetReturn = 0; | |
884 float concertA = 0.0; | |
885 int midipitch; | |
886 | |
887 if (getXScaleValue(v, e->x(), freq, unit)) { | |
888 | |
889 midipitch = Pitch::getPitchForFrequency(freq,centsOffsetReturn,concertA); | |
890 | |
891 std::cerr<< "Frequency: " << freq << " " << unit.toStdString() << " (midi pitch = " << midipitch << ")" << std::endl; | |
892 | |
893 if ((midipitch>=0)&&(midipitch<127)) { | |
894 v->playExampleNote(midipitch); | |
895 } | |
896 | |
897 return true; | |
898 | |
899 } else { | |
900 return false; | |
901 } | |
902 } |