jamulus/src/audiomixerboard.h

224 lines
7.8 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-03-29 23:40:53 +02:00
#include "multicolorledbar.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
QString GetReceivedName() { return strReceivedName; }
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(); }
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
void UpdateSoloState ( const bool bNewOtherSoloState );
void SetFaderLevel ( const int iLevel );
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 );
int GetFaderLevel() { return pFader->value(); }
int GetPanValue() { return pPan->value(); }
void Reset();
2020-03-29 23:40:53 +02:00
void SetChannelLevel ( const uint16_t iLevel );
void SetIsMyOwnFader() { bIsMyOwnFader = true; }
2013-01-23 11:41:13 +01:00
protected:
double CalcFaderGain ( const int value );
void SetMute ( const bool bState );
void SendFaderLevelToServer ( const int iLevel );
2020-04-26 00:55:28 +02:00
void SendPanValueToServer ( const int iPan );
void SetupFaderTag ( const ESkillLevel eSkillLevel );
2013-01-23 11:41:13 +01:00
2020-03-29 23:40:53 +02:00
QFrame* pFrame;
2013-01-23 11:41:13 +01:00
2020-03-29 23:40:53 +02:00
QWidget* pLevelsBox;
QWidget* pMuteSoloBox;
CMultiColorLEDBar* plbrChannelLevel;
QSlider* pFader;
QDial* pPan;
QLabel* pPanLabel;
QLabel* pInfoLabel;
QHBoxLayout* pLabelGrid;
QVBoxLayout* pLabelPictGrid;
2020-03-29 23:40:53 +02:00
QCheckBox* pcbMute;
QCheckBox* pcbSolo;
QGroupBox* pLabelInstBox;
QLabel* plblLabel;
QLabel* plblInstrument;
QLabel* plblCountryFlag;
QString strReceivedName;
bool bOtherChannelIsSolo;
bool bIsMyOwnFader;
2013-01-23 11:41:13 +01:00
public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value ); }
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 );
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 ) { UpdateGainValue ( slotId - 1, dValue, bIsMyOwnFader ); }
void OnChPanValueChanged ( double dValue ) { UpdatePanValue ( slotId - 1, dValue ); }
protected:
virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue,
const bool bIsMyOwnFader ) = 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:
2019-05-17 22:55:46 +02:00
CAudioMixerBoard ( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
2013-01-23 11:41:13 +01:00
void HideAll();
void ChangeFaderOrder ( const bool bDoSort );
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-03-29 23:40:53 +02:00
void SetChannelLevels ( const CVector<uint16_t>& vecChannelLevel );
// 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,
bool& bStoredFaderIsMute );
2014-01-19 11:51:31 +01:00
void StoreFaderSettings ( CChannelFader* pChanFader );
void UpdateSoloStates();
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;
2013-01-23 11:41:13 +01:00
virtual void UpdateGainValue ( const int iChannelIdx,
const double dValue,
const bool bIsMyOwnFader );
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 );
};