jamulus/src/audiomixerboard.h

266 lines
9.6 KiB
C
Raw Normal View History

2013-01-23 11:41:13 +01:00
/******************************************************************************\
2020-01-01 15:41:43 +01:00
* Copyright (c) 2004-2020
2013-01-23 11:41:13 +01:00
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* 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
2013-01-23 11:41:13 +01:00
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
2013-01-23 11:41:13 +01:00
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2013-01-23 11:41:13 +01:00
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2013-01-23 11:41:13 +01:00
*
\******************************************************************************/
2019-07-09 08:52:38 +02:00
#pragma once
2013-01-23 11:41:13 +01:00
#include <QFrame>
#include <QScrollArea>
2013-01-23 11:41:13 +01:00
#include <QGroupBox>
#include <QLabel>
#include <QCheckBox>
#include <QLayout>
#include <QString>
#include <QSlider>
#include <QDial>
2013-01-23 11:41:13 +01:00
#include <QSizePolicy>
#include <QHostAddress>
#include <QListWidget>
2013-01-23 11:41:13 +01:00
#include "global.h"
#include "util.h"
2020-06-21 19:55:12 +02:00
#include "levelmeter.h"
2013-01-23 11:41:13 +01:00
/* Classes ********************************************************************/
class CChannelFader : public QObject
{
Q_OBJECT
public:
CChannelFader ( QWidget* pNW );
2013-01-23 11:41:13 +01:00
2020-06-13 08:31:28 +02:00
QString GetReceivedName() { return cReceivedChanInfo.strName; }
int GetReceivedInstrument() { return cReceivedChanInfo.iInstrument; }
void SetChannelInfos ( const CChannelInfo& cChanInfo );
2013-01-23 11:41:13 +01:00
void Show() { pFrame->show(); }
void Hide() { pFrame->hide(); }
bool IsVisible() { return !pFrame->isHidden(); }
bool IsSolo() { return pcbSolo->isChecked(); }
bool IsMute() { return pcbMute->isChecked(); }
2020-06-20 17:44:34 +02:00
bool IsSelect() { return pcbGroup->isChecked(); }
2013-01-23 11:41:13 +01:00
void SetGUIDesign ( const EGUIDesign eNewDesign );
2020-03-29 23:40:53 +02:00
void SetDisplayChannelLevel ( const bool eNDCL );
bool GetDisplayChannelLevel();
void SetDisplayPans ( const bool eNDP );
QFrame* GetMainWidget() { return pFrame; }
2013-01-23 11:41:13 +01:00
2020-04-26 00:55:28 +02:00
void SetPanValue ( const int iPan );
2014-01-19 11:51:31 +01:00
void SetFaderIsSolo ( const bool bIsSolo );
void SetFaderIsMute ( const bool bIsMute );
void SetRemoteFaderIsMute ( const bool bIsMute );
void SetFaderIsSelect ( const bool bIsMute );
void SetFaderLevel ( const double dLevel,
const bool bIsGroupUpdate = false );
int GetFaderLevel() { return pFader->value(); }
double GetPreviousFaderLevel() { return dPreviousFaderLevel; }
int GetPanValue() { return pPan->value(); }
void Reset();
void SetChannelLevel ( const uint16_t iLevel );
void SetIsMyOwnFader() { bIsMyOwnFader = true; }
void UpdateSoloState ( const bool bNewOtherSoloState );
2013-01-23 11:41:13 +01:00
protected:
double CalcFaderGain ( const double dValue );
void SetMute ( const bool bState );
void SetupFaderTag ( const ESkillLevel eSkillLevel );
void SendPanValueToServer ( const int iPan );
void SendFaderLevelToServer ( const double dLevel,
const bool bIsGroupUpdate );
2013-01-23 11:41:13 +01:00
2020-06-21 20:09:13 +02:00
QFrame* pFrame;
QWidget* pLevelsBox;
QWidget* pMuteSoloBox;
CLevelMeter* plbrChannelLevel;
QSlider* pFader;
QDial* pPan;
QLabel* pPanLabel;
QLabel* pInfoLabel;
QHBoxLayout* pLabelGrid;
QVBoxLayout* pLabelPictGrid;
QCheckBox* pcbMute;
QCheckBox* pcbSolo;
QCheckBox* pcbGroup;
QGroupBox* pLabelInstBox;
QLabel* plblLabel;
QLabel* plblInstrument;
QLabel* plblCountryFlag;
CChannelInfo cReceivedChanInfo;
bool bOtherChannelIsSolo;
bool bIsMyOwnFader;
double dPreviousFaderLevel;
2013-01-23 11:41:13 +01:00
public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); }
void OnPanValueChanged ( int value ) { SendPanValueToServer ( value ); }
2013-01-23 11:41:13 +01:00
void OnMuteStateChanged ( int value );
signals:
void gainValueChanged ( double value,
bool bIsMyOwnFader,
bool bIsGroupUpdate,
bool bSuppressServerUpdate,
double dLevelRatio );
void panValueChanged ( double value );
2013-01-23 11:41:13 +01:00
void soloStateChanged ( int value );
};
template<unsigned int slotId>
class CAudioMixerBoardSlots : public CAudioMixerBoardSlots<slotId - 1>
{
public:
void OnChGainValueChanged ( double dValue,
bool bIsMyOwnFader,
bool bIsGroupUpdate,
bool bSuppressServerUpdate,
double dLevelRatio ) { UpdateGainValue ( slotId - 1,
dValue,
bIsMyOwnFader,
bIsGroupUpdate,
bSuppressServerUpdate,
dLevelRatio ); }
void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); }
protected:
virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue,
const bool bIsMyOwnFader,
const bool bIsGroupUpdate,
const bool bSuppressServerUpdate,
const double dLevelRatio ) = 0;
virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue ) = 0;
};
template<>
class CAudioMixerBoardSlots<0> {};
class CAudioMixerBoard :
public QGroupBox,
public CAudioMixerBoardSlots<MAX_NUM_CHANNELS>
2013-01-23 11:41:13 +01:00
{
Q_OBJECT
public:
CAudioMixerBoard ( QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
2013-01-23 11:41:13 +01:00
virtual ~CAudioMixerBoard();
2013-01-23 11:41:13 +01:00
void HideAll();
void ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInfo );
2013-01-23 11:41:13 +01:00
void SetServerName ( const QString& strNewServerName );
void SetGUIDesign ( const EGUIDesign eNewDesign );
2020-03-29 23:40:53 +02:00
void SetDisplayChannelLevels ( const bool eNDCL );
void SetDisplayPans ( const bool eNDP );
void SetPanIsSupported();
void SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute );
void SetMyChannelID ( const int iChannelIdx ) { iMyChannelID = iChannelIdx; }
2013-01-23 11:41:13 +01:00
void SetFaderLevel ( const int iChannelIdx,
const int iValue );
2020-06-13 08:51:05 +02:00
void ChangeFaderOrder ( const bool bDoSort,
const EChSortType eChSortType );
2020-03-29 23:40:53 +02:00
void SetChannelLevels ( const CVector<uint16_t>& vecChannelLevel );
2020-06-14 23:02:13 +02:00
void SetRecorderState ( const ERecorderState newRecorderState );
// settings
CVector<QString> vecStoredFaderTags;
CVector<int> vecStoredFaderLevels;
2020-05-16 19:11:54 +02:00
CVector<int> vecStoredPanValues;
CVector<int> vecStoredFaderIsSolo;
CVector<int> vecStoredFaderIsMute;
2015-11-25 16:52:00 +01:00
int iNewClientFaderLevel;
2013-01-23 11:41:13 +01:00
protected:
class CMixerBoardScrollArea : public QScrollArea
{
public:
CMixerBoardScrollArea ( QWidget* parent = nullptr ) : QScrollArea ( parent ) {}
protected:
virtual void resizeEvent ( QResizeEvent* event )
{
// if after a resize of the main window a vertical scroll bar is required, make
// sure that the fader label is visible (scroll down completely)
ensureVisible ( 0, 2000 ); // use a large value here
QScrollArea::resizeEvent ( event );
}
};
bool GetStoredFaderSettings ( const CChannelInfo& ChanInfo,
2014-01-19 11:51:31 +01:00
int& iStoredFaderLevel,
2020-05-16 19:11:54 +02:00
int& iStoredPanValue,
bool& bStoredFaderIsSolo,
2020-06-20 17:44:34 +02:00
bool& bStoredFaderIsMute );
2014-01-19 11:51:31 +01:00
void StoreFaderSettings ( CChannelFader* pChanFader );
void UpdateSoloStates();
2020-06-15 21:48:30 +02:00
void UpdateTitle();
2020-04-26 00:55:28 +02:00
void OnGainValueChanged ( const int iChannelIdx,
const double dValue );
2013-01-23 11:41:13 +01:00
CVector<CChannelFader*> vecpChanFader;
CMixerBoardScrollArea* pScrollArea;
2013-01-23 11:41:13 +01:00
QHBoxLayout* pMainLayout;
2020-03-29 23:40:53 +02:00
bool bDisplayChannelLevels;
bool bDisplayPans;
bool bIsPanSupported;
2015-11-25 16:52:00 +01:00
bool bNoFaderVisible;
int iMyChannelID;
QString strServerName;
2020-06-14 23:02:13 +02:00
ERecorderState eRecorderState;
2013-01-23 11:41:13 +01:00
virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue,
const bool bIsMyOwnFader,
const bool bIsGroupUpdate,
const bool bSuppressServerUpdate,
const double dLevelRatio );
virtual void UpdatePanValue ( const int iChannelIdx,
const double dValue );
template<unsigned int slotId>
inline void connectFaderSignalsToMixerBoardSlots();
2013-01-23 11:41:13 +01:00
signals:
void ChangeChanGain ( int iId, double dGain, bool bIsMyOwnFader );
2020-04-26 00:55:28 +02:00
void ChangeChanPan ( int iId, double dPan );
2013-01-23 11:41:13 +01:00
void NumClientsChanged ( int iNewNumClients );
};