Skip to content
Merged
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
4 changes: 4 additions & 0 deletions include/MixHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ namespace MixHelpers

bool isSilent( const sampleFrame* src, int frames );

bool useNaNHandler();

void setNaNHandler( bool use );

bool sanitize( sampleFrame * src, int frames );

/*! \brief Add samples from src to dst */
Expand Down
1 change: 1 addition & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private slots:
bool m_MMPZ;
bool m_disableBackup;
bool m_openLastProject;
bool m_NaNHandler;
bool m_hqAudioDev;
QString m_lang;
QStringList m_languages;
Expand Down
37 changes: 37 additions & 0 deletions src/core/MixHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "ValueBuffer.h"


static bool s_NaNHandler;


namespace MixHelpers
{

Expand Down Expand Up @@ -68,10 +71,24 @@ bool isSilent( const sampleFrame* src, int frames )
return true;
}

bool useNaNHandler()
{
return s_NaNHandler;
}

void setNaNHandler( bool use )
{
s_NaNHandler = use;
}

/*! \brief Function for sanitizing a buffer of infs/nans - returns true if those are found */
bool sanitize( sampleFrame * src, int frames )
{
if( !useNaNHandler() )
{
return false;
}

bool found = false;
for( int f = 0; f < frames; ++f )
{
Expand Down Expand Up @@ -179,6 +196,13 @@ void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuff

void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
{
if ( !useNaNHandler() )
{
addMultipliedByBuffer( dst, src, coeffSrc, coeffSrcBuf,
frames );
return;
}

for( int f = 0; f < frames; ++f )
{
dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) ? 0.0f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f];
Expand All @@ -188,6 +212,13 @@ void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, f

void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
{
if ( !useNaNHandler() )
{
addMultipliedByBuffers( dst, src, coeffSrcBuf1, coeffSrcBuf2,
frames );
return;
}

for( int f = 0; f < frames; ++f )
{
dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) )
Expand Down Expand Up @@ -216,6 +247,12 @@ struct AddSanitizedMultipliedOp

void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames )
{
if ( !useNaNHandler() )
{
addMultiplied( dst, src, coeffSrc, frames );
return;
}

run<>( dst, src, frames, AddSanitizedMultipliedOp(coeffSrc) );
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "GuiApplication.h"
#include "ImportFilter.h"
#include "MainWindow.h"
#include "MixHelpers.h"
#include "OutputSettings.h"
#include "ProjectRenderer.h"
#include "RenderManager.h"
Expand Down Expand Up @@ -633,6 +634,10 @@ int main( int argc, char * * argv )

ConfigManager::inst()->loadConfigFile(configFile);

// Hidden settings
MixHelpers::setNaNHandler( ConfigManager::inst()->value( "app",
"nanhandler", "1" ).toInt() );

// set language
QString pos = ConfigManager::inst()->value( "app", "language" );
if( pos.isEmpty() )
Expand Down
13 changes: 13 additions & 0 deletions src/gui/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
"disablebackup" ).toInt() ),
m_openLastProject( ConfigManager::inst()->value( "app",
"openlastproject" ).toInt() ),
m_NaNHandler( ConfigManager::inst()->value( "app",
"nanhandler", "1" ).toInt() ),
m_hqAudioDev( ConfigManager::inst()->value( "mixer",
"hqaudio" ).toInt() ),
m_lang( ConfigManager::inst()->value( "app",
Expand Down Expand Up @@ -334,6 +336,15 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :

misc_tw->setFixedHeight( YDelta*labelNumber + HeaderSize );

// Advanced setting, hidden for now
if( false )
{
LedCheckBox * useNaNHandler = new LedCheckBox(
tr( "Use built-in NaN handler" ),
misc_tw );
useNaNHandler->setChecked( m_NaNHandler );
}

TabWidget* embed_tw = new TabWidget( tr( "PLUGIN EMBEDDING" ), general);
embed_tw->setFixedHeight( 48 );
m_vstEmbedComboBox = new QComboBox( embed_tw );
Expand Down Expand Up @@ -1055,6 +1066,8 @@ void SetupDialog::accept()
QString::number( !m_disableBackup ) );
ConfigManager::inst()->setValue( "app", "openlastproject",
QString::number( m_openLastProject ) );
ConfigManager::inst()->setValue( "app", "nanhandler",
QString::number( m_NaNHandler ) );
ConfigManager::inst()->setValue( "mixer", "hqaudio",
QString::number( m_hqAudioDev ) );
ConfigManager::inst()->setValue( "ui", "smoothscroll",
Expand Down