mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-21 06:06:25 +01:00
Implement out-of-place MidiBuffer::merge.
Completely untested. git-svn-id: svn://localhost/ardour2/branches/3.0@5817 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
09990dd26d
commit
55ba5c60b3
1 changed files with 29 additions and 4 deletions
|
|
@ -324,14 +324,39 @@ MidiBuffer::merge(const MidiBuffer& a, const MidiBuffer& b)
|
||||||
_size = 0;
|
_size = 0;
|
||||||
|
|
||||||
if (this == &a) {
|
if (this == &a) {
|
||||||
merge_in_place(b);
|
return merge_in_place(b);
|
||||||
|
} else if (this == &b) {
|
||||||
|
return merge_in_place(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this == &b) {
|
const_iterator ai = a.begin();
|
||||||
merge_in_place(a);
|
const_iterator bi = b.begin();
|
||||||
|
|
||||||
|
resize(a.size() + b.size());
|
||||||
|
while (ai != a.end() && bi != b.end()) {
|
||||||
|
if ((*ai).time() < (*bi).time()) {
|
||||||
|
memcpy(_data + _size, (*ai).buffer(), (*ai).size());
|
||||||
|
_size += (*ai).size();
|
||||||
|
++ai;
|
||||||
|
} else {
|
||||||
|
memcpy(_data + _size, (*bi).buffer(), (*bi).size());
|
||||||
|
_size += (*bi).size();
|
||||||
|
++bi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (ai != a.end()) {
|
||||||
|
memcpy(_data + _size, (*ai).buffer(), (*ai).size());
|
||||||
|
_size += (*ai).size();
|
||||||
|
++ai;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (bi != b.end()) {
|
||||||
|
memcpy(_data + _size, (*bi).buffer(), (*bi).size());
|
||||||
|
_size += (*bi).size();
|
||||||
|
++bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "FIXME: MIDI BUFFER MERGE" << endl;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue