annotate widgets/LevelPanWidget.h @ 1127:9fb8dfd7ce4c spectrogram-minor-refactor

Fix threshold in spectrogram -- it wasn't working in the last release. There is a new protocol for this. Formerly the threshold parameter had a range from -50dB to 0 with the default at -50, and -50 treated internally as "no threshold". However, there was a hardcoded, hidden internal threshold for spectrogram colour mapping at -80dB with anything below this being rounded to zero. Now the threshold parameter has range -81 to -1 with the default at -80, -81 is treated internally as "no threshold", and there is no hidden internal threshold. So the default behaviour is the same as before, an effective -80dB threshold, but it is now possible to change this in both directions. Sessions reloaded from prior versions may look slightly different because, if the session says there should be no threshold, there will now actually be no threshold instead of having the hidden internal one. Still need to do something in the UI to make it apparent that the -81dB setting removes the threshold entirely. This is at least no worse than the previous, also obscured, magic -50dB setting.
author Chris Cannam
date Mon, 01 Aug 2016 16:21:01 +0100
parents 77110abca8a1
children 916b62baf7ac
rev   line source
Chris@923 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@923 2
Chris@923 3 /*
Chris@923 4 Sonic Visualiser
Chris@923 5 An audio file viewer and annotation editor.
Chris@923 6 Centre for Digital Music, Queen Mary, University of London.
Chris@923 7
Chris@923 8 This program is free software; you can redistribute it and/or
Chris@923 9 modify it under the terms of the GNU General Public License as
Chris@923 10 published by the Free Software Foundation; either version 2 of the
Chris@923 11 License, or (at your option) any later version. See the file
Chris@923 12 COPYING included with this distribution for more information.
Chris@923 13 */
Chris@923 14
Chris@923 15 #ifndef LEVEL_PAN_WIDGET_H
Chris@923 16 #define LEVEL_PAN_WIDGET_H
Chris@923 17
Chris@923 18 #include <QWidget>
Chris@923 19
Chris@923 20 /**
Chris@923 21 * A simple widget for coarse level and pan control.
Chris@923 22 */
Chris@923 23
Chris@923 24 class LevelPanWidget : public QWidget
Chris@923 25 {
Chris@923 26 Q_OBJECT
Chris@923 27
Chris@923 28 public:
Chris@923 29 LevelPanWidget(QWidget *parent = 0);
Chris@923 30 ~LevelPanWidget();
Chris@923 31
Chris@923 32 /// Return level as a gain value in the range [0,1]
Chris@923 33 float getLevel() const;
Chris@923 34
Chris@923 35 /// Return pan as a value in the range [-1,1]
Chris@923 36 float getPan() const;
Chris@923 37
Chris@923 38 /// Find out whether the widget is editable
Chris@923 39 bool isEditable() const;
Chris@923 40
Chris@940 41 /// Discover whether the level range includes muting or not
Chris@940 42 bool includesMute() const;
Chris@940 43
Chris@929 44 /// Draw a suitably sized copy of the widget's contents to the given device
Chris@929 45 void renderTo(QPaintDevice *, QRectF, bool asIfEditable) const;
Chris@929 46
Chris@929 47 QSize sizeHint() const;
Chris@929 48
Chris@923 49 public slots:
Chris@923 50 /// Set level in the range [0,1] -- will be rounded
Chris@923 51 void setLevel(float);
Chris@923 52
Chris@923 53 /// Set pan in the range [-1,1] -- will be rounded
Chris@923 54 void setPan(float);
Chris@923 55
Chris@923 56 /// Specify whether the widget is editable or read-only (default editable)
Chris@923 57 void setEditable(bool);
Chris@940 58
Chris@940 59 /// Specify whether the level range should include muting or not
Chris@940 60 void setIncludeMute(bool);
Chris@923 61
Chris@923 62 signals:
Chris@923 63 void levelChanged(float);
Chris@923 64 void panChanged(float);
Chris@923 65
Chris@923 66 protected:
Chris@923 67 virtual void mousePressEvent(QMouseEvent *ev);
Chris@923 68 virtual void mouseMoveEvent(QMouseEvent *ev);
Chris@923 69 virtual void mouseReleaseEvent(QMouseEvent *ev);
Chris@923 70 virtual void wheelEvent(QWheelEvent *ev);
Chris@923 71 virtual void paintEvent(QPaintEvent *ev);
Chris@923 72
Chris@923 73 void emitLevelChanged();
Chris@923 74 void emitPanChanged();
Chris@923 75
Chris@923 76 int m_level;
Chris@923 77 int m_pan;
Chris@923 78 bool m_editable;
Chris@940 79 bool m_includeMute;
Chris@923 80
Chris@929 81 QSizeF cellSize(QRectF) const;
Chris@929 82 QPointF cellCentre(QRectF, int level, int pan) const;
Chris@929 83 QSizeF cellLightSize(QRectF) const;
Chris@929 84 QRectF cellLightRect(QRectF, int level, int pan) const;
Chris@929 85 double thinLineWidth(QRectF) const;
Chris@929 86 void toCell(QRectF, QPointF loc, int &level, int &pan) const;
Chris@923 87 };
Chris@923 88
Chris@923 89 #endif