diff --git a/include/BasicFilters.h b/include/BasicFilters.h index e6dfbcbe3..58c811c6f 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -398,7 +398,6 @@ public: out *= 0.25f; m_last[_chnl] = _in0; return out; - break; } // 4-pole state-variant lowpass filter, adapted from Nekobee source code @@ -425,7 +424,6 @@ public: return m_type == Lowpass_SV ? m_delay4[_chnl] : m_delay3[_chnl]; - break; } case Highpass_SV: @@ -440,7 +438,6 @@ public: } return hp; - break; } case Notch_SV: @@ -460,7 +457,6 @@ public: /* mix filter output into output buffer */ return m_delay4[_chnl] + hp1; - break; } @@ -492,7 +488,6 @@ public: m_rcbp0[_chnl] = bp; } return lp; - break; } case Highpass_RC12: case Bandpass_RC12: @@ -514,7 +509,6 @@ public: m_rcbp0[_chnl] = bp; } return m_type == Highpass_RC12 ? hp : bp; - break; } case Lowpass_RC24: @@ -559,7 +553,6 @@ public: m_rchp1[_chnl] = hp; } return lp; - break; } case Highpass_RC24: case Bandpass_RC24: @@ -599,7 +592,6 @@ public: m_rcbp1[_chnl] = bp; } return m_type == Highpass_RC24 ? hp : bp; - break; } case Formantfilter: @@ -697,7 +689,6 @@ public: out += bp; } return m_type == FastFormant ? out * 2.0f : out * 0.5f; - break; } default: diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index b1b682bca..d837292b7 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -107,7 +107,7 @@ const int PR_RIGHT_MARGIN = SCROLLBAR_SIZE; const int RESIZE_AREA_WIDTH = 4; // width of line for setting volume/panning of note -const int NE_LINE_WIDTH = 3; +const int NOTE_EDIT_LINE_WIDTH = 3; // key where to start const int INITIAL_START_KEY = Key_C + Octave_4 * KeysPerOctave; @@ -189,7 +189,7 @@ PianoRoll::PianoRoll() : QSignalMapper * signalMapper = new QSignalMapper( this ); m_noteEditMenu = new QMenu( this ); m_noteEditMenu->clear(); - for( int i=0; ipos() ).y() ); - const InstrumentFunctionNoteStacking::Chord * chord = 0; + const InstrumentFunctionNoteStacking::Chord * chord = nullptr; switch( static_cast( i ) ) { @@ -453,10 +447,10 @@ void PianoRoll::markSemiTone( int i ) break; case stmaMarkCurrentSemiTone: { - QList::iterator i = qFind( m_markedSemiTones.begin(), m_markedSemiTones.end(), key ); - if( i != m_markedSemiTones.end() ) + QList::iterator it = qFind( m_markedSemiTones.begin(), m_markedSemiTones.end(), key ); + if( it != m_markedSemiTones.end() ) { - m_markedSemiTones.erase( i ); + m_markedSemiTones.erase( it ); } else { @@ -490,7 +484,6 @@ void PianoRoll::markSemiTone( int i ) for( int i = first; i <= last; i++ ) { - //if( chord->hasSemiTone( std::abs( key - i ) % cap ) ) if( chord->hasSemiTone( ( i + cap - ( key % cap ) ) % cap ) ) { m_markedSemiTones.push_back( i ); @@ -551,10 +544,8 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) { // 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 ) + for( const Note* const& note : notes ) { - Note *note = *it; if( note->length() > 0 ) { central_key += note->key(); @@ -565,12 +556,11 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern ) if( total_notes > 0 ) { central_key = central_key / total_notes - - ( KeysPerOctave * NumOctaves - - m_totalKeysToScroll ) / 2; - m_startKey = tLimit( central_key, 0, - NumOctaves * KeysPerOctave ); + ( KeysPerOctave * NumOctaves - m_totalKeysToScroll ) / 2; + m_startKey = tLimit( central_key, 0, NumOctaves * KeysPerOctave ); } } + // resizeEvent() does the rest for us (scrolling, range-checking // of start-notes and so on...) resizeEvent( NULL ); @@ -719,7 +709,7 @@ inline void PianoRoll::drawDetuningInfo( QPainter & _p, Note * _n, int _x, const float level = it.value(); - int pos_y = (int)( middle_y - level * KEY_LINE_HEIGHT ); + int pos_y = middle_y - level * KEY_LINE_HEIGHT; if( old_x != 0 && old_y != 0 ) { @@ -1302,9 +1292,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) || ( edit_note && pos_ticks <= note->pos() + - NE_LINE_WIDTH * - MidiTime::ticksPerTact() / - m_ppt ) + NOTE_EDIT_LINE_WIDTH * MidiTime::ticksPerTact() / m_ppt ) ) ) { @@ -1414,7 +1402,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) if( first ) { m_moveBoundaryLeft = note->pos().getTicks(); - m_moveBoundaryRight = note->pos() + note->length(); + m_moveBoundaryRight = note->endPos(); m_moveBoundaryBottom = note->key(); m_moveBoundaryTop = note->key(); @@ -1425,8 +1413,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_moveBoundaryLeft = qMin( note->pos().getTicks(), (tick_t) m_moveBoundaryLeft ); - m_moveBoundaryRight = qMax( note->pos() + - note->length(), + m_moveBoundaryRight = qMax( (int) note->endPos(), m_moveBoundaryRight ); m_moveBoundaryBottom = qMin( note->key(), m_moveBoundaryBottom ); @@ -1443,16 +1430,16 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) clearSelectedNotes(); m_currentNote->setSelected( true ); m_moveBoundaryLeft = m_currentNote->pos().getTicks(); - m_moveBoundaryRight = m_currentNote->pos() + m_currentNote->length(); + m_moveBoundaryRight = m_currentNote->endPos(); m_moveBoundaryBottom = m_currentNote->key(); m_moveBoundaryTop = m_currentNote->key(); } // 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 && - m_currentNote->length() > 0 ) + if( pos_ticks * m_ppt / MidiTime::ticksPerTact() > + m_currentNote->endPos() * m_ppt / MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH + && m_currentNote->length() > 0 ) { m_pattern->addJournalCheckPoint(); // then resize the note @@ -1464,7 +1451,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } else { - if( !created_new_note ) + if( ! created_new_note ) { m_pattern->addJournalCheckPoint(); } @@ -1481,10 +1468,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { // vector to hold new notes until we're through the loop QVector newNotes; - it = notes.begin(); - while( it != notes.end() ) + for( Note* const& note : notes ) { - Note *note = *it; if( note->selected() ) { // copy this note @@ -2263,7 +2248,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) || ( edit_note && pos_ticks <= note->pos() + - NE_LINE_WIDTH * + NOTE_EDIT_LINE_WIDTH * MidiTime::ticksPerTact() / m_ppt ) ) @@ -2936,7 +2921,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) { color.setRgb( 0x00, 0x40, 0xC0 ); } - p.setPen( QPen( color, NE_LINE_WIDTH ) ); + p.setPen( QPen( color, NOTE_EDIT_LINE_WIDTH ) ); editHandleTop = noteEditBottom() - ( (float)( note->getVolume() - MinVolume ) ) / @@ -2955,7 +2940,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) color.setRgb( 0x00, 0x40, 0xC0 ); } - p.setPen( QPen( color, NE_LINE_WIDTH ) ); + p.setPen( QPen( color, NOTE_EDIT_LINE_WIDTH ) ); editHandleTop = noteEditBottom() - ( (float)( note->getPanning() - PanningLeft ) ) / @@ -2977,7 +2962,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } } - p.setPen( QPen( noteColor(), NE_LINE_WIDTH+2 ) ); + p.setPen( QPen( noteColor(), NOTE_EDIT_LINE_WIDTH + 2 ) ); p.drawPoints( editHandles ); } @@ -3819,8 +3804,9 @@ int PianoRoll::quantization() const return DefaultTicksPerTact / 16; } } - return DefaultTicksPerTact / m_quantizeModel.currentText().right( - m_quantizeModel.currentText().length() - 2 ).toInt(); + + QString text = m_quantizeModel.currentText(); + return DefaultTicksPerTact / text.right( text.length() - 2 ).toInt(); } @@ -3828,11 +3814,11 @@ int PianoRoll::quantization() const void PianoRoll::updateSemiToneMarkerMenu() { - const InstrumentFunctionNoteStacking::Chord & scale = InstrumentFunctionNoteStacking::ChordTable::getInstance() - .getScaleByName( m_scaleModel.currentText() ); - - const InstrumentFunctionNoteStacking::Chord & chord = InstrumentFunctionNoteStacking::ChordTable::getInstance() - .getChordByName( m_chordModel.currentText() ); + const auto& chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance(); + const InstrumentFunctionNoteStacking::Chord& scale = + chord_table.getScaleByName( m_scaleModel.currentText() ); + const InstrumentFunctionNoteStacking::Chord& chord = + chord_table.getChordByName( m_chordModel.currentText() ); emit semiToneMarkerMenuScaleSetEnabled( ! scale.isEmpty() ); emit semiToneMarkerMenuChordSetEnabled( ! chord.isEmpty() ); @@ -3847,8 +3833,9 @@ MidiTime PianoRoll::newNoteLen() const { return m_lenOfNewNotes; } - return DefaultTicksPerTact / m_noteLenModel.currentText().right( - m_noteLenModel.currentText().length() - 2 ).toInt(); + + QString text = m_noteLenModel.currentText(); + return DefaultTicksPerTact / text.right( text.length() - 2 ).toInt(); } @@ -3869,7 +3856,8 @@ Note * PianoRoll::noteUnderMouse() // get note-vector of current pattern const NoteVector & notes = m_pattern->notes(); - if( pos.x() <= WHITE_KEY_WIDTH || pos.x() > width() - SCROLLBAR_SIZE + if( pos.x() <= WHITE_KEY_WIDTH + || pos.x() > width() - SCROLLBAR_SIZE || pos.y() < PR_TOP_MARGIN || pos.y() > keyAreaBottom() ) { @@ -3880,42 +3868,26 @@ Note * PianoRoll::noteUnderMouse() int pos_ticks = ( pos.x() - WHITE_KEY_WIDTH ) * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; - // will be our iterator in the following loop - NoteVector::ConstIterator it = notes.end() - 1; - Note *note = *it; - // loop through whole note-vector... - int i; - for( i = 0; i < notes.size(); ++i ) + for( Note* const& note : notes ) { - note = *it; // and check whether the cursor is over an // existing note - if( pos_ticks >= note->pos() && - pos_ticks <= note->endPos() && - note->key() == key_num && note->length() > 0 ) + if( pos_ticks >= note->pos() + && pos_ticks <= note->endPos() + && note->key() == key_num + && note->length() > 0 ) { - break; + return note; } - --it; } - if( i == notes.size() ) - { - return NULL; - } - - return note; + return NULL; } - - - - - PianoRollWindow::PianoRollWindow() : Editor(true), m_editor(new PianoRoll()) @@ -4150,7 +4122,7 @@ PianoRollWindow::PianoRollWindow() : connect(m_editor, SIGNAL(currentPatternChanged()), this, SIGNAL(currentPatternChanged())); } -const Pattern*PianoRollWindow::currentPattern() const +const Pattern* PianoRollWindow::currentPattern() const { return m_editor->currentPattern(); } @@ -4213,5 +4185,5 @@ void PianoRollWindow::loadSettings(const QDomElement & de) QSize PianoRollWindow::sizeHint() const { - return {m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT}; + return {m_toolBar->sizeHint().width() + 10, INITIAL_PIANOROLL_HEIGHT}; }