mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-14 10:36:34 +01:00
allow ARDOUR::Filter to be used with MIDI regions/sources
This commit is contained in:
parent
76a0b3c70e
commit
ae32daa148
2 changed files with 39 additions and 43 deletions
|
|
@ -6155,60 +6155,58 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress
|
||||||
RegionSelection::iterator tmp = r;
|
RegionSelection::iterator tmp = r;
|
||||||
++tmp;
|
++tmp;
|
||||||
|
|
||||||
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
|
RegionView* const rv = *r;
|
||||||
if (arv) {
|
boost::shared_ptr<Playlist> playlist = rv->region()->playlist();
|
||||||
boost::shared_ptr<Playlist> playlist = arv->region()->playlist();
|
|
||||||
|
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress->descend (1.0 / N);
|
progress->descend (1.0 / N);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rv->region()->apply (filter, progress) == 0) {
|
||||||
|
|
||||||
|
playlist->clear_changes ();
|
||||||
|
playlist->clear_owned_changes ();
|
||||||
|
|
||||||
|
if (!in_command) {
|
||||||
|
begin_reversible_command (command);
|
||||||
|
in_command = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arv->audio_region()->apply (filter, progress) == 0) {
|
if (filter.results.empty ()) {
|
||||||
|
|
||||||
playlist->clear_changes ();
|
/* no regions returned; remove the old one */
|
||||||
playlist->clear_owned_changes ();
|
// playlist->remove_region (rv->region ());
|
||||||
|
|
||||||
if (!in_command) {
|
} else {
|
||||||
begin_reversible_command (command);
|
|
||||||
in_command = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filter.results.empty ()) {
|
playlist->freeze ();
|
||||||
|
std::vector<boost::shared_ptr<Region> >::iterator res = filter.results.begin ();
|
||||||
|
|
||||||
/* no regions returned; remove the old one */
|
/* first region replaces the old one */
|
||||||
playlist->remove_region (arv->region ());
|
playlist->replace_region (rv->region(), *res, (*res)->position());
|
||||||
|
++res;
|
||||||
|
|
||||||
} else {
|
/* add the rest */
|
||||||
|
while (res != filter.results.end()) {
|
||||||
playlist->freeze ();
|
playlist->add_region (*res, (*res)->position());
|
||||||
std::vector<boost::shared_ptr<Region> >::iterator res = filter.results.begin ();
|
|
||||||
|
|
||||||
/* first region replaces the old one */
|
|
||||||
playlist->replace_region (arv->region(), *res, (*res)->position());
|
|
||||||
++res;
|
++res;
|
||||||
|
|
||||||
/* add the rest */
|
|
||||||
while (res != filter.results.end()) {
|
|
||||||
playlist->add_region (*res, (*res)->position());
|
|
||||||
++res;
|
|
||||||
}
|
|
||||||
playlist->thaw ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
playlist->thaw ();
|
||||||
|
|
||||||
/* We might have removed regions, which alters other regions' layering_index,
|
|
||||||
so we need to do a recursive diff here.
|
|
||||||
*/
|
|
||||||
vector<Command*> cmds;
|
|
||||||
playlist->rdiff (cmds);
|
|
||||||
_session->add_commands (cmds);
|
|
||||||
|
|
||||||
_session->add_command(new StatefulDiffCommand (playlist));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress) {
|
/* We might have removed regions, which alters other regions' layering_index,
|
||||||
progress->ascend ();
|
so we need to do a recursive diff here.
|
||||||
}
|
*/
|
||||||
|
vector<Command*> cmds;
|
||||||
|
playlist->rdiff (cmds);
|
||||||
|
_session->add_commands (cmds);
|
||||||
|
|
||||||
|
_session->add_command(new StatefulDiffCommand (playlist));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progress) {
|
||||||
|
progress->ascend ();
|
||||||
}
|
}
|
||||||
|
|
||||||
r = tmp;
|
r = tmp;
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,6 @@ Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, s
|
||||||
|
|
||||||
if (aregion) {
|
if (aregion) {
|
||||||
sample_rate = aregion->audio_source()->sample_rate();
|
sample_rate = aregion->audio_source()->sample_rate();
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue