Merge pull request #3881 from zonkmachine/arppatternsort
Note sorting algorithm rework
This commit is contained in:
@@ -213,28 +213,7 @@ Note * Pattern::addNote( const Note & _new_note, const bool _quant_pos )
|
||||
}
|
||||
|
||||
instrumentTrack()->lock();
|
||||
if( m_notes.size() == 0 || m_notes.back()->pos() <= new_note->pos() )
|
||||
{
|
||||
m_notes.push_back( new_note );
|
||||
}
|
||||
else
|
||||
{
|
||||
// simple algorithm for inserting the note between two
|
||||
// notes with smaller and greater position
|
||||
// maybe it could be optimized by starting in the middle and
|
||||
// going forward or backward but note-inserting isn't that
|
||||
// time-critical since it is usually not done while playing...
|
||||
long new_note_abs_time = new_note->pos();
|
||||
NoteVector::Iterator it = m_notes.begin();
|
||||
|
||||
while( it != m_notes.end() &&
|
||||
( *it )->pos() < new_note_abs_time )
|
||||
{
|
||||
++it;
|
||||
}
|
||||
|
||||
m_notes.insert( it, new_note );
|
||||
}
|
||||
m_notes.insert(std::upper_bound(m_notes.begin(), m_notes.end(), new_note, Note::lessThan), new_note);
|
||||
instrumentTrack()->unlock();
|
||||
|
||||
checkType();
|
||||
@@ -292,7 +271,7 @@ Note * Pattern::noteAtStep( int _step )
|
||||
void Pattern::rearrangeAllNotes()
|
||||
{
|
||||
// sort notes by start time
|
||||
qSort(m_notes.begin(), m_notes.end(), Note::lessThan );
|
||||
std::sort(m_notes.begin(), m_notes.end(), Note::lessThan);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user