Mercurial > hg > svcore
changeset 141:4f26f623a8bc
* Finish preferences dialog (as far as it's going at the moment) and connect it up
* Fix Parzen window shape (was triangular!)
* Various fixes to spectrogram draw coordinates in smoothing mode etc
* Draw C keys in grey on the piano
author | Chris Cannam |
---|---|
date | Fri, 21 Jul 2006 16:03:42 +0000 |
parents | a35098a9c814 |
children | 0ba66b160a02 |
files | base/Pitch.cpp base/Pitch.h base/Preferences.cpp base/PropertyContainer.h base/View.cpp base/View.h base/Window.h |
diffstat | 7 files changed, 53 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/base/Pitch.cpp Thu Jul 20 16:51:20 2006 +0000 +++ b/base/Pitch.cpp Fri Jul 21 16:03:42 2006 +0000 @@ -14,6 +14,7 @@ */ #include "Pitch.h" +#include "Preferences.h" #include <cmath> @@ -22,6 +23,9 @@ float centsOffset, float concertA) { + if (concertA <= 0.0) { + concertA = Preferences::getInstance()->getTuningFrequency(); + } float p = float(midiPitch) + (centsOffset / 100); return concertA * powf(2.0, (p - 69.0) / 12.0); } @@ -31,6 +35,9 @@ float *centsOffsetReturn, float concertA) { + if (concertA <= 0.0) { + concertA = Preferences::getInstance()->getTuningFrequency(); + } float p = 12.0 * (log(frequency / (concertA / 2.0)) / log(2.0)) + 57.0; int midiPitch = int(p + 0.00001); @@ -86,6 +93,9 @@ float concertA, bool useFlats) { + if (concertA <= 0.0) { + concertA = Preferences::getInstance()->getTuningFrequency(); + } float centsOffset = 0.0; int midiPitch = getPitchForFrequency(frequency, ¢sOffset, concertA); return getPitchLabel(midiPitch, centsOffset, useFlats);
--- a/base/Pitch.h Thu Jul 20 16:51:20 2006 +0000 +++ b/base/Pitch.h Fri Jul 21 16:03:42 2006 +0000 @@ -21,20 +21,22 @@ class Pitch { public: + /* If concertA <= 0, it will be taken from current preferences */ + static float getFrequencyForPitch(int midiPitch, float centsOffset = 0, - float concertA = 440.0); + float concertA = 0.0); static int getPitchForFrequency(float frequency, float *centsOffsetReturn = 0, - float concertA = 440.0); + float concertA = 0.0); static QString getPitchLabel(int midiPitch, float centsOffset = 0, bool useFlats = false); static QString getPitchLabelForFrequency(float frequency, - float concertA = 440.0, + float concertA = 0.0, bool useFlats = false); };
--- a/base/Preferences.cpp Thu Jul 20 16:51:20 2006 +0000 +++ b/base/Preferences.cpp Fri Jul 21 16:03:42 2006 +0000 @@ -41,16 +41,16 @@ Preferences::getPropertyLabel(const PropertyName &name) const { if (name == "Smooth Spectrogram") { - return tr("Spectrogram Display Smoothing"); + return tr("Smooth spectrogram display by zero padding FFT"); } if (name == "Tuning Frequency") { - return tr("Tuning Frequency (concert A)"); + return tr("Frequency of concert A"); } if (name == "Property Box Layout") { - return tr("Arrangement of Layer Properties"); + return tr("Property box layout"); } if (name == "Window Type") { - return tr("Spectral Analysis Window Shape"); + return tr("Spectral analysis window shape"); } return name; } @@ -105,13 +105,13 @@ int value) const { if (name == "Property Box Layout") { - if (value == 0) return tr("Vertically Stacked"); - else return tr("Layered"); + if (value == 0) return tr("Show boxes for all panes"); + else return tr("Show box for current pane only"); } if (name == "Window Type") { switch (WindowType(value)) { case RectangularWindow: return tr("Rectangular"); - case BartlettWindow: return tr("Bartlett"); + case BartlettWindow: return tr("Triangular"); case HammingWindow: return tr("Hamming"); case HanningWindow: return tr("Hanning"); case BlackmanWindow: return tr("Blackman"); @@ -153,7 +153,7 @@ { if (m_smoothSpectrogram != smooth) { m_smoothSpectrogram = smooth; -//!!! emit + emit propertyChanged("Smooth Spectrogram"); } } @@ -162,7 +162,7 @@ { if (m_tuningFrequency != freq) { m_tuningFrequency = freq; - //!!! emit + emit propertyChanged("Tuning Frequency"); } } @@ -171,7 +171,7 @@ { if (m_propertyBoxLayout != layout) { m_propertyBoxLayout = layout; - //!!! emit + emit propertyChanged("Property Box Layout"); } } @@ -180,7 +180,7 @@ { if (m_windowType != type) { m_windowType = type; - //!!! emit + emit propertyChanged("Window Type"); } }
--- a/base/PropertyContainer.h Thu Jul 20 16:51:20 2006 +0000 +++ b/base/PropertyContainer.h Fri Jul 21 16:03:42 2006 +0000 @@ -90,7 +90,7 @@ virtual PlayParameters *getPlayParameters() { return 0; } signals: - void propertyChanged(PropertyName); + void propertyChanged(PropertyContainer::PropertyName); public slots: /**
--- a/base/View.cpp Thu Jul 20 16:51:20 2006 +0000 +++ b/base/View.cpp Fri Jul 21 16:03:42 2006 +0000 @@ -1514,8 +1514,8 @@ ViewPropertyContainer::ViewPropertyContainer(View *v) : m_v(v) { - connect(m_v, SIGNAL(propertyChanged(PropertyName)), - this, SIGNAL(propertyChanged(PropertyName))); + connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), + this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); } #ifdef INCLUDE_MOCFILES
--- a/base/View.h Thu Jul 20 16:51:20 2006 +0000 +++ b/base/View.h Fri Jul 21 16:03:42 2006 +0000 @@ -237,7 +237,7 @@ void propertyContainerRemoved(PropertyContainer *pc); void propertyContainerPropertyChanged(PropertyContainer *pc); void propertyContainerNameChanged(PropertyContainer *pc); - void propertyChanged(PropertyName); + void propertyChanged(PropertyContainer::PropertyName); void centreFrameChanged(void *, unsigned long, bool); void zoomLevelChanged(void *, unsigned long, bool);
--- a/base/Window.h Thu Jul 20 16:51:20 2006 +0000 +++ b/base/Window.h Fri Jul 21 16:03:42 2006 +0000 @@ -69,56 +69,67 @@ template <typename T> void Window<T>::encache() { - size_t n = m_size; + int n = int(m_size); T *mult = new T[n]; - size_t i; + int i; for (i = 0; i < n; ++i) mult[i] = 1.0; switch (m_type) { case RectangularWindow: for (i = 0; i < n; ++i) { - mult[i] = mult[i] * 0.5; + mult[i] *= 0.5; } break; case BartlettWindow: for (i = 0; i < n/2; ++i) { - mult[i] = mult[i] * (i / T(n/2)); - mult[i + n/2] = mult[i + n/2] * (1.0 - (i / T(n/2))); + mult[i] *= (i / T(n/2)); + mult[i + n/2] *= (1.0 - (i / T(n/2))); } break; case HammingWindow: for (i = 0; i < n; ++i) { - mult[i] = mult[i] * (0.54 - 0.46 * cos(2 * M_PI * i / n)); + mult[i] *= (0.54 - 0.46 * cos(2 * M_PI * i / n)); } break; case HanningWindow: for (i = 0; i < n; ++i) { - mult[i] = mult[i] * (0.50 - 0.50 * cos(2 * M_PI * i / n)); + mult[i] *= (0.50 - 0.50 * cos(2 * M_PI * i / n)); } break; case BlackmanWindow: for (i = 0; i < n; ++i) { - mult[i] = mult[i] * (0.42 - 0.50 * cos(2 * M_PI * i / n) + mult[i] *= (0.42 - 0.50 * cos(2 * M_PI * i / n) + 0.08 * cos(4 * M_PI * i / n)); } break; case GaussianWindow: for (i = 0; i < n; ++i) { - mult[i] = mult[i] * exp(-(pow(i - (n-1)/2.0, 2) / + mult[i] *= exp(-(pow(i - (n-1)/2.0, 2) / (2 * pow(0.25 * n, 2)))); // sd = 0.25 } break; case ParzenWindow: - for (i = 0; i < n; ++i) { - mult[i] = mult[i] * (1.0 - fabs((T(2*i) - n) / T(n + 1))); - } + { + int N = n-1; + for (i = 0; i < N/4; ++i) { + T m = 2 * pow(1.0 - (T(N)/2 - i) / (T(N)/2), 3); + mult[i] *= m; + mult[N-i] *= m; + } + for (i = N/4; i <= N/2; ++i) { + int wn = i - N/2; + T m = 1.0 - 6 * pow(wn / (T(N)/2), 2) * (1.0 - abs(wn) / (T(N)/2)); + mult[i] *= m; + mult[N-i] *= m; + } + } break; }