mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-27 07:48:18 -05:00
Add peak indicators to the mixer strips. They show the maximum peak value that was observed and can be reset by clicking on them. ## Implementation details The implementation works via a signal/slot mechanism. The `Fader` class has a new signal `peakChanged` which reports peak values as amplifications. A new class `PeakIndicator` is added which has a slot `updatePeak` which is connected to the new signal in `Fader`. The `PeakIndicator` inherits from `QLabel` and mainly deals with updating the label text from the current peak value. Add a `PeakIndicator` instance to `MixerChannelView`. Add a `reset` method to `MixerChannelView` so that the mixer channel can be reset on the loading of new projects, etc. The current implementation resets the peak indicator back to -inf dbFS. The `reset` method is called in `MixerView::clear`. Remove the clamping in `Fader::setPeak` so that all peaks are reported. Emit the new signal if the peak changes.
144 lines
4.5 KiB
C++
144 lines
4.5 KiB
C++
/*
|
|
* MixerChannelView.h - the mixer channel view
|
|
*
|
|
* Copyright (c) 2022 saker <sakertooth@gmail.com>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program (see COPYING); if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef MIXER_CHANNEL_VIEW_H
|
|
#define MIXER_CHANNEL_VIEW_H
|
|
|
|
#include "EffectRackView.h"
|
|
#include "Fader.h"
|
|
#include "Knob.h"
|
|
#include "LcdWidget.h"
|
|
#include "PixmapButton.h"
|
|
#include "SendButtonIndicator.h"
|
|
|
|
#include <QGraphicsView>
|
|
#include <QLabel>
|
|
#include <QLineEdit>
|
|
#include <QPixmap>
|
|
#include <QWidget>
|
|
|
|
namespace lmms
|
|
{
|
|
class MixerChannel;
|
|
}
|
|
|
|
namespace lmms::gui
|
|
{
|
|
class PeakIndicator;
|
|
|
|
constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3;
|
|
constexpr int MIXER_CHANNEL_OUTER_BORDER_SIZE = 1;
|
|
|
|
class MixerChannelView : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QBrush backgroundActive READ backgroundActive WRITE setBackgroundActive)
|
|
Q_PROPERTY(QColor strokeOuterActive READ strokeOuterActive WRITE setStrokeOuterActive)
|
|
Q_PROPERTY(QColor strokeOuterInactive READ strokeOuterInactive WRITE setStrokeOuterInactive)
|
|
Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive)
|
|
Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive)
|
|
public:
|
|
enum class SendReceiveState
|
|
{
|
|
None, SendToThis, ReceiveFromThis
|
|
};
|
|
|
|
MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex);
|
|
void paintEvent(QPaintEvent* event) override;
|
|
void contextMenuEvent(QContextMenuEvent*) override;
|
|
void mousePressEvent(QMouseEvent*) override;
|
|
void mouseDoubleClickEvent(QMouseEvent*) override;
|
|
bool eventFilter(QObject* dist, QEvent* event) override;
|
|
|
|
int channelIndex() const;
|
|
void setChannelIndex(int index);
|
|
|
|
SendReceiveState sendReceiveState() const;
|
|
void setSendReceiveState(const SendReceiveState& state);
|
|
|
|
QBrush backgroundActive() const;
|
|
void setBackgroundActive(const QBrush& c);
|
|
|
|
QColor strokeOuterActive() const;
|
|
void setStrokeOuterActive(const QColor& c);
|
|
|
|
QColor strokeOuterInactive() const;
|
|
void setStrokeOuterInactive(const QColor& c);
|
|
|
|
QColor strokeInnerActive() const;
|
|
void setStrokeInnerActive(const QColor& c);
|
|
|
|
QColor strokeInnerInactive() const;
|
|
void setStrokeInnerInactive(const QColor& c);
|
|
|
|
void reset();
|
|
|
|
public slots:
|
|
void renameChannel();
|
|
void resetColor();
|
|
void selectColor();
|
|
void randomizeColor();
|
|
|
|
private slots:
|
|
void renameFinished();
|
|
void removeChannel();
|
|
void removeUnusedChannels();
|
|
void moveChannelLeft();
|
|
void moveChannelRight();
|
|
|
|
private:
|
|
bool confirmRemoval(int index);
|
|
QString elideName(const QString& name);
|
|
MixerChannel* mixerChannel() const;
|
|
auto isMasterChannel() const -> bool { return m_channelIndex == 0; }
|
|
|
|
private:
|
|
SendButtonIndicator* m_sendButton;
|
|
Knob* m_sendKnob;
|
|
LcdWidget* m_channelNumberLcd;
|
|
QLineEdit* m_renameLineEdit;
|
|
QGraphicsView* m_renameLineEditView;
|
|
QLabel* m_sendArrow;
|
|
QLabel* m_receiveArrow;
|
|
PixmapButton* m_muteButton;
|
|
PixmapButton* m_soloButton;
|
|
PeakIndicator* m_peakIndicator = nullptr;
|
|
Fader* m_fader;
|
|
EffectRackView* m_effectRackView;
|
|
MixerView* m_mixerView;
|
|
SendReceiveState m_sendReceiveState = SendReceiveState::None;
|
|
int m_channelIndex = 0;
|
|
bool m_inRename = false;
|
|
|
|
QBrush m_backgroundActive;
|
|
QColor m_strokeOuterActive;
|
|
QColor m_strokeOuterInactive;
|
|
QColor m_strokeInnerActive;
|
|
QColor m_strokeInnerInactive;
|
|
|
|
friend class MixerView;
|
|
};
|
|
} // namespace lmms::gui
|
|
|
|
#endif |