Merge pull request #1618 from teeberg/master
More minor code style cleanup
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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; i<m_nemStr.size(); ++i )
|
||||
for( int i = 0; i < m_nemStr.size(); ++i )
|
||||
{
|
||||
QAction * act = new QAction( m_nemStr.at(i), this );
|
||||
connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) );
|
||||
@@ -202,7 +202,7 @@ PianoRoll::PianoRoll() :
|
||||
signalMapper = new QSignalMapper( this );
|
||||
m_semiToneMarkerMenu = new QMenu( this );
|
||||
|
||||
QAction * markSemitoneAction = new QAction( tr("Mark/unmark current semitone"), this );
|
||||
QAction* markSemitoneAction = new QAction( tr("Mark/unmark current semitone"), this );
|
||||
QAction* markScaleAction = new QAction( tr("Mark current scale"), this );
|
||||
QAction* markChordAction = new QAction( tr("Mark current chord"), this );
|
||||
QAction* unmarkAllAction = new QAction( tr("Unmark all"), this );
|
||||
@@ -263,28 +263,23 @@ PianoRoll::PianoRoll() :
|
||||
}
|
||||
if( s_toolDraw == NULL )
|
||||
{
|
||||
s_toolDraw = new QPixmap( embed::getIconPixmap(
|
||||
"edit_draw" ) );
|
||||
s_toolDraw = new QPixmap( embed::getIconPixmap( "edit_draw" ) );
|
||||
}
|
||||
if( s_toolErase == NULL )
|
||||
{
|
||||
s_toolErase= new QPixmap( embed::getIconPixmap(
|
||||
"edit_erase" ) );
|
||||
s_toolErase= new QPixmap( embed::getIconPixmap( "edit_erase" ) );
|
||||
}
|
||||
if( s_toolSelect == NULL )
|
||||
{
|
||||
s_toolSelect = new QPixmap( embed::getIconPixmap(
|
||||
"edit_select" ) );
|
||||
s_toolSelect = new QPixmap( embed::getIconPixmap( "edit_select" ) );
|
||||
}
|
||||
if( s_toolMove == NULL )
|
||||
{
|
||||
s_toolMove = new QPixmap( embed::getIconPixmap(
|
||||
"edit_move" ) );
|
||||
s_toolMove = new QPixmap( embed::getIconPixmap( "edit_move" ) );
|
||||
}
|
||||
if( s_toolOpen == NULL )
|
||||
{
|
||||
s_toolOpen = new QPixmap( embed::getIconPixmap(
|
||||
"automation" ) );
|
||||
s_toolOpen = new QPixmap( embed::getIconPixmap( "automation" ) );
|
||||
}
|
||||
|
||||
// init text-float
|
||||
@@ -365,13 +360,13 @@ PianoRoll::PianoRoll() :
|
||||
|
||||
for( int i = 0; i < NUM_EVEN_LENGTHS; ++i )
|
||||
{
|
||||
m_noteLenModel.addItem( "1/" + QString::number( 1 << i ),
|
||||
new PixmapLoader( "note_" + pixmaps[i] ) );
|
||||
PixmapLoader *loader = new PixmapLoader( "note_" + pixmaps[i] );
|
||||
m_noteLenModel.addItem( "1/" + QString::number( 1 << i ), loader );
|
||||
}
|
||||
for( int i = 0; i < NUM_TRIPLET_LENGTHS; ++i )
|
||||
{
|
||||
m_noteLenModel.addItem( "1/" + QString::number( (1 << i) * 3 ),
|
||||
new PixmapLoader( "note_" + pixmaps[i+NUM_EVEN_LENGTHS] ) );
|
||||
PixmapLoader *loader = new PixmapLoader( "note_" + pixmaps[i+NUM_EVEN_LENGTHS] );
|
||||
m_noteLenModel.addItem( "1/" + QString::number( (1 << i) * 3 ), loader );
|
||||
}
|
||||
m_noteLenModel.setValue( 0 );
|
||||
|
||||
@@ -380,15 +375,14 @@ PianoRoll::PianoRoll() :
|
||||
this, SLOT( quantizeChanged() ) );
|
||||
|
||||
// Set up scale model
|
||||
|
||||
const InstrumentFunctionNoteStacking::ChordTable & chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance();
|
||||
const auto& chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance();
|
||||
|
||||
m_scaleModel.addItem( tr("No scale") );
|
||||
for( int i = 0; i < chord_table.size(); ++i )
|
||||
for( const InstrumentFunctionNoteStacking::Chord& chord : chord_table )
|
||||
{
|
||||
if( chord_table[i].isScale() )
|
||||
if( chord.isScale() )
|
||||
{
|
||||
m_scaleModel.addItem( chord_table[i].getName() );
|
||||
m_scaleModel.addItem( chord.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,11 +393,11 @@ PianoRoll::PianoRoll() :
|
||||
|
||||
// Set up chord model
|
||||
m_chordModel.addItem( tr("No chord") );
|
||||
for( int i = 0; i < chord_table.size(); ++i )
|
||||
for( const InstrumentFunctionNoteStacking::Chord& chord : chord_table )
|
||||
{
|
||||
if( ! chord_table[i].isScale() )
|
||||
if( ! chord.isScale() )
|
||||
{
|
||||
m_chordModel.addItem( chord_table[i].getName() );
|
||||
m_chordModel.addItem( chord.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +438,7 @@ void PianoRoll::changeNoteEditMode( int i )
|
||||
void PianoRoll::markSemiTone( int i )
|
||||
{
|
||||
const int key = getKey( mapFromGlobal( m_semiToneMarkerMenu->pos() ).y() );
|
||||
const InstrumentFunctionNoteStacking::Chord * chord = 0;
|
||||
const InstrumentFunctionNoteStacking::Chord * chord = nullptr;
|
||||
|
||||
switch( static_cast<SemiToneMarkerAction>( i ) )
|
||||
{
|
||||
@@ -453,10 +447,10 @@ void PianoRoll::markSemiTone( int i )
|
||||
break;
|
||||
case stmaMarkCurrentSemiTone:
|
||||
{
|
||||
QList<int>::iterator i = qFind( m_markedSemiTones.begin(), m_markedSemiTones.end(), key );
|
||||
if( i != m_markedSemiTones.end() )
|
||||
QList<int>::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<Note> 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};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user