From 4f62be89ed4f684cbcbeee06142a123f116bc77b Mon Sep 17 00:00:00 2001 From: Vesa Date: Mon, 1 Dec 2014 09:33:54 +0200 Subject: [PATCH 01/13] Fix time --- plugins/MultitapEcho/MultitapEcho.cpp | 2 +- plugins/MultitapEcho/MultitapEchoControls.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index d6664a63a..75ae20b87 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -50,7 +50,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug Effect( &multitapecho_plugin_descriptor, parent, key ), m_stages( 1 ), m_controls( this ), - m_buffer( 20100.0f ), + m_buffer( 16100.0f ), m_sampleRate( Engine::mixer()->processingSampleRate() ), m_sampleRatio( 1.0f / m_sampleRate ) { diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 70ad2cad0..02bc45198 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -35,7 +35,7 @@ MultitapEchoControls::MultitapEchoControls( MultitapEchoEffect * eff ) : EffectControls( eff ), m_effect( eff ), m_steps( 16, 4, 32, this, "Steps" ), - m_stepLength( 100.0f, 1.0f, 1000.0f, 0.1f, 1000.0f, this, "Step length" ), + m_stepLength( 100.0f, 1.0f, 500.0f, 0.1f, 500.0f, this, "Step length" ), m_dryGain( 0.0f, -80.0f, 20.0f, 0.1f, this, "Dry gain" ), m_swapInputs( false, this, "Swap inputs" ), m_stages( 1.0f, 1.0f, 4.0f, 1.0f, this, "Lowpass stages" ), From b1414eba2396698e49b4bb449b4ba224f0326c69 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Tue, 2 Dec 2014 18:07:56 -0500 Subject: [PATCH 02/13] Cleaning up null-pointer-deallocation warnings. --- src/core/SampleBuffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index c685fd1cf..6ab17741c 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -149,7 +149,9 @@ SampleBuffer::SampleBuffer( const f_cnt_t _frames ) : SampleBuffer::~SampleBuffer() { - MM_FREE( m_origData ); + if( m_origData != NULL ) + MM_FREE( m_origData ); + MM_FREE( m_data ); } From d17b6c53288690cf4b2dd28ad8a1be17245977bc Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 4 Dec 2014 17:16:50 +0100 Subject: [PATCH 03/13] LmmsStyle: Remove legacy code --- include/LmmsStyle.h | 5 - src/core/RingBuffer.cpp | 4 +- src/gui/LmmsStyle.cpp | 430 ---------------------------------------- 3 files changed, 2 insertions(+), 437 deletions(-) diff --git a/include/LmmsStyle.h b/include/LmmsStyle.h index 1173a1e1a..a99628f5e 100644 --- a/include/LmmsStyle.h +++ b/include/LmmsStyle.h @@ -69,8 +69,6 @@ public: virtual QPalette standardPalette( void ) const; -// virtual void drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const; - virtual void drawComplexControl( ComplexControl control, const QStyleOptionComplex * option, @@ -85,9 +83,6 @@ public: const QStyleOption * option = 0, const QWidget * widget = 0 ) const; -// QSize sizeFromContents( ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget ) const; -// QRect subControlRect( ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget ) const; - static QPalette * s_palette; private: diff --git a/src/core/RingBuffer.cpp b/src/core/RingBuffer.cpp index 21ec1f70f..ae06acc61 100644 --- a/src/core/RingBuffer.cpp +++ b/src/core/RingBuffer.cpp @@ -56,7 +56,7 @@ RingBuffer::RingBuffer( float size ) : RingBuffer::~RingBuffer() { - delete m_buffer; + delete[] m_buffer; } @@ -308,7 +308,7 @@ void RingBuffer::updateSamplerate() float newsize = static_cast( ( m_size - m_fpp ) * Engine::mixer()->processingSampleRate() ) / m_samplerate; m_size = static_cast( ceilf( newsize ) ) + m_fpp; m_samplerate = Engine::mixer()->processingSampleRate(); - delete m_buffer; + delete[] m_buffer; m_buffer = new sampleFrame[ m_size ]; memset( m_buffer, 0, m_size * sizeof( sampleFrame ) ); m_position = 0; diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 28e47b2c1..893e00684 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -35,78 +35,6 @@ #include "LmmsStyle.h" #include "LmmsPalette.h" -const int BUTTON_LENGTH = 24; - -static const char * const s_scrollbarArrowUpXpm[] = { - "7 6 8 1", - " g None", - ". g #000000", - "+ g #101010", - "@ g #A0A0A0", - "# g #C0C0C0", - "$ g #FFFFFF", - "% g #808080", - "& g #202020", - "..+@+..", - "..#$#..", - ".%$$$%.", - "&$$$$$&", - "@$$$$$@", - "@#####@"}; - -static const char * const s_scrollbarArrowRightXpm[] = { - "6 7 8 1", - " c None", - ". c #A0A0A0", - "+ c #202020", - "@ c #000000", - "# c #C0C0C0", - "$ c #FFFFFF", - "% c #808080", - "& c #101010", - "..+@@@", - "#$$%@@", - "#$$$#&", - "#$$$$.", - "#$$$#&", - "#$$%@@", - "..+@@@"}; - -static const char * const s_scrollbarArrowDownXpm[] = { - "7 6 8 1", - " g None", - ". g #000000", - "+ g #101010", - "@ g #A0A0A0", - "# g #C0C0C0", - "$ g #FFFFFF", - "% g #808080", - "& g #202020", - "@#####@", - "@$$$$$@", - "&$$$$$&", - ".%$$$%.", - "..#$#..", - "..+@+.."}; - -static const char * const s_scrollbarArrowLeftXpm[] = { - "6 7 8 1", - " g None", - ". g #000000", - "+ g #202020", - "@ g #A0A0A0", - "# g #808080", - "$ g #FFFFFF", - "% g #C0C0C0", - "& g #101010", - "...+@@", - "..#$$%", - "&%$$$%", - "@$$$$%", - "&%$$$%", - "..#$$%", - "...+@@"}; - QPalette * LmmsStyle::s_palette = NULL; QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) @@ -226,196 +154,6 @@ QPalette LmmsStyle::standardPalette( void ) const } - -/* -void LmmsStyle::drawControl( ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const -{ - - switch( element ) - { - case CE_ScrollBarAddLine: - if( const QStyleOptionSlider * scrollBar = qstyleoption_cast( option ) ) - { - - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool isEnabled = scrollBar->state & State_Enabled; - bool sunken = scrollBar->state & State_Sunken; - bool hover = scrollBar->state & State_MouseOver; - - QString pixmapName = getCacheKey( QLatin1String( "ScrollBarAddLine" ), option, option->rect.size() ); - - QPixmap cache; - if( !QPixmapCache::find( pixmapName, cache ) ) - { - cache = QPixmap( option->rect.size() ); - QPainter cachePainter( &cache ); - - cache.fill( QColor( 48, 48, 48 ) ); - QColor sliderColor; - QColor blurColor; - hoverColors(sunken, hover, - scrollBar->activeSubControls & SC_ScrollBarAddLine && isEnabled, - sliderColor, blurColor); - - int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, option, widget ); - cachePainter.setPen( QPen( sliderColor, 0 ) ); - if( horizontal ) - { - int r = cache.rect().right(); - cachePainter.fillRect(0, 2, BUTTON_LENGTH-2, - scrollBarExtent-4, sliderColor); - - cachePainter.drawLine( r, 4, r, scrollBarExtent - 5 ); - cachePainter.drawLine( r - 1, 3, r - 1, scrollBarExtent - 4 ); - - const QPointF points[4] = { - QPoint( r, 3 ), QPoint( r, scrollBarExtent - 4 ), - QPoint( r - 1, 2 ), QPoint( r - 1, scrollBarExtent - 3 )}; - - cachePainter.setPen( QPen( blurColor, 0 ) ); - cachePainter.drawPoints( points, 4 ); - - QImage arrow = colorizeXpm( s_scrollbarArrowRightXpm, option->palette.foreground().color() ); - if( ( scrollBar->activeSubControls & SC_ScrollBarAddLine ) && sunken ) - { - cachePainter.translate( 1, 1 ); - } - cachePainter.drawImage( cache.rect().center() - QPoint( 3, 3 ), arrow ); - } - else - { - int b = cache.rect().bottom(); - cachePainter.fillRect( 2, 0, scrollBarExtent - 4, BUTTON_LENGTH - 2, sliderColor ); - cachePainter.drawLine( 4, b, scrollBarExtent - 5, b ); - cachePainter.drawLine( 3, b - 1, scrollBarExtent - 4, b - 1 ); - - const QPointF points[4] = { - QPoint( 3, b ), QPoint( scrollBarExtent - 4, b ), - QPoint( 2, b - 1 ), QPoint( scrollBarExtent - 3, b - 1 )}; - - cachePainter.setPen( QPen( blurColor, 0 ) ); - cachePainter.drawPoints( points, 4 ); - - QImage arrow = colorizeXpm( s_scrollbarArrowDownXpm, option->palette.foreground().color() ); - if( ( scrollBar->activeSubControls & SC_ScrollBarAddLine ) && sunken ) - { - cachePainter.translate( 1, 1 ); - } - cachePainter.drawImage( cache.rect().center() - QPoint( 3, 3 ), arrow ); - } - QPixmapCache::insert( pixmapName, cache ); - } - painter->drawPixmap( option->rect.topLeft(), cache ); - - } - break; - - case CE_ScrollBarSubLine: - if(const QStyleOptionSlider *scrollBar = qstyleoption_cast( option ) ) - { - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool isEnabled = scrollBar->state & State_Enabled; - bool sunken = scrollBar->state & State_Sunken; - bool hover = scrollBar->state & State_MouseOver; - - QString pixmapName = getCacheKey( QLatin1String( "ScrollBarSubLine" ), option, option->rect.size() ); - QPixmap cache; - if( !QPixmapCache::find( pixmapName, cache ) ) - { - cache = QPixmap( option->rect.size() ); - QPainter cachePainter( &cache ); - - cache.fill( QColor( 48, 48, 48 ) ); // TODO: Fill with CSS background - QColor sliderColor; - QColor blurColor; - hoverColors(sunken, hover, - scrollBar->activeSubControls & SC_ScrollBarSubLine && isEnabled, - sliderColor, blurColor); - - int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, option, widget ); - cachePainter.setPen( QPen( sliderColor, 0 ) ); - if( horizontal ) - { - cachePainter.fillRect( 2, 2, BUTTON_LENGTH - 2, scrollBarExtent - 4, sliderColor ); - cachePainter.drawLine( 0, 4, 0, scrollBarExtent - 5 ); - cachePainter.drawLine( 1, 3, 1, scrollBarExtent - 4 ); - - const QPointF points[4] = { - QPoint( 0, 3 ), QPoint( 0, scrollBarExtent - 4 ), - QPoint( 1, 2 ), QPoint( 1, scrollBarExtent - 3 )}; - - cachePainter.setPen( QPen( blurColor, 0 ) ); - cachePainter.drawPoints( points, 4 ); - - QImage arrow = colorizeXpm( s_scrollbarArrowLeftXpm, option->palette.foreground().color() ); - if( ( scrollBar->activeSubControls & SC_ScrollBarSubLine ) && sunken ) - { - cachePainter.translate( 1, 1 ); - } - cachePainter.drawImage( cache.rect().center() - QPoint( 3, 3 ), arrow ); - } - else - { - cachePainter.fillRect( 2, 2, scrollBarExtent - 4, BUTTON_LENGTH - 2, sliderColor ); - cachePainter.drawLine( 4, 0, scrollBarExtent - 5, 0 ); - cachePainter.drawLine( 3, 1, scrollBarExtent - 4, 1 ); - - const QPointF points[4] = { - QPoint( 3, 0 ), QPoint( scrollBarExtent - 4, 0 ), - QPoint( 2, 1 ), QPoint( scrollBarExtent - 3, 1 )}; - - cachePainter.setPen( QPen( blurColor, 0 ) ); - cachePainter.drawPoints( points, 4 ); - - QImage arrow = colorizeXpm( s_scrollbarArrowUpXpm, option->palette.foreground().color() ); - if( ( scrollBar->activeSubControls & SC_ScrollBarSubLine ) && sunken ) - { - cachePainter.translate( 1, 1 ); - } - cachePainter.drawImage( cache.rect().center() - QPoint( 3, 3 ), arrow ); - } - QPixmapCache::insert( pixmapName, cache ); - } - painter->drawPixmap( option->rect.topLeft(), cache ); - - } - break; - - case CE_ScrollBarSubPage: - case CE_ScrollBarAddPage: - break; - - case CE_ScrollBarSlider: - if( const QStyleOptionSlider* scrollBar = qstyleoption_cast( option ) ) - { - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool isEnabled = scrollBar->state & State_Enabled; - bool sunken = scrollBar->state & State_Sunken; - bool hover = scrollBar->state & State_MouseOver; - - QColor sliderColor, blendColor; - hoverColors( sunken, hover, (scrollBar->activeSubControls & SC_ScrollBarSlider) && isEnabled, sliderColor, blendColor); - - QRect rc = scrollBar->rect; - if( horizontal ) - { - painter->fillRect( rc.left(), rc.top() + 2, rc.width(), rc.height() - 4, sliderColor ); - } - else - { - painter->fillRect( rc.left() + 2, rc.top(), rc.width() - 4, rc.height(), sliderColor ); - } - } - break; - - default: - QProxyStyle::drawControl( element, option, painter, widget ); - break; - } -} - -*/ - void LmmsStyle::drawComplexControl( ComplexControl control, const QStyleOptionComplex * option, QPainter *painter, @@ -589,174 +327,6 @@ int LmmsStyle::pixelMetric( PixelMetric _metric, const QStyleOption * _option, } } -// QStyle::SH_TitleBar_NoBorder -/* -QSize LmmsStyle::sizeFromContents( ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget ) const -{ - if( type == CT_ScrollBar ) - { - if( const QStyleOptionSlider * scrollBar = qstyleoption_cast( option ) ) - { - int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, option, widget ); - int scrollBarSliderMinimum = pixelMetric( PM_ScrollBarSliderMin, option, widget ); - if( scrollBar->orientation == Qt::Horizontal ) - { - return QSize( BUTTON_LENGTH * 2 + scrollBarSliderMinimum, scrollBarExtent ); - } - else - { - return QSize( scrollBarExtent, BUTTON_LENGTH * 2 + scrollBarSliderMinimum ); - } - } - } - - return QProxyStyle::sizeFromContents( type, option, size, widget ); -} -*/ -/* -QRect LmmsStyle::subControlRect( ComplexControl control, const QStyleOptionComplex* option, SubControl subControl, const QWidget* widget ) const -{ - QRect rect = QProxyStyle::subControlRect( control, option, subControl, widget ); - - switch( control ) - { - case CC_ScrollBar: - if( const QStyleOptionSlider* scrollBar = qstyleoption_cast( option ) ) - { - int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, scrollBar, widget ); - int sliderMaxLength = ( - ( scrollBar->orientation == Qt::Horizontal ) ? - scrollBar->rect.width() : - scrollBar->rect.height() ) - - ( BUTTON_LENGTH * 2 + 6 ); - int sliderMinLength = pixelMetric( PM_ScrollBarSliderMin, scrollBar, widget ); - int sliderLength; - - // calculate slider length - if( scrollBar->maximum != scrollBar->minimum ) - { - uint valueRange = scrollBar->maximum - scrollBar->minimum; - sliderLength = ( scrollBar->pageStep * sliderMaxLength ) / - ( valueRange + scrollBar->pageStep ); - - if( sliderLength < sliderMinLength || valueRange > ( INT_MAX ) / 2 ) - { - sliderLength = sliderMinLength; - } - if( sliderLength > sliderMaxLength ) - { - sliderLength = sliderMaxLength; - } - } - else - { - sliderLength = sliderMaxLength; - } - - int sliderStart = BUTTON_LENGTH + 3 + sliderPositionFromValue( - scrollBar->minimum, - scrollBar->maximum, - scrollBar->sliderPosition, - sliderMaxLength - sliderLength, - scrollBar->upsideDown ); - - QRect scrollBarRect = scrollBar->rect; - - switch( subControl ) - { - case SC_ScrollBarSubLine: // top/left button - if( scrollBar->orientation == Qt::Horizontal ) - { - rect.setRect( scrollBarRect.left() + 2, scrollBarRect.top(), - BUTTON_LENGTH, scrollBarExtent ); - } - else - { - rect.setRect( scrollBarRect.left(), scrollBarRect.top() + 2, - scrollBarExtent, BUTTON_LENGTH ); - } - break; - - case SC_ScrollBarAddLine: // bottom/right button - if( scrollBar->orientation == Qt::Horizontal ) - { - rect.setRect( scrollBarRect.right() - 1 - BUTTON_LENGTH, - scrollBarRect.top(), BUTTON_LENGTH, scrollBarExtent ); - } - else - { - rect.setRect( scrollBarRect.left(), - scrollBarRect.bottom() - 1 - BUTTON_LENGTH, - scrollBarExtent, BUTTON_LENGTH ); - } - break; - - case SC_ScrollBarSubPage: - if( scrollBar->orientation == Qt::Horizontal ) - { - rect.setRect( scrollBarRect.left() + 2 + BUTTON_LENGTH, - scrollBarRect.top(), - sliderStart - ( scrollBarRect.left() + 2 + BUTTON_LENGTH ), - scrollBarExtent ); - } - else - { - rect.setRect( scrollBarRect.left(), - scrollBarRect.top() + 2 + BUTTON_LENGTH, scrollBarExtent, - sliderStart - ( scrollBarRect.left() + 2 + BUTTON_LENGTH ) ); - } - break; - - case SC_ScrollBarAddPage: - if( scrollBar->orientation == Qt::Horizontal ) - { - rect.setRect( sliderStart + sliderLength, 0, - sliderMaxLength - sliderStart - sliderLength, - scrollBarExtent ); - } - else - rect.setRect( 0, sliderStart + sliderLength, scrollBarExtent, - sliderMaxLength - sliderStart - sliderLength ); - break; - - case SC_ScrollBarGroove: - if( scrollBar->orientation == Qt::Horizontal ) - { - rect = scrollBarRect.adjusted( BUTTON_LENGTH, 0, -BUTTON_LENGTH, 0 ); - } - else - { - rect = scrollBarRect.adjusted( 0, BUTTON_LENGTH, 0, -BUTTON_LENGTH ); - } - break; - - case SC_ScrollBarSlider: - if( scrollBar->orientation == Qt::Horizontal ) - { - rect.setRect( sliderStart, 0, sliderLength, scrollBarExtent ); - } - else - { - rect.setRect( 0, sliderStart, scrollBarExtent, sliderLength ); - } - break; - - default: - break; - } - rect = visualRect( scrollBar->direction, scrollBarRect, rect ); - } - break; - - default: - break; - } - - return rect; -} -*/ - - QImage LmmsStyle::colorizeXpm( const char * const * xpm, const QBrush& fill ) const { From 79bbe72055bcaa31c11b389d38283c64c1cf11bb Mon Sep 17 00:00:00 2001 From: Vesa Date: Thu, 4 Dec 2014 18:48:58 +0200 Subject: [PATCH 04/13] Added 4th-order Linkwitz-Riley filter object to BasicFilters.h --- include/BasicFilters.h | 104 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/include/BasicFilters.h b/include/BasicFilters.h index 901fba802..75305ba27 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -45,9 +45,109 @@ #include "interpolation.h" #include "MemoryManager.h" -//#include -//#include template class BasicFilters; + +template +class LinkwitzRiley +{ + MM_OPERATORS +public: + LinkwitzRiley( float sampleRate ) + { + m_sampleRate = sampleRate; + clearHistory(); + } + virtual ~LinkwitzRiley() {} + + inline void clearHistory() + { + for( int i = 0; i < CHANNELS; ++i ) + { + m_x1[i] = m_x2[i] = m_x3[i] = m_x4[i] = 0.0f; + m_y1[i] = m_y2[i] = m_y3[i] = m_y4[i] = 0.0f; + } + } + + inline void setSampleRate( float sampleRate ) + { + m_sampleRate = sampleRate; + } + + inline void setCoeffs( float freq ) + { + // wc + const float wc = F_2PI * freq; + const float wc2 = wc * wc; + const float wc3 = wc2 * wc; + m_wc4 = wc2 * wc2; + + // k + const float k = wc / tanf( F_PI * freq / m_sampleRate ); + const float k2 = k * k; + const float k3 = k2 * k; + m_k4 = k2 * k2; + + // a + static const float sqrt2 = sqrtf( 2.0f ); + const float sq_tmp1 = sqrt2 * wc3 * k; + const float sq_tmp2 = sqrt2 * wc * k3; + m_a = 4.0f * wc2 * k2 + 2.0f * sq_tmp1 + m_k4 + 2.0f * sq_tmp2 + m_wc4; + + // b + m_b1 = ( 4.0f * ( m_wc4 + sq_tmp1 - m_k4 - sq_tmp2 ) ) / m_a; + m_b2 = ( 6.0f * m_wc4 - 8.0f * wc2 * k2 + 6.0f * m_k4 ) / m_a; + m_b3 = ( 4.0f * ( m_wc4 - sq_tmp1 + sq_tmp2 - m_k4 ) ) / m_a; + m_b4 = ( m_k4 - 2.0f * sq_tmp1 + m_wc4 - 2.0f * sq_tmp2 + 4.0f * wc2 * k2 ) / m_a; + } + + inline void setLowpass( float freq ) + { + setCoeffs( freq ); + m_a0 = m_wc4 / m_a; + m_a1 = 4.0f * m_a0; + m_a2 = 6.0f * m_a0; + } + + inline void setHighpass( float freq ) + { + setCoeffs( freq ); + m_a0 = m_k4 / m_a; + m_a1 = 4.0f * m_a0; + m_a2 = 6.0f * m_a0; + } + + inline float update( float in, ch_cnt_t ch ) + { + const float tmpy = m_a0 * in + m_a1 * m_x1[ch] + m_a2 * m_x2[ch] + + m_a1 * m_x3[ch] + m_a0 * m_x4[ch] - m_b1 * m_y1[ch] - + m_b2 * m_y2[ch] - m_b3 * m_y3[ch] - m_b4 * m_y4[ch]; + + m_x4[ch] = m_x3[ch]; + m_x3[ch] = m_x2[ch]; + m_x2[ch] = m_x1[ch]; + m_x1[ch] = in; + + m_y4[ch] = m_y3[ch]; + m_y3[ch] = m_y2[ch]; + m_y2[ch] = m_y1[ch]; + m_y1[ch] = tmpy; + + return tmpy; + } + +private: + float m_sampleRate; + float m_wc4; + float m_k4; + float m_a, m_a0, m_a1, m_a2; + float m_b1, m_b2, m_b3, m_b4; + + typedef float frame[CHANNELS]; + frame m_x1, m_x2, m_x3, m_x4; + frame m_y1, m_y2, m_y3, m_y4; +}; +typedef LinkwitzRiley<2> StereoLinkwitzRiley; + template class BiQuad { From dcd0e81d86bd548ea7e85ed1d4939c1c0bc37c5d Mon Sep 17 00:00:00 2001 From: Vesa Date: Thu, 4 Dec 2014 20:43:37 +0200 Subject: [PATCH 05/13] Transposed form of Linkwitz-Riley --- include/BasicFilters.h | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/include/BasicFilters.h b/include/BasicFilters.h index 75305ba27..cd4687ef0 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -63,8 +63,7 @@ public: { for( int i = 0; i < CHANNELS; ++i ) { - m_x1[i] = m_x2[i] = m_x3[i] = m_x4[i] = 0.0f; - m_y1[i] = m_y2[i] = m_y3[i] = m_y4[i] = 0.0f; + m_z1[i] = m_z2[i] = m_z3[i] = m_z4[i] = 0.0f; } } @@ -115,24 +114,19 @@ public: m_a1 = 4.0f * m_a0; m_a2 = 6.0f * m_a0; } - + inline float update( float in, ch_cnt_t ch ) { - const float tmpy = m_a0 * in + m_a1 * m_x1[ch] + m_a2 * m_x2[ch] + - m_a1 * m_x3[ch] + m_a0 * m_x4[ch] - m_b1 * m_y1[ch] - - m_b2 * m_y2[ch] - m_b3 * m_y3[ch] - m_b4 * m_y4[ch]; + const float a0in = m_a0 * in; + const float a1in = m_a1 * in; + const float out = m_z1[ch] + a0in; - m_x4[ch] = m_x3[ch]; - m_x3[ch] = m_x2[ch]; - m_x2[ch] = m_x1[ch]; - m_x1[ch] = in; + m_z1[ch] = a1in + m_z2[ch] - ( m_b1 * out ); + m_z2[ch] = ( m_a2 * in ) + m_z3[ch] - ( m_b2 * out ); + m_z3[ch] = a1in + m_z4[ch] - ( m_b3 * out ); + m_z4[ch] = a0in - ( m_b4 * out ); - m_y4[ch] = m_y3[ch]; - m_y3[ch] = m_y2[ch]; - m_y2[ch] = m_y1[ch]; - m_y1[ch] = tmpy; - - return tmpy; + return out; } private: @@ -143,8 +137,7 @@ private: float m_b1, m_b2, m_b3, m_b4; typedef float frame[CHANNELS]; - frame m_x1, m_x2, m_x3, m_x4; - frame m_y1, m_y2, m_y3, m_y4; + frame m_z1, m_z2, m_z3, m_z4; }; typedef LinkwitzRiley<2> StereoLinkwitzRiley; From 3b2316e2425d0dea73a72b47395113cf8f5a0ed7 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Thu, 4 Dec 2014 16:03:12 -0500 Subject: [PATCH 06/13] Removed vim-config comment from SampleBuffer.cpp. --- src/core/SampleBuffer.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index 6ab17741c..9b7b5fa00 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -1479,11 +1479,3 @@ SampleBuffer::handleState::~handleState() { src_delete( m_resamplingData ); } - - - - - - - -/* vim: set tw=0 noexpandtab: */ From 809cad1b62ccd8a7d9c8fe4cf0085067d9448e39 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Thu, 4 Dec 2014 16:03:21 -0500 Subject: [PATCH 07/13] Removed vim-config comment from main.cpp. --- src/core/main.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 14dce4091..08042ef89 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -542,6 +542,3 @@ int main( int argc, char * * argv ) return( ret ); } - - -/* vim: set tw=0 noexpandtab: */ From 2425366b582b5da91df820cfe891255e46a1b5c1 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Thu, 4 Dec 2014 16:03:35 -0500 Subject: [PATCH 08/13] Removed vim-config comment from ExportProjectDialog.cpp. --- src/gui/ExportProjectDialog.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gui/ExportProjectDialog.cpp b/src/gui/ExportProjectDialog.cpp index 2133729fb..7241216b6 100644 --- a/src/gui/ExportProjectDialog.cpp +++ b/src/gui/ExportProjectDialog.cpp @@ -340,10 +340,3 @@ void ExportProjectDialog::updateTitleBar( int _prog ) Engine::mainWindow()->setWindowTitle( tr( "Rendering: %1%" ).arg( _prog ) ); } - - - - - - -/* vim: set tw=0 noexpandtab: */ From 63b353e07c739813d906a4ace282c32728210e34 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Thu, 4 Dec 2014 16:03:45 -0500 Subject: [PATCH 09/13] Removed vim-config comment from SongEditor.cpp. --- src/gui/SongEditor.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index 24d00d922..bb477be56 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -790,11 +790,3 @@ bool SongEditor::allowRubberband() const { return( m_editModeButton->isChecked() ); } - - - - - - - -/* vim: set tw=0 noexpandtab: */ From 5675b1a373e7f2e6d80afc6b5e9bd469a93f809a Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Thu, 4 Dec 2014 23:39:53 -0500 Subject: [PATCH 10/13] Removing focus from hidden windows upon hiding them. --- src/gui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 86a4ea65d..8a721c950 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -879,6 +879,7 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow ) else { parent->hide(); + this->setFocus(); } // Workaround for Qt Bug #260116 From 4ec1920b79ff0f255f8fa4c254db1f978593f6f3 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Fri, 5 Dec 2014 20:05:37 -0500 Subject: [PATCH 11/13] Setting dialog titles in Title Case. --- src/gui/MainWindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 86a4ea65d..6e5875222 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -99,24 +99,24 @@ MainWindow::MainWindow() : ConfigManager::inst()->userProjectsDir() + "*" + ConfigManager::inst()->factoryProjectsDir(), "*.mmp *.mmpz *.xml *.mid *.flp", - tr( "My projects" ), + tr( "My Projects" ), embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ), splitter ) ); sideBar->appendTab( new FileBrowser( ConfigManager::inst()->userSamplesDir() + "*" + ConfigManager::inst()->factorySamplesDir(), - "*", tr( "My samples" ), + "*", tr( "My Samples" ), embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ), splitter ) ); sideBar->appendTab( new FileBrowser( ConfigManager::inst()->userPresetsDir() + "*" + ConfigManager::inst()->factoryPresetsDir(), "*.xpf *.cs.xml *.xiz", - tr( "My presets" ), + tr( "My Presets" ), embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ), splitter ) ); sideBar->appendTab( new FileBrowser( QDir::homePath(), "*", - tr( "My home" ), + tr( "My Home" ), embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ), splitter ) ); @@ -132,11 +132,11 @@ MainWindow::MainWindow() : #endif sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", #ifdef LMMS_BUILD_WIN32 - tr( "My computer" ), + tr( "My Computer" ), #elif defined(LMMS_BUILD_APPLE) tr( "Volumes" ), #else - tr( "Root directory" ), + tr( "Root Directory" ), #endif embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ), @@ -721,7 +721,7 @@ void MainWindow::openProject() { if( mayChangeProject() ) { - FileDialog ofd( this, tr( "Open project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) ); + FileDialog ofd( this, tr( "Open Project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) ); ofd.setDirectory( ConfigManager::inst()->userProjectsDir() ); ofd.setFileMode( FileDialog::ExistingFiles ); @@ -786,7 +786,7 @@ bool MainWindow::saveProject() bool MainWindow::saveProjectAs() { - VersionedSaveDialog sfd( this, tr( "Save project" ), "", + VersionedSaveDialog sfd( this, tr( "Save Project" ), "", tr( "LMMS Project (*.mmpz *.mmp);;" "LMMS Project Template (*.mpt)" ) ); QString f = Engine::getSong()->projectFileName(); From 38b3279cf0bd2266063790a93b4a2f9eabbe78b7 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Fri, 5 Dec 2014 20:40:22 -0500 Subject: [PATCH 12/13] Setting menu titles in Title Case. --- src/gui/MainWindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 6e5875222..9566ec110 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -245,7 +245,7 @@ void MainWindow::finalize() m_recentlyOpenedProjectsMenu = project_menu->addMenu( embed::getIconPixmap( "project_open_recent" ), - tr( "&Recently opened projects" ) ); + tr( "&Recently Opened Projects" ) ); connect( m_recentlyOpenedProjectsMenu, SIGNAL( aboutToShow() ), this, SLOT( updateRecentlyOpenedProjectsMenu() ) ); connect( m_recentlyOpenedProjectsMenu, SIGNAL( triggered( QAction * ) ), @@ -257,7 +257,7 @@ void MainWindow::finalize() Qt::CTRL + Qt::Key_S ); project_menu->addAction( embed::getIconPixmap( "project_save" ), - tr( "Save as new &version" ), + tr( "Save as New &Version" ), this, SLOT( saveProjectAsNewVersion() ), Qt::CTRL + Qt::ALT + Qt::Key_S ); project_menu->addAction( embed::getIconPixmap( "project_saveas" ), @@ -275,7 +275,7 @@ void MainWindow::finalize() SLOT( exportProject() ), Qt::CTRL + Qt::Key_E ); project_menu->addAction( embed::getIconPixmap( "project_export" ), - tr( "E&xport tracks..." ), + tr( "E&xport Tracks..." ), Engine::getSong(), SLOT( exportProjectTracks() ), Qt::CTRL + Qt::SHIFT + Qt::Key_E ); @@ -331,7 +331,7 @@ void MainWindow::finalize() if( true ) { help_menu->addAction( embed::getIconPixmap( "help" ), - tr( "Online help" ), + tr( "Online Help" ), this, SLOT( browseHelp() ) ); } else @@ -341,7 +341,7 @@ void MainWindow::finalize() this, SLOT( help() ) ); } help_menu->addAction( embed::getIconPixmap( "whatsthis" ), - tr( "What's this?" ), + tr( "What's This?" ), this, SLOT( enterWhatsThisMode() ) ); help_menu->addSeparator(); From ca973b9369849d23ba939e7fc746d20e71c72385 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Sat, 6 Dec 2014 03:46:41 -0500 Subject: [PATCH 13/13] Upon toggling off a window, now attempting to focus SongEditor, then any other visible editors, or finally the parent window if all editors are hidden. --- include/MainWindow.h | 1 + src/gui/MainWindow.cpp | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/MainWindow.h b/include/MainWindow.h index a8aae83c5..9fd9acecd 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -145,6 +145,7 @@ private: void finalize(); void toggleWindow( QWidget *window, bool forceShow = false ); + void refocus(); QMdiArea * m_workspace; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 8a721c950..fc7d12d2b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -879,7 +879,7 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow ) else { parent->hide(); - this->setFocus(); + refocus(); } // Workaround for Qt Bug #260116 @@ -892,6 +892,38 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow ) +/* + * When an editor window with focus is toggled off, attempt to set focus + * to the next visible editor window, or if none are visible, set focus + * to the parent window. + */ +void MainWindow::refocus() +{ + QList editors; + editors + << Engine::songEditor()->parentWidget() + << Engine::getBBEditor()->parentWidget() + << Engine::pianoRoll()->parentWidget() + << Engine::automationEditor()->parentWidget(); + + bool found = false; + QList::Iterator editor; + for( editor = editors.begin(); editor != editors.end(); ++editor ) + { + if( ! (*editor)->isHidden() ) { + (*editor)->setFocus(); + found = true; + break; + } + } + + if( ! found ) + this->setFocus(); +} + + + + void MainWindow::toggleBBEditorWin( bool forceShow ) { toggleWindow( Engine::getBBEditor(), forceShow );