From cee287116bfe1fc183addc15d403c2520d72206a Mon Sep 17 00:00:00 2001 From: Dave French Date: Fri, 26 Dec 2014 11:00:26 +0000 Subject: [PATCH 01/22] Proposed fix for 1150 Preset Browser: division between factory and user files fails if factory has folders --- include/FileBrowser.h | 2 ++ src/gui/FileBrowser.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 97e20f4bc..4f9b78c48 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -161,6 +161,8 @@ private: QStringList m_directories; QString m_filter; + int m_dirCount; + } ; diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index ac84e404a..7a7780a44 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -708,7 +708,8 @@ Directory::Directory(const QString & filename, const QString & path, const QString & filter ) : QTreeWidgetItem( QStringList( filename ), TypeDirectoryItem ), m_directories( path ), - m_filter( filter ) + m_filter( filter ), + m_dirCount( 0 ) { initPixmaps(); @@ -762,6 +763,7 @@ void Directory::update( void ) setIcon( 0, *s_folderOpenedPixmap ); if( !childCount() ) { + m_dirCount = 0; for( QStringList::iterator it = m_directories.begin(); it != m_directories.end(); ++it ) { @@ -776,7 +778,7 @@ void Directory::update( void ) "--- Factory files ---" ) ); sep->setIcon( 0, embed::getIconPixmap( "factory_files" ) ); - insertChild( top_index, sep ); + insertChild( m_dirCount + top_index - 1, sep ); } } } @@ -814,6 +816,7 @@ bool Directory::addItems(const QString & path ) insertChild( i, new Directory( cur_file, path, m_filter ) ); orphan = false; + m_dirCount++; break; } else if( cur_file == d->text( 0 ) ) @@ -827,6 +830,7 @@ bool Directory::addItems(const QString & path ) { addChild( new Directory( cur_file, path, m_filter ) ); + m_dirCount++; } added_something = true; From 2818bd736a8ec6e7d5a609e5694cc5dc2c8686fd Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Mon, 5 Jan 2015 17:40:14 +0200 Subject: [PATCH 02/22] Looks like locking the mutex in SF2 player is needed around a few more operations than before, at least while importing MIDI. Should fix #1544 --- plugins/sf2_player/sf2_player.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 91d9d6e8f..f2acd2f07 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -649,14 +649,19 @@ void sf2Instrument::play( sampleFrame * _working_buffer ) if( m_lastMidiPitch != currentMidiPitch ) { m_lastMidiPitch = currentMidiPitch; + m_synthMutex.lock(); fluid_synth_pitch_bend( m_synth, m_channel, m_lastMidiPitch ); + m_synthMutex.unlock(); + } const int currentMidiPitchRange = instrumentTrack()->midiPitchRange(); if( m_lastMidiPitchRange != currentMidiPitchRange ) { m_lastMidiPitchRange = currentMidiPitchRange; + m_synthMutex.lock(); fluid_synth_pitch_wheel_sens( m_synth, m_channel, m_lastMidiPitchRange ); + m_synthMutex.unlock(); } // if we have no new noteons/noteoffs, just render a period and call it a day if( m_playingNotes.isEmpty() ) From 7588f235ee158f782bf3f687bce53dc9ad079d95 Mon Sep 17 00:00:00 2001 From: Dave French Date: Mon, 5 Jan 2015 18:39:44 +0000 Subject: [PATCH 03/22] Proposed fix for 1352 Mk2, move the loaded instrument to the parent thread --- include/TrackContainerView.h | 14 ++++++++++++++ src/gui/TrackContainerView.cpp | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index 7e9dee437..3431289b1 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -33,6 +33,7 @@ #include "Track.h" #include "JournallingObject.h" +#include "InstrumentTrack.h" class QVBoxLayout; @@ -182,6 +183,19 @@ signals: } ; +class InstrumentLoaderThread : public QThread +{ + Q_OBJECT +public: + InstrumentLoaderThread( QObject *parent = 0, InstrumentTrack *it = 0, + QString name = "" ); + void run(); + +private: + InstrumentTrack *m_it; + QString m_name; + QThread *m_containerThread; +}; #endif diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index 94c72d278..a2d3ce12b 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -325,7 +325,9 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) InstrumentTrack * it = dynamic_cast( Track::create( Track::InstrumentTrack, m_tc ) ); - it->loadInstrument( value ); + InstrumentLoaderThread *ilt = new InstrumentLoaderThread( + this, it, value ); + ilt->start(); //it->toggledInstrumentTrackButton( true ); _de->accept(); } @@ -453,6 +455,22 @@ void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we ) +InstrumentLoaderThread::InstrumentLoaderThread( QObject *parent, InstrumentTrack *it, QString name ) : + QThread( parent ), + m_it( it ), + m_name( name ) +{ + m_containerThread = thread(); +} + +void InstrumentLoaderThread::run() +{ + Instrument *i = m_it->loadInstrument( m_name ); + QObject *parent = i->parent(); + i->setParent( 0 ); + i->moveToThread( m_containerThread ); + i->setParent( parent ); +} From 3c44012defec2ece54209251bf7970e46f9d091e Mon Sep 17 00:00:00 2001 From: Dave French Date: Mon, 5 Jan 2015 21:41:48 +0000 Subject: [PATCH 04/22] Proposed fix for 1522 Noise at the end of Sample previews --- src/core/SamplePlayHandle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index a881a5f8e..1bcf6691e 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -98,14 +98,15 @@ SamplePlayHandle::~SamplePlayHandle() void SamplePlayHandle::play( sampleFrame * buffer ) { + const fpp_t fpp = Engine::mixer()->framesPerPeriod(); //play( 0, _try_parallelizing ); if( framesDone() >= totalFrames() ) { + memset( buffer, 0, sizeof( sampleFrame ) * fpp ); return; } sampleFrame * workingBuffer = buffer; - const fpp_t fpp = Engine::mixer()->framesPerPeriod(); f_cnt_t frames = fpp; // apply offset for the first period From 74407945978ec57a0b1c74a4eceaa866c2c19540 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Tue, 6 Jan 2015 18:18:16 +0100 Subject: [PATCH 05/22] Don't display resize cursor for non-resizable TCOs --- include/Track.h | 13 +++++++++++-- include/TrackContainer.h | 17 +++++++++++++++++ src/core/AutomationPattern.cpp | 23 +++++++++++++++++++++++ src/core/BBTrackContainer.cpp | 1 + src/core/Song.cpp | 1 + src/core/Track.cpp | 18 ++---------------- src/gui/AutomationPatternView.cpp | 1 - src/tracks/BBTrack.cpp | 1 + src/tracks/Pattern.cpp | 12 +++++++++++- src/tracks/SampleTrack.cpp | 10 ++++++++++ 10 files changed, 77 insertions(+), 20 deletions(-) diff --git a/include/Track.h b/include/Track.h index 800524a9e..d09b955fc 100644 --- a/include/Track.h +++ b/include/Track.h @@ -121,6 +121,16 @@ public: return m_length; } + inline void setAutoResize( const bool _r ) + { + m_autoResize = _r; + } + + inline const bool getAutoResize() const + { + return m_autoResize; + } + virtual void movePosition( const MidiTime & _pos ); virtual void changeLength( const MidiTime & _length ); @@ -165,6 +175,7 @@ private: BoolModel m_mutedModel; BoolModel m_soloModel; + bool m_autoResize; bool m_selectViewOnCreate; @@ -216,7 +227,6 @@ protected: virtual void mouseMoveEvent( QMouseEvent * _me ); virtual void mouseReleaseEvent( QMouseEvent * _me ); - void setAutoResizeEnabled( bool _e = false ); float pixelsPerTact(); inline TrackView * getTrackView() @@ -248,7 +258,6 @@ private: TrackContentObject * m_tco; TrackView * m_trackView; Actions m_action; - bool m_autoResize; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; diff --git a/include/TrackContainer.h b/include/TrackContainer.h index d932f32dd..2e31e0814 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -42,6 +42,11 @@ class EXPORT TrackContainer : public Model, public JournallingObject Q_OBJECT public: typedef QVector TrackList; + enum TrackContainerTypes + { + BBContainer, + SongContainer + } ; TrackContainer(); virtual ~TrackContainer(); @@ -78,6 +83,16 @@ public: return "trackcontainer"; } + inline void setType( TrackContainerTypes newType ) + { + m_TrackContainerType = newType; + } + + inline TrackContainerTypes type() const + { + return m_TrackContainerType; + } + signals: void trackAdded( Track * _track ); @@ -88,6 +103,8 @@ protected: private: TrackList m_tracks; + TrackContainerTypes m_TrackContainerType; + friend class TrackContainerView; friend class Track; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 02566b65c..714906058 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -54,6 +54,19 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : m_lastRecordedValue( 0 ) { changeLength( MidiTime( 1, 0 ) ); + if( getTrack() ) + { + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + setAutoResize( false ); + break; + } + } } @@ -72,6 +85,16 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : m_timeMap[it.key()] = it.value(); m_tangents[it.key()] = _pat_to_copy.m_tangents[it.key()]; } + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + setAutoResize( false ); + break; + } } diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp index 7bf59f1d7..839e40994 100644 --- a/src/core/BBTrackContainer.cpp +++ b/src/core/BBTrackContainer.cpp @@ -42,6 +42,7 @@ BBTrackContainer::BBTrackContainer() : // not change upon setCurrentBB()-call connect( &m_bbComboBoxModel, SIGNAL( dataUnchanged() ), this, SLOT( currentBBChanged() ) ); + setType( BBContainer ); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index e15533cdf..c4cc905d8 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -114,6 +114,7 @@ Song::Song() : this, SLOT( masterPitchChanged() ) );*/ qRegisterMetaType( "note" ); + setType( SongContainer ); } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 5acbb6477..486667b14 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -248,7 +248,6 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * _tco, m_tco( _tco ), m_trackView( _tv ), m_action( NoAction ), - m_autoResize( false ), m_initialMousePos( QPoint( 0, 0 ) ), m_initialMouseGlobalPos( QPoint( 0, 0 ) ), m_hint( NULL ), @@ -656,7 +655,7 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * _me ) "a copy." ), embed::getIconPixmap( "hint" ), 0 ); } - else if( m_autoResize == false ) + else if( !m_tco->getAutoResize() ) { m_action = Resize; m_oldTime = m_tco->length(); @@ -846,7 +845,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) } else { - if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() ) + if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() && !m_tco->getAutoResize() ) { if( QApplication::overrideCursor() != NULL && QApplication::overrideCursor()->shape() != @@ -957,19 +956,6 @@ float TrackContentObjectView::pixelsPerTact() -/*! \brief Set whether this trackContentObjectView can resize. - * - * \param _e The boolean state of whether this track content object view - * is allowed to resize. - */ -void TrackContentObjectView::setAutoResizeEnabled( bool _e ) -{ - m_autoResize = _e; -} - - - - /*! \brief Detect whether the mouse moved more than n pixels on screen. * * \param _me The QMouseEvent. diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 1c404e6ef..3792724ce 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -54,7 +54,6 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, setAttribute( Qt::WA_OpaquePaintEvent, true ); setFixedHeight( parentWidget()->height() - 2 ); - setAutoResizeEnabled( false ); ToolTip::add( this, tr( "double-click to open this pattern in " "automation editor" ) ); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 5a76d56a0..50d57bef6 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -58,6 +58,7 @@ BBTCO::BBTCO( Track * _track ) : changeLength( MidiTime( t, 0 ) ); restoreJournallingState(); } + setAutoResize( false ); } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 727fbd948..de76f7761 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -66,6 +66,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) : { setName( _instrument_track->name() ); init(); + setAutoResize( true ); } @@ -83,6 +84,16 @@ Pattern::Pattern( const Pattern& other ) : } init(); + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + setAutoResize( false ); + break; + } } @@ -635,7 +646,6 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : } setFixedHeight( parentWidget()->height() - 2 ); - setAutoResizeEnabled( false ); ToolTip::add( this, tr( "double-click to open this pattern in piano-roll\n" diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 891790af2..633f41c69 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -62,6 +62,16 @@ SampleTCO::SampleTCO( Track * _track ) : // change length of this TCO connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), this, SLOT( updateLength( bpm_t ) ) ); + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + setAutoResize( false ); + break; + } } From 01fac0d342512fb0b21e864ee74a509d2359ff7a Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Tue, 6 Jan 2015 18:50:51 +0100 Subject: [PATCH 06/22] Add default behaviour to switch --- src/core/AutomationPattern.cpp | 4 ++++ src/tracks/Pattern.cpp | 2 ++ src/tracks/SampleTrack.cpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 714906058..fb3cace93 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -63,6 +63,8 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : break; case TrackContainer::SongContainer: + // move down + default: setAutoResize( false ); break; } @@ -92,6 +94,8 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : break; case TrackContainer::SongContainer: + // move down + default: setAutoResize( false ); break; } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index de76f7761..280d24036 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -91,6 +91,8 @@ Pattern::Pattern( const Pattern& other ) : break; case TrackContainer::SongContainer: + // move down + default: setAutoResize( false ); break; } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 633f41c69..b438b985a 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -69,6 +69,8 @@ SampleTCO::SampleTCO( Track * _track ) : break; case TrackContainer::SongContainer: + // move down + default: setAutoResize( false ); break; } From c0fc56eaea272a37bc82ef81fd97cc7d49bd7db5 Mon Sep 17 00:00:00 2001 From: Dave French Date: Wed, 7 Jan 2015 20:08:18 +0000 Subject: [PATCH 07/22] Proposed fix 888 Bar, Beat and Tick should follow dragged timeline --- src/gui/widgets/TimeDisplayWidget.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index d2afe9240..01b447d92 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -106,12 +106,13 @@ void TimeDisplayWidget::updateTime() break; case BarsTicks: - m_majorLCD.setValue( s->getTacts() + 1 ); - m_minorLCD.setValue( ( s->getTicks() % s->ticksPerTact() ) / - ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); -; - m_milliSecondsLCD.setValue( ( s->getTicks() % s->ticksPerTact() ) % - ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) ); + int tick; + tick = ( s->getMilliseconds() * s->getTempo() * 48 ) / 60000 ; + m_majorLCD.setValue( (int)(tick / s->ticksPerTact() ) + 1); + m_minorLCD.setValue( ( tick % s->ticksPerTact() ) / + ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); + m_milliSecondsLCD.setValue( ( tick % s->ticksPerTact() ) % + ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) ); break; default: break; From 7b3e4265b8ffe28820b460c5265b8c15f9af1918 Mon Sep 17 00:00:00 2001 From: Dave French Date: Thu, 8 Jan 2015 06:15:18 +0000 Subject: [PATCH 08/22] Proposed fix 1388 Remove auto-naming of copied blocks --- src/core/Track.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 5acbb6477..7ee6c1f59 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -1402,6 +1402,11 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * _de ) { tco->selectViewOnCreate( true ); } + //check tco name, if the same as source track name dont copy + if( tco->name() == tracks[trackIndex]->name() ) + { + tco->setName( "" ); + } } AutomationPattern::resolveAllIDs(); From 736c44ab8d6ef9cd7a3174a040f5b8dd0aba397e Mon Sep 17 00:00:00 2001 From: Dave French Date: Thu, 8 Jan 2015 08:37:07 +0000 Subject: [PATCH 09/22] 888 changed 48 to DefaultTicksPerTact/4 --- src/gui/widgets/TimeDisplayWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index 01b447d92..981af4b43 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -107,7 +107,7 @@ void TimeDisplayWidget::updateTime() case BarsTicks: int tick; - tick = ( s->getMilliseconds() * s->getTempo() * 48 ) / 60000 ; + tick = ( s->getMilliseconds() * s->getTempo() * (DefaultTicksPerTact / 4 ) ) / 60000 ; m_majorLCD.setValue( (int)(tick / s->ticksPerTact() ) + 1); m_minorLCD.setValue( ( tick % s->ticksPerTact() ) / ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); From 1dbc44a7f0dbf5f26f3ec2fedfa7dc2c3163594b Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Thu, 8 Jan 2015 14:37:10 -0200 Subject: [PATCH 10/22] Refactor redundant pattern color assignment Instead of creating a new QColor for each condition just use the `setRgb` method or fix the conditions order. --- src/gui/AutomationPatternView.cpp | 2 +- src/tracks/BBTrack.cpp | 15 ++++++++++----- src/tracks/Pattern.cpp | 9 ++++++--- src/tracks/SampleTrack.cpp | 6 +++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 7885905f7..1e96839f3 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -267,7 +267,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) if( isSelected() == true ) { - c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); + c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); } lingrad.setColorAt( 1, c.darker( 300 ) ); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 011e5e826..435fdb5b7 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -215,18 +215,23 @@ void BBTCOView::paintEvent( QPaintEvent * ) { QPainter p( this ); - QColor col = m_bbTCO->m_useStyleColor - ? p.pen().brush().color() - : m_bbTCO->colorObj(); - + QColor col; if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() ) { col = QColor( 160, 160, 160 ); } + else if ( m_bbTCO->m_useStyleColor ) + { + col = p.pen().brush().color(); + } + else + { + col = m_bbTCO->colorObj(); + } if( isSelected() == true ) { - col = QColor( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 ); + col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 ); } QLinearGradient lingrad( 0, 0, 0, height() ); diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index dc61aa6d7..b934733c5 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -904,16 +904,19 @@ void PatternView::paintEvent( QPaintEvent * ) QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; - if(( m_pat->m_patternType != Pattern::BeatPattern ) && - !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) + !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) + { c = styleColor; + } else + { c = QColor( 80, 80, 80 ); + } if( isSelected() == true ) { - c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); + c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); } if( m_pat->m_patternType != Pattern::BeatPattern ) diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 7e3be4f4c..9ef5f981c 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -340,13 +340,17 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe ) QColor c; if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) ) + { c = styleColor; + } else + { c = QColor( 80, 80, 80 ); + } if( isSelected() == true ) { - c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); + c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); } QLinearGradient grad( 0, 0, 0, height() ); From d5c9b78178c52897c56bed9a96bf8013414bc617 Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Thu, 8 Jan 2015 16:13:15 -0200 Subject: [PATCH 11/22] Collect error for non existing samples --- data/locale/ca.ts | 4 ++++ data/locale/cs.ts | 4 ++++ data/locale/de.ts | 4 ++++ data/locale/en.ts | 4 ++++ data/locale/es.ts | 4 ++++ data/locale/fa.ts | 4 ++++ data/locale/fr.ts | 4 ++++ data/locale/gl.ts | 4 ++++ data/locale/it.ts | 4 ++++ data/locale/ja.ts | 4 ++++ data/locale/ko.ts | 4 ++++ data/locale/nl.ts | 4 ++++ data/locale/pl.ts | 4 ++++ data/locale/pt.ts | 4 ++++ data/locale/ru.ts | 4 ++++ data/locale/sv.ts | 4 ++++ data/locale/zh.ts | 4 ++++ plugins/audio_file_processor/audio_file_processor.cpp | 8 ++++++++ 18 files changed, 76 insertions(+) diff --git a/data/locale/ca.ts b/data/locale/ca.ts index 4035efb53..9cd6ae404 100644 --- a/data/locale/ca.ts +++ b/data/locale/ca.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/cs.ts b/data/locale/cs.ts index 9b0a8e9fe..6aa7e566b 100644 --- a/data/locale/cs.ts +++ b/data/locale/cs.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/de.ts b/data/locale/de.ts index 167686614..c193d646f 100644 --- a/data/locale/de.ts +++ b/data/locale/de.ts @@ -203,6 +203,10 @@ Wenn Sie daran interessiert sind LMMS in eine andere Sprache zu übersetzen oder With this knob you can set the point where the loop starts. Mit diesem Regler können Sie festlegen, wo die Wiederholung beginnt. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/en.ts b/data/locale/en.ts index ad6b6829c..76e145ebc 100644 --- a/data/locale/en.ts +++ b/data/locale/en.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/es.ts b/data/locale/es.ts index 1c62562c5..bd89815ea 100644 --- a/data/locale/es.ts +++ b/data/locale/es.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/fa.ts b/data/locale/fa.ts index b8628bdff..e38e2d970 100644 --- a/data/locale/fa.ts +++ b/data/locale/fa.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/fr.ts b/data/locale/fr.ts index 730db5a5b..6dcf0a8b8 100644 --- a/data/locale/fr.ts +++ b/data/locale/fr.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/gl.ts b/data/locale/gl.ts index 061fac646..96b19ccd6 100644 --- a/data/locale/gl.ts +++ b/data/locale/gl.ts @@ -195,6 +195,10 @@ Se lle interesa traducir o LMMS a outro idioma ou desexa mellorar as traducións With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/it.ts b/data/locale/it.ts index ad6de8a1f..a046d158a 100644 --- a/data/locale/it.ts +++ b/data/locale/it.ts @@ -196,6 +196,10 @@ Se sei interessato a tradurre LMMS o vuoi migliorare una traduzione esistente, s With this knob you can set the point where the loop starts. Con questa modalità puoi impostare il punto dove la ripetizione comincia: la parte del suono tra il LoopBack e il punto di fine è quella che verà ripetuta. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/ja.ts b/data/locale/ja.ts index 43c8cf233..49f272525 100644 --- a/data/locale/ja.ts +++ b/data/locale/ja.ts @@ -195,6 +195,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/ko.ts b/data/locale/ko.ts index 76377dca3..aeee0b941 100644 --- a/data/locale/ko.ts +++ b/data/locale/ko.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/nl.ts b/data/locale/nl.ts index c2a8971b9..1b98f5417 100644 --- a/data/locale/nl.ts +++ b/data/locale/nl.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/pl.ts b/data/locale/pl.ts index fe28d3ce8..fec62d198 100644 --- a/data/locale/pl.ts +++ b/data/locale/pl.ts @@ -199,6 +199,10 @@ Zauważone błędy i propozycje zmian tłumaczenia proszę zgłaszać na e-mail: With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/pt.ts b/data/locale/pt.ts index 4e0724c46..defb1e561 100644 --- a/data/locale/pt.ts +++ b/data/locale/pt.ts @@ -197,6 +197,10 @@ Esteban Viveros With this knob you can set the point where the loop starts. + + Sample not found: %1 + Amostra não encontrada: %1 + AudioFileProcessorWaveView diff --git a/data/locale/ru.ts b/data/locale/ru.ts index 6acc4186a..ce01e3d40 100644 --- a/data/locale/ru.ts +++ b/data/locale/ru.ts @@ -197,6 +197,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/sv.ts b/data/locale/sv.ts index 80f960d76..c170ed0d4 100644 --- a/data/locale/sv.ts +++ b/data/locale/sv.ts @@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp With this knob you can set the point where the loop starts. + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/data/locale/zh.ts b/data/locale/zh.ts index a4993226a..d1df46aee 100644 --- a/data/locale/zh.ts +++ b/data/locale/zh.ts @@ -201,6 +201,10 @@ Jeff Bai,邮箱:jeffbaichina@gmail.com With this knob you can set the point where the loop starts. 调节此旋钮,以设置循环开始的地方。 + + Sample not found: %1 + + AudioFileProcessorWaveView diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index 570908d85..be7519179 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -234,6 +234,14 @@ void audioFileProcessor::loadSettings( const QDomElement & _this ) if( _this.attribute( "src" ) != "" ) { setAudioFile( _this.attribute( "src" ), false ); + + QString absolutePath = m_sampleBuffer.tryToMakeAbsolute( m_sampleBuffer.audioFile() ); + if ( !QFileInfo( absolutePath ).exists() ) + { + QString message = tr( "Sample not found: %1" ).arg( m_sampleBuffer.audioFile() ); + + Engine::getSong()->collectError( message ); + } } else if( _this.attribute( "sampledata" ) != "" ) { From fc9efc6f5862cb796a10d6c2b8df5952b4ca7e28 Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Thu, 8 Jan 2015 17:47:39 -0200 Subject: [PATCH 12/22] Fix error collection on Song instead of MainWindow --- plugins/audio_file_processor/audio_file_processor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index be7519179..08ef28857 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -34,6 +34,7 @@ #include "audio_file_processor.h" #include "Engine.h" #include "Song.h" +#include "MainWindow.h" #include "InstrumentTrack.h" #include "NotePlayHandle.h" #include "interpolation.h" @@ -240,7 +241,7 @@ void audioFileProcessor::loadSettings( const QDomElement & _this ) { QString message = tr( "Sample not found: %1" ).arg( m_sampleBuffer.audioFile() ); - Engine::getSong()->collectError( message ); + Engine::mainWindow()->collectError( message ); } } else if( _this.attribute( "sampledata" ) != "" ) From d20e83e2f7356ae5376b6479e456a0bf86c2cb89 Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Fri, 9 Jan 2015 04:15:20 -0200 Subject: [PATCH 13/22] Fix exporting class for windows build --- include/MainWindow.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/MainWindow.h b/include/MainWindow.h index 9fd9acecd..f82a5db02 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -30,6 +30,8 @@ #include #include +#include "export.h" + class QAction; class QDomElement; class QGridLayout; @@ -40,7 +42,7 @@ class PluginView; class ToolButton; -class MainWindow : public QMainWindow +class EXPORT MainWindow : public QMainWindow { Q_OBJECT public: From 4a55e1c46a4c1599c5ed12a730bed532f83284b6 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Fri, 9 Jan 2015 20:17:07 +0100 Subject: [PATCH 14/22] Performance and other fixes --- include/MainWindow.h | 4 ++-- include/PlayHandle.h | 2 ++ plugins/LadspaEffect/LadspaControlDialog.cpp | 2 +- plugins/LadspaEffect/calf/src/organ.cpp | 2 +- plugins/LadspaEffect/calf/src/synth.cpp | 12 ++++++------ plugins/LadspaEffect/calf/src/utils.cpp | 2 +- plugins/ladspa_browser/ladspa_description.cpp | 2 +- src/core/AutomationPattern.cpp | 6 +++--- src/core/Ladspa2LMMS.cpp | 2 +- src/core/LadspaManager.cpp | 2 +- src/core/Track.cpp | 4 ++-- src/core/audio/AudioFileOgg.cpp | 1 + src/gui/MainWindow.cpp | 4 ++-- src/gui/PluginBrowser.cpp | 4 ++-- 14 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/MainWindow.h b/include/MainWindow.h index f82a5db02..dd12c05a7 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -98,9 +98,9 @@ public: static void restoreWidgetState( QWidget * _w, const QDomElement & _de ); void collectErrors( const QList* errors ); - void collectError( const QString error ); + void collectError( const QString & error ); void clearErrors(); - void showErrors( const QString reason ); + void showErrors( const QString & reason ); public slots: diff --git a/include/PlayHandle.h b/include/PlayHandle.h index b96ec55ad..ea66cc65c 100644 --- a/include/PlayHandle.h +++ b/include/PlayHandle.h @@ -55,6 +55,8 @@ public: m_type = p.m_type; m_offset = p.m_offset; m_affinity = p.m_affinity; + m_usesBuffer = p.m_usesBuffer; + m_audioPort = p.m_audioPort; return *this; } diff --git a/plugins/LadspaEffect/LadspaControlDialog.cpp b/plugins/LadspaEffect/LadspaControlDialog.cpp index b84fc9b0b..2ea15f1f7 100644 --- a/plugins/LadspaEffect/LadspaControlDialog.cpp +++ b/plugins/LadspaEffect/LadspaControlDialog.cpp @@ -107,7 +107,7 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) grouper->setAlignment( Qt::Vertical ); for( control_list_t::iterator it = controls.begin(); - it != controls.end(); it++ ) + it != controls.end(); ++it ) { if( (*it)->port()->proc == proc ) { diff --git a/plugins/LadspaEffect/calf/src/organ.cpp b/plugins/LadspaEffect/calf/src/organ.cpp index fad15edb5..c90fc50bd 100644 --- a/plugins/LadspaEffect/calf/src/organ.cpp +++ b/plugins/LadspaEffect/calf/src/organ.cpp @@ -983,7 +983,7 @@ bool drawbar_organ::check_percussion() { void drawbar_organ::pitch_bend(int amt) { parameters->pitch_bend = pow(2.0, (amt * parameters->pitch_bend_range) / (1200.0 * 8192.0)); - for (list::iterator i = active_voices.begin(); i != active_voices.end(); i++) + for (list::iterator i = active_voices.begin(); i != active_voices.end(); ++i) { organ_voice *v = dynamic_cast(*i); v->update_pitch(); diff --git a/plugins/LadspaEffect/calf/src/synth.cpp b/plugins/LadspaEffect/calf/src/synth.cpp index fcda18b22..d7074a7c3 100644 --- a/plugins/LadspaEffect/calf/src/synth.cpp +++ b/plugins/LadspaEffect/calf/src/synth.cpp @@ -25,7 +25,7 @@ using namespace std; void basic_synth::kill_note(int note, int vel, bool just_one) { - for (list::iterator it = active_voices.begin(); it != active_voices.end(); it++) { + for (list::iterator it = active_voices.begin(); it != active_voices.end(); ++it) { // preserve sostenuto notes if ((*it)->get_current_note() == note && !(sostenuto && (*it)->sostenuto)) { (*it)->note_off(vel); @@ -58,7 +58,7 @@ dsp::voice *basic_synth::steal_voice() std::list::iterator found = active_voices.end(); float priority = 10000; //int idx = 0; - for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); i++) + for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); ++i) { //printf("Voice %d priority %f at %p\n", idx++, (*i)->get_priority(), *i); if ((*i)->get_priority() < priority) @@ -79,7 +79,7 @@ void basic_synth::trim_voices() { // count stealable voices unsigned int count = 0; - for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); i++) + for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); ++i) { if ((*i)->get_priority() < 10000) count++; @@ -118,7 +118,7 @@ void basic_synth::note_off(int note, int vel) kill_note(note, vel, false); } -#define for_all_voices(iter) for (std::list::iterator iter = active_voices.begin(); iter != active_voices.end(); iter++) +#define for_all_voices(iter) for (std::list::iterator iter = active_voices.begin(); iter != active_voices.end(); ++iter) void basic_synth::on_pedal_release() { @@ -204,7 +204,7 @@ void basic_synth::render_to(float (*output)[2], int nsamples) unused_voices.push(v); continue; } - i++; + ++i; } } @@ -214,7 +214,7 @@ basic_synth::~basic_synth() delete unused_voices.top(); unused_voices.pop(); } - for (list::iterator i = active_voices.begin(); i != active_voices.end(); i++) + for (list::iterator i = active_voices.begin(); i != active_voices.end(); ++i) delete *i; } diff --git a/plugins/LadspaEffect/calf/src/utils.cpp b/plugins/LadspaEffect/calf/src/utils.cpp index c1c3eaff2..5d5f33b87 100644 --- a/plugins/LadspaEffect/calf/src/utils.cpp +++ b/plugins/LadspaEffect/calf/src/utils.cpp @@ -33,7 +33,7 @@ string encode_map(const dictionary &data) osctl::string_buffer sb; osc_stream str(sb); str << (uint32_t)data.size(); - for(dictionary::const_iterator i = data.begin(); i != data.end(); i++) + for(dictionary::const_iterator i = data.begin(); i != data.end(); ++i) { str << i->first << i->second; } diff --git a/plugins/ladspa_browser/ladspa_description.cpp b/plugins/ladspa_browser/ladspa_description.cpp index 76efcb182..fd00fb587 100644 --- a/plugins/ladspa_browser/ladspa_description.cpp +++ b/plugins/ladspa_browser/ladspa_description.cpp @@ -70,7 +70,7 @@ ladspaDescription::ladspaDescription( QWidget * _parent, QList pluginNames; for( l_sortable_plugin_t::iterator it = plugins.begin(); - it != plugins.end(); it++ ) + it != plugins.end(); ++it ) { if( _type != VALID || manager->getDescription( ( *it ).second )->inputChannels diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 7420645e9..9185839a4 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -195,7 +195,7 @@ MidiTime AutomationPattern::putValue( const MidiTime & _time, timeMap::const_iterator it = m_timeMap.find( newTime ); if( it != m_timeMap.begin() ) { - it--; + --it; } generateTangents(it, 3); @@ -229,7 +229,7 @@ void AutomationPattern::removeValue( const MidiTime & _time, timeMap::const_iterator it = m_timeMap.lowerBound( newTime ); if( it != m_timeMap.begin() ) { - it--; + --it; } generateTangents(it, 3); @@ -271,7 +271,7 @@ MidiTime AutomationPattern::setDragValue( const MidiTime & _time, const float _v //Restore to the state before it the point were being dragged m_timeMap = m_oldTimeMap; - for( timeMap::const_iterator it = m_timeMap.begin(); it != m_timeMap.end(); it++ ) + for( timeMap::const_iterator it = m_timeMap.begin(); it != m_timeMap.end(); ++it ) { generateTangents(it, 3); } diff --git a/src/core/Ladspa2LMMS.cpp b/src/core/Ladspa2LMMS.cpp index 08489beff..7f8e4d67f 100644 --- a/src/core/Ladspa2LMMS.cpp +++ b/src/core/Ladspa2LMMS.cpp @@ -32,7 +32,7 @@ Ladspa2LMMS::Ladspa2LMMS() l_sortable_plugin_t plugins = getSortedPlugins(); for( l_sortable_plugin_t::iterator it = plugins.begin(); - it != plugins.end(); it++ ) + it != plugins.end(); ++it ) { ladspa_key_t key = (*it).second; ladspaManagerDescription * desc = getDescription( key ); diff --git a/src/core/LadspaManager.cpp b/src/core/LadspaManager.cpp index 50e791b9e..8dcb20158 100644 --- a/src/core/LadspaManager.cpp +++ b/src/core/LadspaManager.cpp @@ -96,7 +96,7 @@ LadspaManager::LadspaManager() l_ladspa_key_t keys = m_ladspaManagerMap.keys(); for( l_ladspa_key_t::iterator it = keys.begin(); - it != keys.end(); it++ ) + it != keys.end(); ++it ) { m_sortedPlugins.append( qMakePair( getName( *it ), *it ) ); } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 7ee6c1f59..63fe1729c 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -1774,7 +1774,7 @@ void TrackOperationsWidget::recordingOn() if( atv ) { const Track::tcoVector & tcov = atv->getTrack()->getTCOs(); - for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); it++ ) + for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); ++it ) { AutomationPattern * ap = dynamic_cast( *it ); if( ap ) { ap->setRecording( true ); } @@ -1790,7 +1790,7 @@ void TrackOperationsWidget::recordingOff() if( atv ) { const Track::tcoVector & tcov = atv->getTrack()->getTCOs(); - for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); it++ ) + for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); ++it ) { AutomationPattern * ap = dynamic_cast( *it ); if( ap ) { ap->setRecording( false ); } diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp index 72efe883c..798418bf2 100644 --- a/src/core/audio/AudioFileOgg.cpp +++ b/src/core/audio/AudioFileOgg.cpp @@ -120,6 +120,7 @@ bool AudioFileOgg::startEncoding() printf( "Mode initialization failed: invalid parameters for " "bitrate\n" ); vorbis_info_clear( &m_vi ); + delete[] user_comments; return false; } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e5d00f35c..13f98d74b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1211,7 +1211,7 @@ void MainWindow::collectErrors(const QList* errors ) -void MainWindow::collectError( const QString error ) +void MainWindow::collectError( const QString & error ) { m_errors->append( error ); } @@ -1225,7 +1225,7 @@ void MainWindow::clearErrors() -void MainWindow::showErrors( const QString message ) +void MainWindow::showErrors( const QString & message ) { if ( m_errors->length() != 0 ) { QString* errors = new QString(); diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index e87eac326..5c10dd368 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -99,8 +99,8 @@ PluginDescList::PluginDescList(QWidget *parent) : std::sort(m_pluginDescriptors.begin(), m_pluginDescriptors.end(), pluginBefore); - for(Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin(); - it != m_pluginDescriptors.constEnd(); it++) + for( Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin(); + it != m_pluginDescriptors.constEnd(); ++it ) { if( it->type == Plugin::Instrument ) { From 4ad1cd607bd4a6de223b86a73614c363366f0e4f Mon Sep 17 00:00:00 2001 From: Dave French Date: Fri, 9 Jan 2015 19:28:26 +0000 Subject: [PATCH 15/22] Eq fix incorrect memory allocation --- plugins/Eq/EqParameterWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index d7318de3b..64e87b8da 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -234,7 +234,7 @@ EqBand* EqParameterWidget::selectNearestHandle( const int x, const int y ) { selectedModel = &m_bands[shortestBand]; } - delete distanceToHandles; + delete[] distanceToHandles; return selectedModel; } From 180c02aedc5de6652a29b98d7af4d3cc8e6c7e07 Mon Sep 17 00:00:00 2001 From: Dave French Date: Fri, 9 Jan 2015 21:25:41 +0000 Subject: [PATCH 16/22] Proposed fix for issue 300, preview vst crashes --- src/core/PresetPreviewPlayHandle.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index dceb5b0d2..832159a7f 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -147,9 +147,17 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, else { DataFile dataFile( _preset_file ); - s_previewTC->previewInstrumentTrack()-> - loadTrackSpecificSettings( - dataFile.content().firstChild().toElement() ); + if(dataFile.content().elementsByTagName( "vestige" ).length() == 0 ) + { + s_previewTC->previewInstrumentTrack()-> + loadTrackSpecificSettings( + dataFile.content().firstChild().toElement() ); + } + else + { + s_previewTC->previewInstrumentTrack()->loadInstrument("tripleoscillator"); + s_previewTC->previewInstrumentTrack()->setVolume( 0 ); + } } Engine::setSuppressMessages( false ); From 25448d3f216bfc6bd9a4c80fbe8e66870120f32e Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Fri, 9 Jan 2015 18:12:46 -0500 Subject: [PATCH 17/22] Add explanation for #1587 changes --- src/core/PresetPreviewPlayHandle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index 832159a7f..69b550fdc 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -147,6 +147,8 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, else { DataFile dataFile( _preset_file ); + // vestige previews are bug prone; fallback on 3xosc with volume of 0 + // without an instrument in preview track, it will segfault if(dataFile.content().elementsByTagName( "vestige" ).length() == 0 ) { s_previewTC->previewInstrumentTrack()-> From 1284b6e9000c60ab1a6b3aeadf04877406851544 Mon Sep 17 00:00:00 2001 From: Umcaruje Date: Sat, 10 Jan 2015 00:57:48 +0100 Subject: [PATCH 18/22] Update README --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e451275cb..614b3bf72 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![LMMS Logo](http://lmms.sourceforge.net/Lmms_logo.png) LMMS +#![LMMS Logo](http://lmms.sourceforge.net/Lmms_logo.png) LMMS [![Build Status](https://travis-ci.org/LMMS/lmms.png)](https://travis-ci.org/LMMS/lmms) What is LMMS? @@ -25,13 +25,17 @@ Features * Compatible with many standards such as SoundFont2, VST(i), LADSPA, GUS Patches, and full MIDI support * Import of MIDI and FLP (FL Studio®/Fruityloops® Project) files -[Latest Stable Release (1.0.3)](https://github.com/LMMS/lmms/releases/tag/v1.0.3) +[Latest Stable Release (1.1.0)](https://github.com/LMMS/lmms/releases/tag/v1.1.0) --------------------- -* Fix zyn GUI crash on win32 -* Fix SF2 note volume -* Localization updates -* Updated LADSPA search paths -* Bugfixes in plugins +* New FX Mixer +* New Instruments +* Instrument Enhancements +* Improved Demos/Presets +* UI Improvements +* Enabled toggling of knob scale in context menu (Linear/Logarithmic) +* Added ability to record automations +* Added support for undo/redo in Piano Roll +* Bug Fixes Building --------- From 5178ecd3a2e513cf8da44c3ea0826bcd3ac84525 Mon Sep 17 00:00:00 2001 From: Dave French Date: Sat, 10 Jan 2015 12:40:53 +0000 Subject: [PATCH 19/22] update 1211 solo nolonger mutes master --- src/core/FxMixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index 358e31171..e6d1767ff 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -230,7 +230,7 @@ int FxMixer::createChannel() void FxMixer::activateSolo() { - for (int i = 0; i < m_fxChannels.size(); ++i) + for (int i = 1; i < m_fxChannels.size(); ++i) { m_fxChannels[i]->m_muteBeforeSolo = m_fxChannels[i]->m_muteModel.value(); m_fxChannels[i]->m_muteModel.setValue( true ); @@ -239,7 +239,7 @@ void FxMixer::activateSolo() void FxMixer::deactivateSolo() { - for (int i = 0; i < m_fxChannels.size(); ++i) + for (int i = 1; i < m_fxChannels.size(); ++i) { m_fxChannels[i]->m_muteModel.setValue( m_fxChannels[i]->m_muteBeforeSolo ); } From 1444902a2d6c8ebd8658fe7eaccdc1e6055531c7 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sat, 10 Jan 2015 17:43:32 +0100 Subject: [PATCH 20/22] Enable GigPlayer Windows build --- .travis.yml | 4 ++-- plugins/GigPlayer/CMakeLists.txt | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93ad9ea4b..a8bb8c652 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ before_install: - sudo apt-get update -qq install: - if [ $TARGET_OS != linux ]; then sudo apt-get install -y nsis cloog-isl libmpc2 mingw32; fi - - if [ $TARGET_OS != linux ]; then sudo apt-get install -y mingw32-x-qt mingw32-x-sdl mingw32-x-libvorbis mingw32-x-fluidsynth mingw32-x-stk mingw32-x-glib2 mingw32-x-portaudio mingw32-x-libsndfile mingw32-x-fftw mingw32-x-flac mingw32-x-fltk mingw32-x-libsamplerate mingw32-x-pkgconfig mingw32-x-binutils mingw32-x-gcc mingw32-x-runtime; fi - - if [ $TARGET_OS == win64 ]; then sudo apt-get install -y mingw64-x-qt mingw64-x-sdl mingw64-x-libvorbis mingw64-x-fluidsynth mingw64-x-stk mingw64-x-glib2 mingw64-x-portaudio mingw64-x-libsndfile mingw64-x-fftw mingw64-x-flac mingw64-x-fltk mingw64-x-libsamplerate mingw64-x-pkgconfig mingw64-x-binutils mingw64-x-gcc mingw64-x-runtime; fi + - if [ $TARGET_OS != linux ]; then sudo apt-get install -y mingw32-x-qt mingw32-x-sdl mingw32-x-libvorbis mingw32-x-fluidsynth mingw32-x-stk mingw32-x-glib2 mingw32-x-portaudio mingw32-x-libsndfile mingw32-x-fftw mingw32-x-flac mingw32-x-fltk mingw32-x-libsamplerate mingw32-x-pkgconfig mingw32-x-binutils mingw32-x-gcc mingw32-x-runtime mingw32-x-libgig; fi + - if [ $TARGET_OS == win64 ]; then sudo apt-get install -y mingw64-x-qt mingw64-x-sdl mingw64-x-libvorbis mingw64-x-fluidsynth mingw64-x-stk mingw64-x-glib2 mingw64-x-portaudio mingw64-x-libsndfile mingw64-x-fftw mingw64-x-flac mingw64-x-fltk mingw64-x-libsamplerate mingw64-x-pkgconfig mingw64-x-binutils mingw64-x-gcc mingw64-x-runtime mingw64-x-libgig; fi - if [ $TARGET_OS == linux ]; then sudo apt-get install -y libqt4-dev libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev libfluidsynth-dev portaudio19-dev wine-dev g++-multilib libfltk1.3-dev libgig-dev; fi before_script: - mkdir build && cd build diff --git a/plugins/GigPlayer/CMakeLists.txt b/plugins/GigPlayer/CMakeLists.txt index 4be4dff82..24db813bd 100644 --- a/plugins/GigPlayer/CMakeLists.txt +++ b/plugins/GigPlayer/CMakeLists.txt @@ -6,8 +6,14 @@ if(LMMS_HAVE_GIG) SET(GCC_COVERAGE_COMPILE_FLAGS "-fexceptions") add_definitions(${GCC_COVERAGE_COMPILE_FLAGS}) - LINK_DIRECTORIES(${GIG_LIBRARY_DIRS}) - LINK_LIBRARIES(${GIG_LIBRARIES}) + # disable deprecated check for mingw-x-libgig + if(LMMS_BUILD_WIN32) + SET(GCC_GIG_COMPILE_FLAGS "-Wno-deprecated") + add_definitions(${GCC_GIG_COMPILE_FLAGS}) + endif(LMMS_BUILD_WIN32) + + LINK_DIRECTORIES(${GIG_LIBRARY_DIRS} ${SAMPLERATE_LIBRARY_DIRS}) + LINK_LIBRARIES(${GIG_LIBRARIES} ${SAMPLERATE_LIBRARIES}) BUILD_PLUGIN(gigplayer GigPlayer.cpp GigPlayer.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui MOCFILES GigPlayer.h PatchesDialog.h UICFILES PatchesDialog.ui EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") endif(LMMS_HAVE_GIG) From 60f34788fba05cf55beabc36da09692e3ac31253 Mon Sep 17 00:00:00 2001 From: Jonas Trappenberg Date: Sat, 10 Jan 2015 23:52:57 -0800 Subject: [PATCH 21/22] Remove unused variable --- src/gui/PianoRoll.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index cfa98bc23..deeb70d7c 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -78,9 +78,6 @@ typedef AutomationPattern::timeMap timeMap; -extern Keys whiteKeys[]; // defined in piano_widget.cpp - - // some constants... const int INITIAL_PIANOROLL_HEIGHT = 480; From 87e597510cac8b02e65d7205a81a7f8d80598ad8 Mon Sep 17 00:00:00 2001 From: Jonas Trappenberg Date: Sat, 10 Jan 2015 23:59:06 -0800 Subject: [PATCH 22/22] Minor refactorings and codestyle cleanup. --- include/MidiTime.h | 3 +- include/Note.h | 6 +- include/PianoRoll.h | 2 +- src/gui/PianoRoll.cpp | 464 ++++++++++++++++++++--------------------- src/tracks/Pattern.cpp | 21 +- 5 files changed, 247 insertions(+), 249 deletions(-) diff --git a/include/MidiTime.h b/include/MidiTime.h index 5c49f780d..788e6fb57 100644 --- a/include/MidiTime.h +++ b/include/MidiTime.h @@ -137,7 +137,8 @@ public: static int stepsPerTact() { - return qMax( 1, ticksPerTact() / DefaultBeatsPerTact ); + int steps = ticksPerTact() / DefaultBeatsPerTact; + return qMax( 1, steps ); } static void setTicksPerTact( tick_t _tpt ) diff --git a/include/Note.h b/include/Note.h index eb36462a6..d179ba939 100644 --- a/include/Note.h +++ b/include/Note.h @@ -91,9 +91,9 @@ public: virtual ~Note(); // used by GUI - inline void setSelected( const bool _selected ){ m_selected = _selected; } - inline void setOldKey( const int _oldKey ){ m_oldKey = _oldKey; } - inline void setOldPos( const MidiTime & _oldPos ){ m_oldPos = _oldPos; } + inline void setSelected( const bool _selected ) { m_selected = _selected; } + inline void setOldKey( const int _oldKey ) { m_oldKey = _oldKey; } + inline void setOldPos( const MidiTime & _oldPos ) { m_oldPos = _oldPos; } inline void setOldLength( const MidiTime & _oldLength ) { m_oldLength = _oldLength; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index bd27bda2e..84a8ffee8 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -341,7 +341,7 @@ private: volume_t m_lastNoteVolume; panning_t m_lastNotePanning; - int m_startKey; // first key when drawing + int m_startKey; // first key when drawing int m_lastKey; editModes m_editMode; diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index deeb70d7c..980b24396 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -809,7 +809,7 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) m_currentNote = NULL; m_startKey = INITIAL_START_KEY; - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { //resizeEvent( NULL ); setWindowTitle( tr( "Piano-Roll - no pattern" ) ); @@ -823,16 +823,17 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) const NoteVector & notes = m_pattern->notes(); int central_key = 0; - if( notes.empty() == false ) + if( ! notes.empty() ) { // determine the central key so that we can scroll to it int total_notes = 0; for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it ) { - if( ( *it )->length() > 0 ) + Note *note = *it; + if( note->length() > 0 ) { - central_key += ( *it )->key(); + central_key += note->key(); ++total_notes; } } @@ -893,7 +894,7 @@ void PianoRoll::loadSettings( const QDomElement & _this ) void PianoRoll::setPauseIcon( bool pause ) { - if( pause == true ) + if( pause ) { m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } @@ -1056,8 +1057,6 @@ void PianoRoll::removeSelection() m_selectedTick = 0; m_selectStartKey = 0; m_selectedKeys = 0; - - } @@ -1071,12 +1070,10 @@ void PianoRoll::clearSelectedNotes() const NoteVector & notes = m_pattern->notes(); // will be our iterator in the following loop - NoteVector::ConstIterator it = notes.begin(); - while( it != notes.end() ) - { - ( *it )->setSelected( false ); - - ++it; + NoteVector::ConstIterator it; + for( it = notes.begin(); it != notes.end(); ++it ) { + Note *note = *it; + note->setSelected( false ); } } } @@ -1105,21 +1102,21 @@ void PianoRoll::shiftSemiTone( int amount ) // shift notes by amount semitones { bool useAllNotes = ! isSelection(); const NoteVector & notes = m_pattern->notes(); - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); - ++it ) + NoteVector::ConstIterator it; + for( it = notes.begin(); it != notes.end(); ++it ) { + Note *note = *it; // if none are selected, move all notes, otherwise // only move selected notes - if( useAllNotes || ( *it )->selected() ) + if( useAllNotes || note->selected() ) { - ( *it )->setKey( ( *it )->key() + amount ); + note->setKey( note->key() + amount ); } } // we modified the song update(); Engine::songEditor()->update(); - } @@ -1129,26 +1126,27 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount { bool useAllNotes = ! isSelection(); const NoteVector & notes = m_pattern->notes(); + NoteVector::ConstIterator it; bool first = true; - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); - ++it ) + for( it = notes.begin(); it != notes.end(); ++it ) { + Note *note = *it; // if none are selected, move all notes, otherwise // only move selected notes - if( ( *it )->selected() || (useAllNotes && ( *it )->length() > 0) ) + if( note->selected() || (useAllNotes && note->length() > 0) ) { // don't let notes go to out of bounds if( first ) { - m_moveBoundaryLeft = ( *it )->pos(); + m_moveBoundaryLeft = note->pos(); if( m_moveBoundaryLeft + amount < 0 ) { amount += 0 - (amount + m_moveBoundaryLeft); } first = false; } - ( *it )->setPos( ( *it )->pos() + amount ); + note->setPos( note->pos() + amount ); } } @@ -1163,9 +1161,11 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount bool PianoRoll::isSelection() const // are any notes selected? { const NoteVector & notes = m_pattern->notes(); - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it ) + NoteVector::ConstIterator it; + for( it = notes.begin(); it != notes.end(); ++it ) { - if( ( *it )->selected() ) + Note *note = *it; + if( note->selected() ) { return true; } @@ -1181,9 +1181,11 @@ int PianoRoll::selectionCount() const // how many notes are selected? int sum = 0; const NoteVector & notes = m_pattern->notes(); - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it ) + NoteVector::ConstIterator it; + for( it = notes.begin(); it != notes.end(); ++it ) { - if( ( *it )->selected() ) + Note *note = *it; + if( note->selected() ) { ++sum; } @@ -1200,7 +1202,7 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) { const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave; - if( event->isAutoRepeat() == false && key_num > -1 ) + if( ! event->isAutoRepeat() && key_num > -1 ) { m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num ); event->accept(); @@ -1483,7 +1485,7 @@ void PianoRoll::keyReleaseEvent( QKeyEvent* event ) { const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave; - if( event->isAutoRepeat() == false && key_num > -1 ) + if( ! event->isAutoRepeat() && key_num > -1 ) { m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( key_num ); event->accept(); @@ -1581,7 +1583,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) { m_startedWithShift = _me->modifiers() & Qt::ShiftModifier; - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -1645,22 +1647,23 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) // loop through whole note-vector... for( int i = 0; i < notes.size(); ++i ) { - MidiTime len = ( *it )->length(); + Note *note = *it; + MidiTime len = note->length(); if( len < 0 ) { len = 4; } // and check whether the user clicked on an // existing note or an edit-line - if( pos_ticks >= ( *it )->pos() && + if( pos_ticks >= note->pos() && len > 0 && ( - ( edit_note == false && - pos_ticks <= ( *it )->pos() + len && - ( *it )->key() == key_num ) + ( ! edit_note && + pos_ticks <= note->pos() + len && + note->key() == key_num ) || - ( edit_note == true && - pos_ticks <= ( *it )->pos() + + ( edit_note && + pos_ticks <= note->pos() + NE_LINE_WIDTH * MidiTime::ticksPerTact() / m_ppt ) @@ -1674,7 +1677,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) // first check whether the user clicked in note-edit- // area - if( edit_note == true ) + if( edit_note ) { m_pattern->addJournalCheckPoint(); // scribble note edit changes @@ -1744,58 +1747,55 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) { ++it; } - - } - m_currentNote = *it; - m_lastNotePanning = ( *it )->getPanning(); - m_lastNoteVolume = ( *it )->getVolume(); - m_lenOfNewNotes = ( *it )->length(); + Note *current_note = *it; + m_currentNote = current_note; + m_lastNotePanning = current_note->getPanning(); + m_lastNoteVolume = current_note->getVolume(); + m_lenOfNewNotes = current_note->length(); // remember which key and tick we started with m_mouseDownKey = m_startKey; m_mouseDownTick = m_currentPosition; bool first = true; - it = notes.begin(); - while( it != notes.end() ) + for( it = notes.begin(); it != notes.end(); ++it ) { + Note *note = *it; // remember note starting positions - ( *it )->setOldKey( ( *it )->key() ); - ( *it )->setOldPos( ( *it )->pos() ); - ( *it )->setOldLength( ( *it )->length() ); + note->setOldKey( note->key() ); + note->setOldPos( note->pos() ); + note->setOldLength( note->length() ); - if( ( *it )->selected() ) + if( note->selected() ) { // figure out the bounding box of all the selected notes if( first ) { - m_moveBoundaryLeft = ( *it )->pos().getTicks(); - m_moveBoundaryRight = ( *it )->pos() + ( *it )->length(); - m_moveBoundaryBottom = ( *it )->key(); - m_moveBoundaryTop = ( *it )->key(); + m_moveBoundaryLeft = note->pos().getTicks(); + m_moveBoundaryRight = note->pos() + note->length(); + m_moveBoundaryBottom = note->key(); + m_moveBoundaryTop = note->key(); first = false; } else { m_moveBoundaryLeft = qMin( - ( *it )->pos().getTicks(), - m_moveBoundaryLeft ); - m_moveBoundaryRight = qMax( ( *it )->pos() + - ( *it )->length(), + note->pos().getTicks(), + (tick_t) m_moveBoundaryLeft ); + m_moveBoundaryRight = qMax( note->pos() + + note->length(), m_moveBoundaryRight ); - m_moveBoundaryBottom = qMin( ( *it )->key(), + m_moveBoundaryBottom = qMin( note->key(), m_moveBoundaryBottom ); - m_moveBoundaryTop = qMax( ( *it )->key(), + m_moveBoundaryTop = qMax( note->key(), m_moveBoundaryTop ); } } - - ++it; } // if clicked on an unselected note, remove selection @@ -1812,8 +1812,8 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) // clicked at the "tail" of the note? - if( pos_ticks*m_ppt/MidiTime::ticksPerTact() > - ( m_currentNote->pos() + m_currentNote->length() )*m_ppt/ MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH && + if( pos_ticks * m_ppt/MidiTime::ticksPerTact() > + ( m_currentNote->pos() + m_currentNote->length() ) * m_ppt/ MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH && m_currentNote->length() > 0 ) { m_pattern->addJournalCheckPoint(); @@ -1839,18 +1839,18 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) QApplication::setOverrideCursor( c ); // if they're holding shift, copy all selected notes - if( //*it != created_new_note && - ! is_new_note && _me->modifiers() & Qt::ShiftModifier ) + if( ! is_new_note && _me->modifiers() & Qt::ShiftModifier ) { // vector to hold new notes until we're through the loop QVector newNotes; it = notes.begin(); while( it != notes.end() ) { - if( ( *it )->selected() ) + Note *note = *it; + if( note->selected() ) { // copy this note - Note noteCopy( (Note) **it ); + Note noteCopy( *note ); newNotes.push_back( noteCopy ); } ++it; @@ -1859,7 +1859,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) if( newNotes.size() != 0 ) { //put notes from vector into piano roll - for( int i=0; iaddNote( newNotes[i] ); newNote->setSelected( false ); @@ -1886,14 +1886,15 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) m_mouseDownRight = true; if( it != notes.begin()-1 ) { + Note *note = *it; m_pattern->addJournalCheckPoint(); - if( ( *it )->length() > 0 ) + if( note->length() > 0 ) { - m_pattern->removeNote( *it ); + m_pattern->removeNote( note ); } else { - ( *it )->setLength( 0 ); + note->setLength( 0 ); m_pattern->dataChanged(); } Engine::getSong()->setModified(); @@ -1910,7 +1911,6 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) m_selectedKeys = 1; m_action = ActionSelectNotes; - // call mousemove to fix glitch where selection // appears in wrong spot on mousedown mouseMoveEvent( _me ); @@ -1930,11 +1930,8 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) { // left click - play the note m_lastKey = key_num; - //if( ! m_recording && ! engine::getSong()->isPlaying() ) - { - int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity; - m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v ); - } + int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity; + m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v ); } } else @@ -1945,7 +1942,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) m_noteEditMode = (noteEditMode)(((int)m_noteEditMode)+1); if( m_noteEditMode == NoteEditCount ) { - m_noteEditMode = (noteEditMode)0; + m_noteEditMode = (noteEditMode) 0; } repaint(); } @@ -1963,7 +1960,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me ) { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -2014,7 +2011,8 @@ void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me ) NoteVector::Iterator it = nv.begin(); while( it != nv.end() ) { - if( ( *it )->pos().getTicks() != closest->pos().getTicks() ) + Note *note = *it; + if( note->pos().getTicks() != closest->pos().getTicks() ) { it = nv.erase( it ); } @@ -2036,7 +2034,7 @@ void PianoRoll::testPlayNote( Note * n ) { m_lastKey = n->key(); - if( n->isPlaying() == false && m_recording == false ) + if( ! n->isPlaying() && ! m_recording ) { n->setIsPlaying( true ); @@ -2061,18 +2059,19 @@ void PianoRoll::pauseTestNotes( bool _pause ) NoteVector::ConstIterator it = notes.begin(); while( it != notes.end() ) { - if( ( *it )->isPlaying() ) + Note *note = *it; + if( note->isPlaying() ) { if( _pause ) { // stop note - m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() ); + m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() ); } else { // start note - ( *it )->setIsPlaying( false ); - testPlayNote( *it ); + note->setIsPlaying( false ); + testPlayNote( note ); } } @@ -2125,20 +2124,21 @@ void PianoRoll::computeSelectedNotes(bool shift) } //int y_base = noteEditTop() - 1; - if( hasValidPattern() == true ) + if( hasValidPattern() ) { const NoteVector & notes = m_pattern->notes(); + NoteVector::ConstIterator it; - for( NoteVector::ConstIterator it = notes.begin(); - it != notes.end(); ++it ) + for( it = notes.begin(); it != notes.end(); ++it ) { + Note *note = *it; // make a new selection unless they're holding shift if( ! shift ) { - ( *it )->setSelected( false ); + note->setSelected( false ); } - int len_ticks = ( *it )->length(); + int len_ticks = note->length(); if( len_ticks == 0 ) { @@ -2149,9 +2149,9 @@ void PianoRoll::computeSelectedNotes(bool shift) len_ticks = 4; } - const int key = ( *it )->key() - m_startKey + 1; + const int key = note->key() - m_startKey + 1; - int pos_ticks = ( *it )->pos(); + int pos_ticks = note->pos(); // if the selection even barely overlaps the note if( key > sel_key_start && @@ -2160,14 +2160,8 @@ void PianoRoll::computeSelectedNotes(bool shift) pos_ticks < sel_pos_end ) { // remove from selection when holding shift - if( shift && ( *it )->selected() ) - { - ( *it )->setSelected(false); - } - else - { - ( *it )->setSelected(true); - } + bool selected = shift && note->selected(); + note->setSelected( ! selected); } } } @@ -2227,7 +2221,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) } - if( hasValidPattern() == true ) + if( hasValidPattern() ) { // turn off all notes that are playing const NoteVector & notes = m_pattern->notes(); @@ -2235,10 +2229,11 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) NoteVector::ConstIterator it = notes.begin(); while( it != notes.end() ) { - if( ( *it )->isPlaying() ) + Note *note = *it; + if( note->isPlaying() ) { - m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() ); - ( *it )->setIsPlaying( false ); + m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() ); + note->setIsPlaying( false ); } ++it; @@ -2268,7 +2263,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { update(); return; @@ -2342,7 +2337,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) pauseTestNotes( false ); } } - else if( ( edit_note == true || m_action == ActionChangeNoteProperty ) && + else if( ( edit_note || m_action == ActionChangeNoteProperty ) && ( _me->buttons() & Qt::LeftButton || _me->buttons() & Qt::MiddleButton || ( _me->buttons() & Qt::RightButton && _me->modifiers() & Qt::ShiftModifier ) ) ) { @@ -2491,13 +2486,14 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) // loop through whole note-vector... for( int i = 0; i < notes.size(); ++i ) { + Note *note = *it; // and check whether the cursor is over an // existing note - if( pos_ticks >= ( *it )->pos() && - pos_ticks <= ( *it )->pos() + - ( *it )->length() && - ( *it )->key() == key_num && - ( *it )->length() > 0 ) + if( pos_ticks >= note->pos() && + pos_ticks <= note->pos() + + note->length() && + note->key() == key_num && + note->length() > 0 ) { break; } @@ -2508,12 +2504,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) // no note?? if( it != notes.begin()-1 ) { + Note *note = *it; // cursor at the "tail" of the note? - if( ( *it )->length() > 0 && + if( note->length() > 0 && pos_ticks*m_ppt / MidiTime::ticksPerTact() > - ( ( *it )->pos() + - ( *it )->length() )*m_ppt/ + ( note->pos() + + note->length() )*m_ppt/ MidiTime::ticksPerTact()- RESIZE_AREA_WIDTH ) { @@ -2611,22 +2608,23 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) // loop through whole note-vector... while( it != notes.end() ) { - MidiTime len = ( *it )->length(); + Note *note = *it; + MidiTime len = note->length(); if( len < 0 ) { len = 4; } // and check whether the user clicked on an // existing note or an edit-line - if( pos_ticks >= ( *it )->pos() && + if( pos_ticks >= note->pos() && len > 0 && ( - ( edit_note == false && - pos_ticks <= ( *it )->pos() + len && - ( *it )->key() == key_num ) + ( ! edit_note && + pos_ticks <= note->pos() + len && + note->key() == key_num ) || - ( edit_note == true && - pos_ticks <= ( *it )->pos() + + ( edit_note && + pos_ticks <= note->pos() + NE_LINE_WIDTH * MidiTime::ticksPerTact() / m_ppt ) @@ -2636,13 +2634,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) // delete this note if( it != notes.end() ) { - if( ( *it )->length() > 0 ) + if( note->length() > 0 ) { - m_pattern->removeNote( *it ); + m_pattern->removeNote( note ); } else { - ( *it )->setLength( 0 ); + note->setLength( 0 ); m_pattern->dataChanged(); } Engine::getSong()->setModified(); @@ -2792,50 +2790,41 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) NoteVector::ConstIterator it = notes.begin(); while( it != notes.end() ) { - const int pos = ( *it )->pos().getTicks(); + Note *note = *it; + const int pos = note->pos().getTicks(); // when resizing a note and holding shift: shift the following // notes to preserve the melody if( m_action == ActionResizeNote && shift ) { - int shifted_pos = ( *it )->oldPos().getTicks() + shift_offset; + int shifted_pos = note->oldPos().getTicks() + shift_offset; if( shifted_pos && pos == shift_ref_pos ) { shifted_pos -= off_ticks; } - ( *it )->setPos( MidiTime( shifted_pos ) ); + note->setPos( MidiTime( shifted_pos ) ); } - if( ( *it )->selected() ) + if( note->selected() ) { if( m_action == ActionMoveNote && ! ( shift && ! m_startedWithShift ) ) { // moving note - int pos_ticks = ( *it )->oldPos().getTicks() - + off_ticks; - int key_num = ( *it )->oldKey() + off_key; + int pos_ticks = note->oldPos().getTicks() + off_ticks; + int key_num = note->oldKey() + off_key; - if( pos_ticks < 0 ) - { - pos_ticks = 0; - } + // ticks can't be negative + pos_ticks = qMax(0, pos_ticks); // upper/lower bound checks on key_num - if( key_num < 0 ) - { - key_num = 0; - } - else if( key_num > NumKeys ) - { - key_num = NumKeys; - } + key_num = qMax(0, key_num); + key_num = qMin(key_num, NumKeys); - ( *it )->setPos( MidiTime( pos_ticks ) ); - ( *it )->setKey( key_num ); + note->setPos( MidiTime( pos_ticks ) ); + note->setKey( key_num ); } else if( m_action == ActionResizeNote ) { // resizing note - int ticks_new = ( *it )->oldLength().getTicks() - + off_ticks; + int ticks_new = note->oldLength().getTicks() + off_ticks; if( ticks_new <= 0 ) { ticks_new = 1; @@ -2850,20 +2839,20 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) shift_ref_pos = pos; } } - ( *it )->setLength( MidiTime( ticks_new ) ); + note->setLength( MidiTime( ticks_new ) ); - m_lenOfNewNotes = ( *it )->length(); + m_lenOfNewNotes = note->length(); } else if( m_action == ActionMoveNote && ( shift && ! m_startedWithShift ) ) { // quick resize, toggled by holding shift after starting a note move, but not before - int ticks_new = ( *it )->oldLength().getTicks() + off_ticks; + int ticks_new = note->oldLength().getTicks() + off_ticks; if( ticks_new <= 0 ) { ticks_new = 1; } - ( *it )->setLength( MidiTime( ticks_new ) ); - m_lenOfNewNotes = ( *it )->length(); + note->setLength( MidiTime( ticks_new ) ); + m_lenOfNewNotes = note->length(); } } ++it; @@ -2876,7 +2865,9 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift ) static QString calculateNoteLabel(QString note, int octave) { if(note.isEmpty()) + { return ""; + } return note + QString::number(octave); } @@ -2910,7 +2901,7 @@ static void printNoteHeights(QPainter& p, int bottom, int width, int startKey) y -= KEY_LINE_HEIGHT, key++) { const unsigned note = key % KeysPerOctave; - assert( note < ( sizeof( labels ) / sizeof( *labels) )); + assert( note < ( sizeof( labels ) / sizeof( labels[0] ) )); const KeyLabel& noteLabel( labels[note] ); const int octave = key / KeysPerOctave; const KeyLabel notes = { @@ -2919,7 +2910,6 @@ static void printNoteHeights(QPainter& p, int bottom, int width, int startKey) calculateNoteLabel(noteLabel.major, octave), }; - const int drawWidth( width - WHITE_KEY_WIDTH ); const int hspace = 300; const int columnCount = drawWidth/hspace + 1; @@ -2947,7 +2937,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) QBrush bgColor = p.background(); // fill with bg color - p.fillRect( 0,0, width(), height(), bgColor ); + p.fillRect( 0, 0, width(), height(), bgColor ); // set font-size to 8 p.setFont( pointSize<8>( p.font() ) ); @@ -2958,8 +2948,8 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) // calculate y_offset according to first key switch( prKeyOrder[m_startKey % KeysPerOctave] ) { - case PR_BLACK_KEY: y_offset = KEY_LINE_HEIGHT/4; break; - case PR_WHITE_KEY_BIG: y_offset = KEY_LINE_HEIGHT/2; break; + case PR_BLACK_KEY: y_offset = KEY_LINE_HEIGHT / 4; break; + case PR_WHITE_KEY_BIG: y_offset = KEY_LINE_HEIGHT / 2; break; case PR_WHITE_KEY_SMALL: if( prKeyOrder[( ( m_startKey + 1 ) % KeysPerOctave)] != PR_BLACK_KEY ) @@ -2990,7 +2980,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) break; } - p.fillRect( WHITE_KEY_WIDTH+1, y-KEY_LINE_HEIGHT/2, + p.fillRect( WHITE_KEY_WIDTH + 1, y - KEY_LINE_HEIGHT / 2, width() - 10, KEY_LINE_HEIGHT, QColor( 0, 80 - ( key_num % KeysPerOctave ) * 3, 64 + key_num / 2) ); } @@ -3034,8 +3024,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) y -= WHITE_KEY_SMALL_HEIGHT; } - else if( prKeyOrder[key % KeysPerOctave] == - PR_WHITE_KEY_BIG ) + else if( prKeyOrder[key % KeysPerOctave] == PR_WHITE_KEY_BIG ) { // draw a big one while checking if it is pressed or not if( hasValidPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) ) @@ -3060,7 +3049,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) { const QString cLabel = "C" + QString::number( static_cast( key / KeysPerOctave ) ); p.setPen( QColor( 240, 240, 240 ) ); - p.drawText( C_KEY_LABEL_X + 1, y+14, cLabel ); + p.drawText( C_KEY_LABEL_X + 1, y + 14, cLabel ); p.setPen( QColor( 0, 0, 0 ) ); p.drawText( C_KEY_LABEL_X, y + 13, cLabel ); horizCol.setAlpha( 192 ); @@ -3148,7 +3137,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) // erase the area below the piano, because there might be keys that // should be only half-visible p.fillRect( QRect( 0, keyAreaBottom(), - WHITE_KEY_WIDTH, noteEditBottom()-keyAreaBottom() ), bgColor ); + WHITE_KEY_WIDTH, noteEditBottom() - keyAreaBottom() ), bgColor ); // display note editing info QFont f = p.font(); @@ -3212,7 +3201,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) p.setPen( vertCol ); } - p.drawLine( (int)x, PR_TOP_MARGIN, (int)x, height() - + p.drawLine( (int) x, PR_TOP_MARGIN, (int) x, height() - PR_BOTTOM_MARGIN ); // extra 32nd's line @@ -3220,8 +3209,8 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) { vertCol.setAlpha( 80 ); p.setPen( vertCol ); - p.drawLine( (int)(x + pp16th/2) , PR_TOP_MARGIN, - (int)(x + pp16th/2), height() - + p.drawLine( (int)(x + pp16th / 2) , PR_TOP_MARGIN, + (int)(x + pp16th / 2), height() - PR_BOTTOM_MARGIN ); } } @@ -3248,7 +3237,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) } int y_base = keyAreaBottom() - 1; - if( hasValidPattern() == true ) + if( hasValidPattern() ) { p.setClipRect( WHITE_KEY_WIDTH, PR_TOP_MARGIN, width() - WHITE_KEY_WIDTH, @@ -3260,11 +3249,12 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) KEY_LINE_HEIGHT + 2; QPolygon editHandles; + NoteVector::ConstIterator it; - for( NoteVector::ConstIterator it = notes.begin(); - it != notes.end(); ++it ) + for( it = notes.begin(); it != notes.end(); ++it ) { - int len_ticks = ( *it )->length(); + Note *note = *it; + int len_ticks = note->length(); if( len_ticks == 0 ) { @@ -3275,17 +3265,15 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) len_ticks = 4; } - const int key = ( *it )->key() - m_startKey + 1; + const int key = note->key() - m_startKey + 1; - int pos_ticks = ( *it )->pos(); + int pos_ticks = note->pos(); - int note_width = len_ticks * m_ppt / - MidiTime::ticksPerTact(); + int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact(); const int x = ( pos_ticks - m_currentPosition ) * m_ppt / MidiTime::ticksPerTact(); // skip this note if not in visible area at all - if( !( x + note_width >= 0 && - x <= width() - WHITE_KEY_WIDTH ) ) + if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) ) { continue; } @@ -3298,22 +3286,22 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) // note drawNoteRect( p, x + WHITE_KEY_WIDTH, y_base - key * KEY_LINE_HEIGHT, - note_width, *it, noteColor() ); + note_width, note, noteColor() ); } // draw note editing stuff int editHandleTop = 0; if( m_noteEditMode == NoteEditVolume ) { - QColor color = barColor().lighter( 30 + ( ( *it )->getVolume() * 90 / MaxVolume ) ); - if( ( *it )->selected() ) + QColor color = barColor().lighter( 30 + ( note->getVolume() * 90 / MaxVolume ) ); + if( note->selected() ) { color.setRgb( 0x00, 0x40, 0xC0 ); } p.setPen( QPen( color, NE_LINE_WIDTH ) ); editHandleTop = noteEditBottom() - - ( (float)( ( *it )->getVolume() - MinVolume ) ) / + ( (float)( note->getVolume() - MinVolume ) ) / ( (float)( MaxVolume - MinVolume ) ) * ( (float)( noteEditBottom() - noteEditTop() ) ); @@ -3324,7 +3312,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) else if( m_noteEditMode == NoteEditPanning ) { QColor color( noteColor() ); - if( ( *it )->selected() ) + if( note->selected() ) { color.setRgb( 0x00, 0x40, 0xC0 ); } @@ -3332,7 +3320,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) p.setPen( QPen( color, NE_LINE_WIDTH ) ); editHandleTop = noteEditBottom() - - ( (float)( ( *it )->getPanning() - PanningLeft ) ) / + ( (float)( note->getPanning() - PanningLeft ) ) / ( (float)( (PanningRight - PanningLeft ) ) ) * ( (float)( noteEditBottom() - noteEditTop() ) ); @@ -3343,7 +3331,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) editHandles << QPoint( x + noteEditLeft(), editHandleTop+1 ); - if( ( *it )->hasDetuningInfo() ) + if( note->hasDetuningInfo() ) { drawDetuningInfo( p, *it, x + WHITE_KEY_WIDTH, @@ -3383,7 +3371,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) p.drawRect( x + WHITE_KEY_WIDTH, y, w, h ); // TODO: Get this out of paint event - int l = ( hasValidPattern() == true )? (int) m_pattern->length() : 0; + int l = ( hasValidPattern() )? (int) m_pattern->length() : 0; // reset scroll-range if( m_leftRightScroll->maximum() != l ) @@ -3396,7 +3384,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) horizCol.setAlpha( 64 ); // horizontal line for the key under the cursor - if( hasValidPattern() == true ) + if( hasValidPattern() ) { int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() ); p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT * @@ -3448,7 +3436,8 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) // responsible for moving/resizing scrollbars after window-resizing void PianoRoll::resizeEvent( QResizeEvent * ) { - m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, height() - + m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, + height() - SCROLLBAR_SIZE, width()-WHITE_KEY_WIDTH, SCROLLBAR_SIZE ); @@ -3489,9 +3478,9 @@ void PianoRoll::wheelEvent( QWheelEvent * _we ) // get values for going through notes int pixel_range = 8; int x = _we->x() - WHITE_KEY_WIDTH; - int ticks_start = ( x-pixel_range/2 ) * + int ticks_start = ( x - pixel_range / 2 ) * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; - int ticks_end = ( x+pixel_range/2 ) * + int ticks_end = ( x + pixel_range / 2 ) * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; // get note-vector of current pattern @@ -3652,7 +3641,7 @@ Song::PlayModes PianoRoll::desiredPlayModeForAccompany() const void PianoRoll::play() { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -3676,7 +3665,7 @@ void PianoRoll::record() { stop(); } - if( m_recording == true || hasValidPattern() == false ) + if( m_recording || ! hasValidPattern() ) { return; } @@ -3695,7 +3684,7 @@ void PianoRoll::recordAccompany() { stop(); } - if( m_recording == true || hasValidPattern() == false ) + if( m_recording || ! hasValidPattern() ) { return; } @@ -3728,7 +3717,7 @@ void PianoRoll::stop() void PianoRoll::startRecordNote( const Note & _n ) { - if( m_recording == true && hasValidPattern() == true && + if( m_recording && hasValidPattern() && Engine::getSong()->isPlaying() && ( Engine::getSong()->playMode() == desiredPlayModeForAccompany() || @@ -3755,7 +3744,7 @@ void PianoRoll::startRecordNote( const Note & _n ) void PianoRoll::finishRecordNote( const Note & _n ) { - if( m_recording == true && hasValidPattern() == true && + if( m_recording && hasValidPattern() && Engine::getSong()->isPlaying() && ( Engine::getSong()->playMode() == desiredPlayModeForAccompany() || @@ -3840,7 +3829,7 @@ void PianoRoll::detuneButtonToggled() void PianoRoll::selectAll() { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -3849,16 +3838,18 @@ void PianoRoll::selectAll() // if first_time = true, we HAVE to set the vars for select bool first_time = true; + NoteVector::ConstIterator it; - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it ) + for( it = notes.begin(); it != notes.end(); ++it ) { - int len_ticks = ( *it )->length(); + Note *note = *it; + int len_ticks = note->length(); if( len_ticks > 0 ) { - const int key = ( *it )->key(); + const int key = note->key(); - int pos_ticks = ( *it )->pos(); + int pos_ticks = note->pos(); if( key <= m_selectStartKey || first_time ) { // if we move start-key down, we have to add @@ -3898,19 +3889,20 @@ void PianoRoll::selectAll() // returns vector with pointers to all selected notes void PianoRoll::getSelectedNotes( NoteVector & _selected_notes ) { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } const NoteVector & notes = m_pattern->notes(); + NoteVector::ConstIterator it; - for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); - ++it ) + for( it = notes.begin(); it != notes.end(); ++it ) { - if( ( *it )->selected() ) + Note *note = *it; + if( note->selected() ) { - _selected_notes.push_back( *it ); + _selected_notes.push_back( note ); } } } @@ -3990,7 +3982,7 @@ void PianoRoll::copySelectedNotes() NoteVector selected_notes; getSelectedNotes( selected_notes ); - if( selected_notes.empty() == false ) + if( ! selected_notes.empty() ) { copy_to_clipboard( selected_notes ); } @@ -4001,7 +3993,7 @@ void PianoRoll::copySelectedNotes() void PianoRoll::cutSelectedNotes() { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -4009,18 +4001,19 @@ void PianoRoll::cutSelectedNotes() NoteVector selected_notes; getSelectedNotes( selected_notes ); - if( selected_notes.empty() == false ) + if( ! selected_notes.empty() ) { copy_to_clipboard( selected_notes ); Engine::getSong()->setModified(); + NoteVector::Iterator it; - for( NoteVector::Iterator it = selected_notes.begin(); - it != selected_notes.end(); ++it ) + for( it = selected_notes.begin(); it != selected_notes.end(); ++it ) { + Note *note = *it; // note (the memory of it) is also deleted by // pattern::removeNote(...) so we don't have to do that - m_pattern->removeNote( *it ); + m_pattern->removeNote( note ); } } @@ -4033,7 +4026,7 @@ void PianoRoll::cutSelectedNotes() void PianoRoll::pasteNotes() { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -4042,7 +4035,7 @@ void PianoRoll::pasteNotes() ->mimeData( QClipboard::Clipboard ) ->data( Clipboard::mimeType() ); - if( !value.isEmpty() ) + if( ! value.isEmpty() ) { DataFile dataFile( value.toUtf8() ); @@ -4051,12 +4044,12 @@ void PianoRoll::pasteNotes() // remove selection and select the newly pasted notes clearSelectedNotes(); - if( !list.isEmpty() ) + if( ! list.isEmpty() ) { m_pattern->addJournalCheckPoint(); } - for( int i = 0; !list.item( i ).isNull(); ++i ) + for( int i = 0; ! list.item( i ).isNull(); ++i ) { // create the note Note cur_note; @@ -4085,7 +4078,7 @@ void PianoRoll::pasteNotes() void PianoRoll::deleteSelectedNotes() { - if( hasValidPattern() == false ) + if( ! hasValidPattern() ) { return; } @@ -4101,10 +4094,11 @@ void PianoRoll::deleteSelectedNotes() NoteVector::ConstIterator it = notes.begin(); while( it != notes.end() ) { - if( ( *it )->selected() ) + Note *note = *it; + if( note->selected() ) { // delete this note - m_pattern->removeNote( ( *it ) ); + m_pattern->removeNote( note ); update_after_delete = true; // start over, make sure we get all the notes @@ -4116,7 +4110,7 @@ void PianoRoll::deleteSelectedNotes() } } - if( update_after_delete == true ) + if( update_after_delete ) { Engine::getSong()->setModified(); update(); @@ -4133,15 +4127,13 @@ void PianoRoll::autoScroll( const MidiTime & _t ) const int w = width() - WHITE_KEY_WIDTH; if( _t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt ) { - m_leftRightScroll->setValue( _t.getTact() * - MidiTime::ticksPerTact() ); + m_leftRightScroll->setValue( _t.getTact() * MidiTime::ticksPerTact() ); } else if( _t < m_currentPosition ) { MidiTime t = qMax( _t - w * MidiTime::ticksPerTact() * - MidiTime::ticksPerTact() / m_ppt, 0 ); - m_leftRightScroll->setValue( t.getTact() * - MidiTime::ticksPerTact() ); + MidiTime::ticksPerTact() / m_ppt, (tick_t) 0 ); + m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() ); } m_scrollBack = false; } @@ -4151,11 +4143,10 @@ void PianoRoll::autoScroll( const MidiTime & _t ) void PianoRoll::updatePosition( const MidiTime & _t ) { - if( ( Engine::getSong()->isPlaying() && - Engine::getSong()->playMode() == - Song::Mode_PlayPattern && - m_timeLine->autoScroll() == Timeline::AutoScrollEnabled ) || - m_scrollBack == true ) + if( ( Engine::getSong()->isPlaying() + && Engine::getSong()->playMode() == Song::Mode_PlayPattern + && m_timeLine->autoScroll() == Timeline::AutoScrollEnabled + ) || m_scrollBack ) { autoScroll( _t ); } @@ -4196,7 +4187,6 @@ void PianoRoll::zoomingChanged() m_timeLine->setPixelsPerTact( m_ppt ); update(); - } @@ -4222,8 +4212,7 @@ int PianoRoll::quantization() const } } return DefaultTicksPerTact / m_quantizeModel.currentText().right( - m_quantizeModel.currentText().length() - - 2 ).toInt(); + m_quantizeModel.currentText().length() - 2 ).toInt(); } @@ -4251,8 +4240,7 @@ MidiTime PianoRoll::newNoteLen() const return m_lenOfNewNotes; } return DefaultTicksPerTact / m_noteLenModel.currentText().right( - m_noteLenModel.currentText().length() - - 2 ).toInt(); + m_noteLenModel.currentText().length() - 2 ).toInt(); } @@ -4285,17 +4273,19 @@ Note * PianoRoll::noteUnderMouse() MidiTime::ticksPerTact() / m_ppt + m_currentPosition; // will be our iterator in the following loop - NoteVector::ConstIterator it = notes.begin()+notes.size()-1; + NoteVector::ConstIterator it = notes.end() - 1; + Note *note = *it; // loop through whole note-vector... int i; for( i = 0; i < notes.size(); ++i ) { + note = *it; // and check whether the cursor is over an // existing note - if( pos_ticks >= ( *it )->pos() && - pos_ticks <= ( *it )->pos() + ( *it )->length() && - ( *it )->key() == key_num && ( *it )->length() > 0 ) + if( pos_ticks >= note->pos() && + pos_ticks <= note->endPos() && + note->key() == key_num && note->length() > 0 ) { break; } @@ -4307,5 +4297,5 @@ Note * PianoRoll::noteUnderMouse() return NULL; } - return *it; + return note; } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index e527acd03..4c95aa6fc 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -499,12 +499,15 @@ void Pattern::ensureBeatNotes() for( int i = 0; i < m_steps; ++i ) { bool found = false; - for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ++it ) + NoteVector::Iterator it; + + for( it = m_notes.begin(); it != m_notes.end(); ++it ) { + Note *note = *it; // if a note in this position is the one we want - if( ( *it )->pos() == + if( note->pos() == ( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact() - && ( *it )->length() <= 0 ) + && note->length() <= 0 ) { found = true; break; @@ -524,10 +527,12 @@ void Pattern::ensureBeatNotes() for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ) { bool needed = false; + Note *note = *it; + for( int i = 0; i < m_steps; ++i ) { - if( ( *it )->pos() == ( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact() - || ( *it )->length() != 0 ) + if( note->pos() == ( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact() + || note->length() != 0 ) { needed = true; break; @@ -535,10 +540,12 @@ void Pattern::ensureBeatNotes() } if( needed == false ) { - delete *it; + delete note; it = m_notes.erase( it ); } - else ++it; + else { + ++it; + } } }