mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-24 22:58:01 -04:00
Disable built-in NaN handler through hidden setting (#4787)
* Disable built-in NaN handler through hidden setting * Reuse code
This commit is contained in:
committed by
GitHub
parent
0a47b0c8cd
commit
b28d405240
@@ -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 */
|
||||
|
||||
@@ -142,6 +142,7 @@ private:
|
||||
bool m_MMPZ;
|
||||
bool m_disableBackup;
|
||||
bool m_openLastProject;
|
||||
bool m_NaNHandler;
|
||||
bool m_hqAudioDev;
|
||||
QString m_lang;
|
||||
QStringList m_languages;
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "ValueBuffer.h"
|
||||
|
||||
|
||||
static bool s_NaNHandler;
|
||||
|
||||
|
||||
namespace MixHelpers
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
@@ -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];
|
||||
@@ -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] ) )
|
||||
@@ -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) );
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -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() )
|
||||
|
||||
@@ -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",
|
||||
@@ -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 );
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user