From 2ecc8bb4fafd112cbe9205b5c78ba969646400c9 Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Tue, 7 Aug 2018 15:26:58 -0400 Subject: [PATCH 1/4] Add CMake 2 support (#4530) Partially reverts d599955 --- cmake/modules/MinGWCrossCompile.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/MinGWCrossCompile.cmake b/cmake/modules/MinGWCrossCompile.cmake index 50ea72900..90dd7c607 100644 --- a/cmake/modules/MinGWCrossCompile.cmake +++ b/cmake/modules/MinGWCrossCompile.cmake @@ -51,6 +51,10 @@ ELSE() SET(STRIP ${MINGW_TOOL_PREFIX}strip) SET(WINDRES ${MINGW_TOOL_PREFIX}windres) SET(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config) + IF(CMAKE_VERSION LESS 3) + SET(PKG_CONFIG_EXECUTABLE $ENV{PKG_CONFIG}) + SET(PKG_CONFIG_FOUND TRUE) + ENDIF() # Search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) From 0cddc469bca910ad4b3e1fffdb9b798ebde27632 Mon Sep 17 00:00:00 2001 From: Ivo Wetzel Date: Thu, 16 Aug 2018 05:05:50 +0200 Subject: [PATCH 2/4] Fix Freeboy noise channel playback (#4538) Writing the enable bit to `FF23` causes the noise oscillator to start outputting samples and writing the other registers (including the one for the SRW value) during the time the oscillator is active has undefined behaviour. In order for `GB_apu` to correctly generate samples when the LSFR width is set to `7`, the trigger write to `0xff23` must happen after all other writes. --- plugins/papu/papu_instrument.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/papu/papu_instrument.cpp b/plugins/papu/papu_instrument.cpp index b555310a0..b9c1b28ae 100644 --- a/plugins/papu/papu_instrument.cpp +++ b/plugins/papu/papu_instrument.cpp @@ -276,9 +276,6 @@ void papuInstrument::playNote( NotePlayHandle * _n, data += m_ch4SweepStepLengthModel.value(); papu->write_register( 0xff21, data ); - //channel 4 init - papu->write_register( 0xff23, 128 ); - _n->m_pluginData = papu; } @@ -380,6 +377,10 @@ void papuInstrument::playNote( NotePlayHandle * _n, data = data << 3; data += ropt; papu->write_register( 0xff22, data ); + + //channel 4 init + papu->write_register( 0xff23, 128 ); + } int const buf_size = 2048; From 160488c0963f67b13013dc6e198b2f7d42530c64 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Mon, 30 Jul 2018 20:00:08 +0200 Subject: [PATCH 3/4] Make the oscilloscope colors available as properties Make the oscilloscope colors available as properties so that they can be changed via style sheets. Adjust the existing styles to use the colors that have been hard coded previously. Cleanup the paintEvent method of VisualizationWidget, e.g. by extracting a method to determine the color to use for the line and by pulling variables to the place where they are used. Fix some Clang warnings. --- data/themes/classic/style.css | 3 + data/themes/default/style.css | 3 + include/VisualizationWidget.h | 17 +++++ src/gui/widgets/VisualizationWidget.cpp | 89 +++++++++++++++++-------- 4 files changed, 83 insertions(+), 29 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 55f82e4b3..112d8f05c 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -157,6 +157,9 @@ GroupBox { VisualizationWidget { background: none; border: none; + qproperty-normalColor: rgb(71, 253, 133); + qproperty-warningColor: rgb(255, 192, 64); + qproperty-clippingColor: rgb(255, 64, 64); } /* main toolbar cpu load widget - this can have transparent bg now */ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 8493abbf3..cd74c349d 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -176,6 +176,9 @@ GroupBox { VisualizationWidget { background: none; border: none; + qproperty-normalColor: rgb(71, 253, 133); + qproperty-warningColor: rgb(255, 192, 64); + qproperty-clippingColor: rgb(255, 64, 64); } /* main toolbar cpu load widget - this can have transparent bg now */ diff --git a/include/VisualizationWidget.h b/include/VisualizationWidget.h index 4d73f052d..a178b1ad8 100644 --- a/include/VisualizationWidget.h +++ b/include/VisualizationWidget.h @@ -36,6 +36,9 @@ class VisualizationWidget : public QWidget { Q_OBJECT public: + Q_PROPERTY( QColor normalColor READ normalColor WRITE setNormalColor ) + Q_PROPERTY( QColor warningColor READ warningColor WRITE setWarningColor ) + Q_PROPERTY( QColor clippingColor READ clippingColor WRITE setClippingColor ) enum visualizationTypes { Simple // add more here @@ -47,6 +50,15 @@ public: void setActive( bool _active ); + QColor const & normalColor() const; + void setNormalColor(QColor const & normalColor); + + QColor const & warningColor() const; + void setWarningColor(QColor const & warningColor); + + QColor const & clippingColor() const; + void setClippingColor(QColor const & clippingColor); + protected: virtual void paintEvent( QPaintEvent * _pe ); @@ -56,6 +68,8 @@ protected: protected slots: void updateAudioBuffer( const surroundSampleFrame * buffer ); +private: + QColor const & determineLineColor(float level) const; private: QPixmap s_background; @@ -64,6 +78,9 @@ private: sampleFrame * m_buffer; bool m_active; + QColor m_normalColor; + QColor m_warningColor; + QColor m_clippingColor; } ; #endif diff --git a/src/gui/widgets/VisualizationWidget.cpp b/src/gui/widgets/VisualizationWidget.cpp index 1fd4e4c00..3b484ca0a 100644 --- a/src/gui/widgets/VisualizationWidget.cpp +++ b/src/gui/widgets/VisualizationWidget.cpp @@ -43,7 +43,10 @@ VisualizationWidget::VisualizationWidget( const QPixmap & _bg, QWidget * _p, QWidget( _p ), s_background( _bg ), m_points( new QPointF[Engine::mixer()->framesPerPeriod()] ), - m_active( false ) + m_active( false ), + m_normalColor(71, 253, 133), + m_warningColor(255, 192, 64), + m_clippingColor(255, 64, 64) { setFixedSize( s_background.width(), s_background.height() ); setAttribute( Qt::WA_OpaquePaintEvent, true ); @@ -110,6 +113,35 @@ void VisualizationWidget::setActive( bool _active ) } +QColor const & VisualizationWidget::normalColor() const +{ + return m_normalColor; +} + +void VisualizationWidget::setNormalColor(QColor const & normalColor) +{ + m_normalColor = normalColor; +} + +QColor const & VisualizationWidget::warningColor() const +{ + return m_warningColor; +} + +void VisualizationWidget::setWarningColor(QColor const & warningColor) +{ + m_warningColor = warningColor; +} + +QColor const & VisualizationWidget::clippingColor() const +{ + return m_clippingColor; +} + +void VisualizationWidget::setClippingColor(QColor const & clippingColor) +{ + m_clippingColor = clippingColor; +} void VisualizationWidget::paintEvent( QPaintEvent * ) @@ -123,13 +155,6 @@ void VisualizationWidget::paintEvent( QPaintEvent * ) Mixer const * mixer = Engine::mixer(); float master_output = mixer->masterGain(); - int w = width()-4; - const float half_h = -( height() - 6 ) / 3.0 * master_output - 1; - int x_base = 2; - const float y_base = height()/2 - 0.5f; - -// p.setClipRect( 2, 2, w, height()-4 ); - const fpp_t frames = mixer->framesPerPeriod(); float peakLeft; @@ -137,35 +162,27 @@ void VisualizationWidget::paintEvent( QPaintEvent * ) mixer->getPeakValues( m_buffer, frames, peakLeft, peakRight ); const float max_level = qMax( peakLeft, peakRight ); - // and set color according to that... - if( max_level * master_output < 0.9 ) - { - p.setPen( QColor( 71, 253, 133 ) ); - } - else if( max_level * master_output < 1.0 ) - { - p.setPen( QColor( 255, 192, 64 ) ); - } - else - { - p.setPen( QColor( 255, 64, 64 ) ); - } + // Set the color of the line according to the maximum level + float const maxLevelWithAppliedMasterGain = max_level * master_output; + p.setPen(QPen(determineLineColor(maxLevelWithAppliedMasterGain), 0.7)); - p.setPen( QPen( p.pen().color(), 0.7 ) ); - - const float xd = (float) w / frames; p.setRenderHint( QPainter::Antialiasing ); // now draw all that stuff + int w = width() - 4; + const qreal xd = static_cast(w) / frames; + const qreal half_h = -( height() - 6 ) / 3.0 * static_cast(master_output) - 1; + int x_base = 2; + const qreal y_base = height() / 2 - 0.5; + for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) { for( int frame = 0; frame < frames; ++frame ) { + sample_t const clippedSample = Mixer::clip(m_buffer[frame][ch]); m_points[frame] = QPointF( - x_base + (float) frame * xd, - y_base + ( Mixer::clip( - m_buffer[frame][ch] ) * - half_h ) ); + x_base + static_cast(frame) * xd, + y_base + ( static_cast(clippedSample) * half_h ) ); } p.drawPolyline( m_points, frames ); } @@ -190,7 +207,21 @@ void VisualizationWidget::mousePressEvent( QMouseEvent * _me ) } - +QColor const & VisualizationWidget::determineLineColor(float level) const +{ + if( level < 0.9f ) + { + return normalColor(); + } + else if( level < 1.0f ) + { + return warningColor(); + } + else + { + return clippingColor(); + } +} From 7f541a544e34790fd23c52de3afdac0b73124386 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Wed, 22 Aug 2018 20:17:56 +0900 Subject: [PATCH 4/4] Don't try to clear null buffer in NotePlayHandle::play (#4545) This is a workaround for rare crashes when changing the tempo while playing notes with stacking and/or arpeggio. When playing the master note, _working_buffer is null. Tempo change causes false positive in the check because NotePlayHandle::resize changes m_totalFramesPlayed. Thanks to 6fc4577f102e5bb60cc246a426fb9ed8b4ac3be9, we can safely drop the memset call. --- src/core/NotePlayHandle.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 11f71d8f1..9dd29fe32 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -238,13 +238,6 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) // decreasing release of an instrument-track while the note is active if( framesLeft() > 0 ) { - // clear offset frames if we're at the first period - // skip for single-streamed instruments, because in their case NPH::play() could be called from an IPH without a buffer argument - // ... also, they don't actually render the sound in NPH's, which is an even better reason to skip... - if( m_totalFramesPlayed == 0 && ! ( m_instrumentTrack->instrument()->flags() & Instrument::IsSingleStreamed ) ) - { - memset( _working_buffer, 0, sizeof( sampleFrame ) * offset() ); - } // play note! m_instrumentTrack->playNote( this, _working_buffer ); }