/*
- Copyright (C) 2000-2006 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2016 Nick Mainsbridge <mainsbridge@gmail.com>
+ * Copyright (C) 2017 Paul Davis <paul@linuxaudiosystems.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include <iostream>
#include <cstdlib>
#include "ardour/source_factory.h"
#include "ardour/tempo.h"
-#include "evoral/Note.hpp"
-#include "evoral/Sequence.hpp"
+#include "evoral/Note.h"
+#include "evoral/Sequence.h"
#include "common.h"
for (Evoral::Sequence<MidiModel::TimeType>::const_iterator i = bbt_source->model()->begin(MidiModel::TimeType(), true); i != bbt_source->model()->end(); ++i) {
const double new_time = map.quarter_note_at_beat ((*i).time().to_double() + map.beat_at_quarter_note (session_offset * 4.0)) - (session_offset * 4.0);
- Evoral::Event<Evoral::Beats> new_ev (*i, true);
- new_ev.set_time (Evoral::Beats (new_time));
+ Evoral::Event<Temporal::Beats> new_ev (*i, true);
+ new_ev.set_time (Temporal::Beats (new_time));
source->append_event_beats (source_lock, new_ev);
}
bbt_source->model()->set_percussive (old_percussive);
source->mark_streaming_write_completed (source_lock);
- source->set_timeline_position (bbt_source->timeline_position());
+ source->set_natural_position (bbt_source->natural_position());
return true;
}
} else {
newsrc = boost::dynamic_pointer_cast<MidiSource>(
SourceFactory::createWritable(DataType::MIDI, *session,
- newsrc_path, false, session->frame_rate()));
+ newsrc_path, false, session->sample_rate()));
if (!newsrc) {
cout << UTILNAME << ":" << endl
Source::Lock newsrc_lock (newsrc->mutex());
- write_bbt_source_to_source (region->midi_source(0), newsrc, newsrc_lock, (region->pos_beats() - region->start_beats()) / 4.0);
+ write_bbt_source_to_source (region->midi_source(0), newsrc, newsrc_lock, (region->quarter_note() - region->start_beats()) / 4.0);
cout << UTILNAME << ":" << endl
<< " Created new midi source file" << endl
newsrc = boost::dynamic_pointer_cast<MidiSource>(
SourceFactory::createWritable(DataType::MIDI, *session,
- newsrc_path, false, session->frame_rate()));
+ newsrc_path, false, session->sample_rate()));
if (!newsrc) {
cout << UTILNAME << ":" << endl
<<" An error occurred creating writeable source " << newsrc_path << " exiting." << endl;
Source::Lock newsrc_lock (newsrc->mutex());
- write_bbt_source_to_source (region->midi_source(0), newsrc, newsrc_lock, (region->pos_beats() - region->start_beats()) / 4.0);
+ write_bbt_source_to_source (region->midi_source(0), newsrc, newsrc_lock, (region->quarter_note() - region->start_beats()) / 4.0);
cout << UTILNAME << ":" << endl
<< " Created new midi source file" << endl
/* force a change to start and start_beats */
PositionLockStyle old_pls = region->position_lock_style();
region->set_position_lock_style (AudioTime);
- region->set_start (tmap.frame_at_quarter_note (region->pos_beats()) - tmap.frame_at_quarter_note (region->pos_beats() - new_start_qn) + 1);
- region->set_start (tmap.frame_at_quarter_note (region->pos_beats()) - tmap.frame_at_quarter_note (region->pos_beats() - new_start_qn));
+ region->set_start (tmap.sample_at_quarter_note (region->quarter_note()) - tmap.sample_at_quarter_note (region->quarter_note() - new_start_qn) + 1);
+ region->set_start (tmap.sample_at_quarter_note (region->quarter_note()) - tmap.sample_at_quarter_note (region->quarter_note() - new_start_qn));
region->set_position_lock_style (old_pls);
}
/* force a change to length and length_beats */
PositionLockStyle old_pls = region->position_lock_style();
region->set_position_lock_style (AudioTime);
- region->set_length (tmap.frame_at_quarter_note (region->pos_beats() + new_length_qn) + 1 - region->position(), 0);
- region->set_length (tmap.frame_at_quarter_note (region->pos_beats() + new_length_qn)- region->position(), 0);
+ region->set_length (tmap.sample_at_quarter_note (region->quarter_note() + new_length_qn) + 1 - region->position(), 0);
+ region->set_length (tmap.sample_at_quarter_note (region->quarter_note() + new_length_qn)- region->position(), 0);
region->set_position_lock_style (old_pls);
}
return true;
}
-static void usage (int status) {
+static void usage () {
// help2man compatible format (standard GNU help-text)
printf (UTILNAME " - convert an ardour session with 5.0 - 5.3 midi sources to be compatible with 5.4.\n\n");
printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> <snapshot-name>\n\n");
printf ("Report bugs to <http://tracker.ardour.org/>\n"
"Website: <http://ardour.org/>\n");
- ::exit (status);
+ ::exit (EXIT_SUCCESS);
}
int main (int argc, char* argv[])
case 'o':
outfile = optarg;
- if (outfile.empty()) {
- usage (0);
- }
break;
case 'V':
printf ("ardour-utils version %s\n\n", VERSIONSTRING);
printf ("Copyright (C) GPL 2015 Robin Gareus <robin@gareus.org>\n");
- exit (0);
+ exit (EXIT_SUCCESS);
break;
case 'h':
- usage (0);
+ usage ();
break;
default:
- usage (EXIT_FAILURE);
+ cerr << "Error: unrecognized option. See --help for usage information.\n";
+ ::exit (EXIT_FAILURE);
break;
}
}
if (optind + 2 > argc) {
- usage (EXIT_FAILURE);
+ cerr << "Error: Missing parameter. See --help for usage information.\n";
+ ::exit (EXIT_FAILURE);
}
SessionDirectory* session_dir = new SessionDirectory (argv[optind]);