Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ During compile time some CONFIG arguments can be given to enable or disable spec
| `serveronly` | Only support running as Server |
| `headless` | Disable GUI. Supports Client and Server. Usually used with serveronly |
| `nojsonrpc` | Disable JSON-RPC support |
| `nointernaleffects` | Build the Client without the built-in input effects (boost, compressor, reverb); the effects chain stays empty |
| `jackonwindows` | Use JACK instead of ASIO on Windows |
| `jackonmac` | Use JACK instead of CoreAudio on macOS (untested) |
| `server_bundle` | macOS only: Create an application bundle which starts server by default |
Expand Down
35 changes: 29 additions & 6 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ contains(CONFIG, "headless") {
QT += multimedia
}

contains(CONFIG, "nointernaleffects") {
message(Building without the internal input effects due to CONFIG+=nointernaleffects.)
DEFINES += NO_INTERNAL_EFFECTS
}

# Do not set LRELEASE_DIR explicitly when using embed_translations.
# It doesn't work with multiple targets or architectures.
TRANSLATIONS = src/translation/translation_ja_JP.ts \
Expand Down Expand Up @@ -400,11 +405,12 @@ FORMS_GUI = src/aboutdlgbase.ui \
FORMS_GUI += src/clientdlgbase.ui \
src/clientsettingsdlgbase.ui \
src/chatdlgbase.ui \
src/connectdlgbase.ui
src/connectdlgbase.ui \
src/inputeffectlanebase.ui \
src/inputeffectsdlgbase.ui
}

HEADERS += src/plugins/audioreverb.h \
src/buffer.h \
HEADERS += src/buffer.h \
src/channel.h \
src/global.h \
src/protocol.h \
Expand All @@ -423,6 +429,11 @@ HEADERS += src/plugins/audioreverb.h \

!contains(CONFIG, "serveronly") {
HEADERS += src/client.h \
src/plugins/inputeffect.h \
src/plugins/inputeffectchain.h \
src/plugins/inputboost.h \
src/plugins/audiocompressor.h \
src/plugins/audioreverb.h \
src/sound/soundbase.h \
src/testbench.h
}
Expand All @@ -435,6 +446,8 @@ HEADERS_GUI = src/serverdlg.h
src/clientsettingsdlg.h \
src/connectdlg.h \
src/clientdlg.h \
src/inputeffectlane.h \
src/inputeffectsdlg.h \
src/levelmeter.h \
src/analyzerconsole.h \
src/multicolorled.h
Expand Down Expand Up @@ -511,8 +524,7 @@ HEADERS_OPUS_X86 = libs/opus/celt/x86/celt_lpc_sse.h \
libs/opus/celt/x86/x86cpu.h \
$$files(libs/opus/silk/x86/*.h)

SOURCES += src/plugins/audioreverb.cpp \
src/buffer.cpp \
SOURCES += src/buffer.cpp \
src/channel.cpp \
src/main.cpp \
src/protocol.cpp \
Expand All @@ -530,7 +542,16 @@ SOURCES += src/plugins/audioreverb.cpp \

!contains(CONFIG, "serveronly") {
SOURCES += src/client.cpp \
src/sound/soundbase.cpp \
src/plugins/inputeffectchain.cpp \
src/sound/soundbase.cpp

# the internal input effects can be left out (e.g. for a build with a
# plugin host instead)
!contains(CONFIG, "nointernaleffects") {
SOURCES += src/plugins/inputboost.cpp \
src/plugins/audiocompressor.cpp \
src/plugins/audioreverb.cpp
}
}

SOURCES_GUI = src/serverdlg.cpp
Expand All @@ -541,6 +562,8 @@ SOURCES_GUI = src/serverdlg.cpp
src/clientsettingsdlg.cpp \
src/connectdlg.cpp \
src/clientdlg.cpp \
src/inputeffectlane.cpp \
src/inputeffectsdlg.cpp \
src/multicolorled.cpp \
src/levelmeter.cpp \
src/analyzerconsole.cpp
Expand Down
106 changes: 85 additions & 21 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ CClient::CClient ( const quint16 iPortNumber,
Socket ( &Channel, iPortNumber, iQosNumber, "", "", bNDisableIPv6, bIPv6Available ),
Sound ( AudioCallback, this, bNoAutoJackConnect, strNClientName ),
iAudioInFader ( AUD_FADER_IN_MIDDLE ),
bReverbOnLeftChan ( false ),
iReverbLevel ( 0 ),
iInputBoost ( 1 ),
bLocalPreview ( false ),
iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
bSndCrdConversionBufferRequired ( false ),
Expand Down Expand Up @@ -918,6 +916,13 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType )
strError = generr.GetErrorText();
}

// a local preview does not survive a failed sound card restart
if ( bLocalPreview && !Sound.IsRunning() )
{
bLocalPreview = false;
emit LocalPreviewChanged ( false );
}

// inform GUI about the sound card device change
emit SoundDeviceChanged ( strError );
}
Expand Down Expand Up @@ -1056,8 +1061,50 @@ void CClient::OnRawAudioSupported()
}
}

void CClient::SetLocalPreview ( const bool bOn )
{
// the preview uses the sound card, therefore it is only possible while
// not connected
if ( ( bOn == bLocalPreview ) || ( bOn && ( GetConnectionState() != CS_DISCONNECTED ) ) )
{
return;
}

if ( bOn )
{
Init(); // may throw CGenErr
bLocalPreview = true;

try
{
Sound.Start();
}
catch ( const CGenErr& )
{
bLocalPreview = false;
throw;
}
}
else
{
Sound.Stop();
bLocalPreview = false;
}

SignalLevelMeter.Reset();
SignalLevelMeterRaw.Reset();

emit LocalPreviewChanged ( bLocalPreview );
}

void CClient::Start()
{
// a running local preview must end before connecting
if ( bLocalPreview )
{
SetLocalPreview ( false );
}

// init object
Init();

Expand Down Expand Up @@ -1089,6 +1136,13 @@ void CClient::Start()
/// Use to set CClientDlg to show not being connected
void CClient::Stop()
{
// the local preview ends together with the sound card
if ( bLocalPreview )
{
bLocalPreview = false;
emit LocalPreviewChanged ( false );
}

// stop audio interface
Sound.Stop();

Expand Down Expand Up @@ -1132,6 +1186,7 @@ void CClient::Stop()
// reset current signal level and LEDs
bJitterBufferOK = true;
SignalLevelMeter.Reset();
SignalLevelMeterRaw.Reset();

#if defined( Q_OS_WINDOWS )
// Allow hibernation or display dimming if the app is running again (Windows)
Expand Down Expand Up @@ -1461,8 +1516,8 @@ void CClient::Init()
// set the channel network properties
Channel.SetAudioStreamProperties ( eAudioCompressionType, iCeltNumCodedBytes, iSndCrdFrameSizeFactor, iNumAudioChannels );

// init reverberation
AudioReverb.Init ( eAudioChannelConf, iStereoBlockSizeSam, SYSTEM_SAMPLE_RATE_HZ );
// init the local input effects
InputEffects.Init ( eAudioChannelConf, iMonoBlockSizeSam );

// init the sound card conversion buffers
if ( bSndCrdConversionBufferRequired )
Expand Down Expand Up @@ -1541,27 +1596,19 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )

// Transmit signal ---------------------------------------------------------

if ( iInputBoost != 1 )
{
// apply a general gain boost to all audio input:
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
{
vecsStereoSndCrd[j + 1] = Float2Short ( iInputBoost * vecsStereoSndCrd[j + 1] );
vecsStereoSndCrd[j] = Float2Short ( iInputBoost * vecsStereoSndCrd[j] );
}
}
// update the signal level meters before and after the local input
// effects (not needed in headless mode)
#ifndef HEADLESS
SignalLevelMeterRaw.Update ( vecsStereoSndCrd, iMonoBlockSizeSam, true );
#endif

// apply the local input effects (boost, compressor, reverberation)
InputEffects.Process ( vecsStereoSndCrd );

// update stereo signal level meter (not needed in headless mode)
#ifndef HEADLESS
SignalLevelMeter.Update ( vecsStereoSndCrd, iMonoBlockSizeSam, true );
#endif

// add reverberation effect if activated
if ( iReverbLevel != 0 )
{
AudioReverb.Process ( vecsStereoSndCrd, bReverbOnLeftChan, static_cast<float> ( iReverbLevel ) / AUD_REVERB_MAX / 4 );
}

// apply pan (audio fader) and mix mono signals
if ( !( ( iAudioInFader == AUD_FADER_IN_MIDDLE ) && ( eAudioChannelConf == CC_STEREO ) ) )
{
Expand Down Expand Up @@ -1612,6 +1659,23 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
}

// local preview (not connected): nothing is sent or received, instead the
// processed signal which would be sent is played to the sound card outputs
if ( bLocalPreview )
{
if ( eAudioChannelConf == CC_MONO )
{
// copy mono data in stereo sound card buffer (start from the end
// not to overwrite input values)
for ( i = iMonoBlockSizeSam - 1, j = iStereoBlockSizeSam - 2; i >= 0; i--, j -= 2 )
{
vecsStereoSndCrd[j] = vecsStereoSndCrd[j + 1] = vecsStereoSndCrd[i];
}
}

return;
}

for ( i = 0, j = 0; i < iSndCrdFrameSizeFactor; i++, j += iNumAudioChannels * iOPUSFrameSizeSamples )
{
// OPUS encoding or copying RAW audio?
Expand Down
35 changes: 16 additions & 19 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include "socket.h"
#include "channel.h"
#include "util.h"
#include "plugins/audioreverb.h"
#include "plugins/inputeffectchain.h"
#include "buffer.h"
#include "signalhandler.h"

Expand Down Expand Up @@ -105,9 +105,6 @@ enum EConnectionState
#define AUD_FADER_IN_MAX 100
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )

// audio reverberation range
#define AUD_REVERB_MAX 100

// default delay period between successive gain updates (ms)
// this will be increased to double the ping time if connected to a distant server
#define DEFAULT_GAIN_DELAY_PERIOD_MS 50
Expand Down Expand Up @@ -185,9 +182,19 @@ class CClient : public QObject
// IPv6 Available
bool IsIPv6Available() { return bIPv6Available; }

// signal level after the input effects (what is sent to the server)
double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); }
double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); }

// signal level as it comes from the sound card
double GetLevelForMeterdBRawLeft() { return SignalLevelMeterRaw.GetLevelForMeterdBLeftOrMono(); }
double GetLevelForMeterdBRawRight() { return SignalLevelMeterRaw.GetLevelForMeterdBRight(); }

// local preview: while not connected, run the sound card and play the
// processed input signal to the outputs instead of sending it
bool IsLocalPreviewActive() const { return bLocalPreview; }
void SetLocalPreview ( const bool bOn );

bool GetAndResetbJitterBufferOKFlag();

bool IsConnected() { return Channel.IsConnected(); }
Expand All @@ -207,15 +214,7 @@ class CClient : public QObject
int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }

int GetReverbLevel() const { return iReverbLevel; }
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }

bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
void SetReverbOnLeftChan ( const bool bIL )
{
bReverbOnLeftChan = bIL;
AudioReverb.Clear();
}
CInputEffectChain& GetInputEffects() { return InputEffects; }

void SetDoAutoSockBufSize ( const bool bValue );
bool GetDoAutoSockBufSize() const { return Channel.GetDoAutoSockBufSize(); }
Expand Down Expand Up @@ -306,8 +305,6 @@ class CClient : public QObject

void SetControllerInFaderLevel ( int iChannelIdx, int iValue ) { OnControllerInFaderLevel ( iChannelIdx, iValue ); }

void SetInputBoost ( const int iNewBoost ) { iInputBoost = iNewBoost; }

void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); }

void CreateChatTextMes ( const QString& strChatText ) { Channel.CreateChatTextMes ( strChatText ); }
Expand Down Expand Up @@ -428,14 +425,13 @@ class CClient : public QObject

CSound Sound;
CStereoSignalLevelMeter SignalLevelMeter;
CStereoSignalLevelMeter SignalLevelMeterRaw;

CVector<uint8_t> vecbyNetwData;

std::atomic<int> iAudioInFader;
std::atomic<bool> bReverbOnLeftChan;
std::atomic<int> iReverbLevel;
CAudioReverb AudioReverb;
std::atomic<int> iInputBoost;
CInputEffectChain InputEffects;
std::atomic<bool> bLocalPreview;

int iSndCrdPrefFrameSizeFactor;
int iSndCrdFrameSizeFactor;
Expand Down Expand Up @@ -543,6 +539,7 @@ protected slots:
void Disconnected();

void SoundDeviceChanged ( QString strError );
void LocalPreviewChanged ( bool bActive );
void ControllerInFaderLevel ( int iChannelIdx, int iValue );
void ControllerInPanValue ( int iChannelIdx, int iValue );
void ControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo );
Expand Down
Loading