mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
import process now allows optional import of MIDI markers/cues
This commit is contained in:
parent
f689e9ecab
commit
3e47057609
6 changed files with 80 additions and 15 deletions
|
|
@ -462,7 +462,9 @@ public:
|
||||||
ARDOUR::MidiTrackNameSource mts,
|
ARDOUR::MidiTrackNameSource mts,
|
||||||
ARDOUR::MidiTempoMapDisposition mtd,
|
ARDOUR::MidiTempoMapDisposition mtd,
|
||||||
samplepos_t& pos,
|
samplepos_t& pos,
|
||||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
|
||||||
|
bool with_markers = false
|
||||||
|
);
|
||||||
|
|
||||||
void do_embed (std::vector<std::string> paths,
|
void do_embed (std::vector<std::string> paths,
|
||||||
Editing::ImportDisposition disposition,
|
Editing::ImportDisposition disposition,
|
||||||
|
|
@ -1460,6 +1462,7 @@ private:
|
||||||
void import_audio (bool as_tracks);
|
void import_audio (bool as_tracks);
|
||||||
void do_import (std::vector<std::string> paths, bool split, bool as_tracks);
|
void do_import (std::vector<std::string> paths, bool split, bool as_tracks);
|
||||||
void import_smf_tempo_map (Evoral::SMF const &, samplepos_t pos);
|
void import_smf_tempo_map (Evoral::SMF const &, samplepos_t pos);
|
||||||
|
void import_smf_markers (Evoral::SMF &, samplepos_t pos);
|
||||||
void move_to_start ();
|
void move_to_start ();
|
||||||
void move_to_end ();
|
void move_to_end ();
|
||||||
void center_playhead ();
|
void center_playhead ();
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,33 @@ Editor::import_smf_tempo_map (Evoral::SMF const & smf, samplepos_t pos)
|
||||||
_session->tempo_map() = new_map;
|
_session->tempo_map() = new_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Editor::import_smf_markers (Evoral::SMF & smf, samplepos_t pos)
|
||||||
|
{
|
||||||
|
if (!_session) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
smf.load_markers ();
|
||||||
|
|
||||||
|
Evoral::SMF::Markers const & markers = smf.markers();
|
||||||
|
|
||||||
|
if (markers.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX in nutempo2 just add location using Beats */
|
||||||
|
|
||||||
|
for (Evoral::SMF::Markers::const_iterator m = markers.begin(); m != markers.end(); ++m) {
|
||||||
|
// Temporal::Beats beat_pos (m->time_pulses / (double) smf.ppqn() / 4.0);
|
||||||
|
double beat = m->time_pulses / (double) smf.ppqn() / 4.0;
|
||||||
|
samplepos_t samplepos = pos + _session->tempo_map().sample_at_beat (beat);
|
||||||
|
Location* loc = new Location (*_session, samplepos, samplepos_t (0), m->text, Location::IsMark, 0);
|
||||||
|
_session->locations()->add (loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::do_import (vector<string> paths,
|
Editor::do_import (vector<string> paths,
|
||||||
ImportDisposition disposition,
|
ImportDisposition disposition,
|
||||||
|
|
@ -321,28 +348,50 @@ Editor::do_import (vector<string> paths,
|
||||||
MidiTrackNameSource midi_track_name_source,
|
MidiTrackNameSource midi_track_name_source,
|
||||||
MidiTempoMapDisposition smf_tempo_disposition,
|
MidiTempoMapDisposition smf_tempo_disposition,
|
||||||
samplepos_t& pos,
|
samplepos_t& pos,
|
||||||
ARDOUR::PluginInfoPtr instrument)
|
ARDOUR::PluginInfoPtr instrument,
|
||||||
|
bool with_markers)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Track> track;
|
boost::shared_ptr<Track> track;
|
||||||
vector<string> to_import;
|
vector<string> to_import;
|
||||||
int nth = 0;
|
int nth = 0;
|
||||||
bool use_timestamp = (pos == -1);
|
bool use_timestamp = (pos == -1);
|
||||||
|
|
||||||
if (smf_tempo_disposition == SMFTempoUse) {
|
/* XXX nutempo2: we will import markers using music (beat) time, which
|
||||||
/* Find the first MIDI file with a tempo map, and import it
|
will make any imported tempo map irrelevant. Not doing that (in 6.7,
|
||||||
before we do anything else.
|
before nutempo2) is much more complicated because we don't know
|
||||||
|
which file may have the tempo map, and if we're importing that
|
||||||
|
it will change the marker positions. So for now, there's an implicit
|
||||||
|
limitation that if you import more than 1 MIDI file and the first
|
||||||
|
has markers but the second has the tempo map, the markers could be
|
||||||
|
in the wrong position.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (with_markers || (smf_tempo_disposition == SMFTempoUse)) {
|
||||||
|
|
||||||
|
bool tempo_map_done = false;
|
||||||
|
|
||||||
for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
|
for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
|
||||||
|
|
||||||
Evoral::SMF smf;
|
Evoral::SMF smf;
|
||||||
|
|
||||||
if (smf.open (*a)) {
|
if (smf.open (*a)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the first MIDI file with a tempo map, and import it
|
||||||
|
before we do anything else.
|
||||||
|
*/
|
||||||
|
if (!tempo_map_done && smf_tempo_disposition == SMFTempoUse) {
|
||||||
if (smf.num_tempos() > 0) {
|
if (smf.num_tempos() > 0) {
|
||||||
import_smf_tempo_map (smf, pos);
|
import_smf_tempo_map (smf, pos);
|
||||||
smf.close ();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (with_markers) {
|
||||||
|
|
||||||
|
import_smf_markers (smf, pos);
|
||||||
|
}
|
||||||
|
|
||||||
smf.close ();
|
smf.close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, samplepos_t sample, do
|
||||||
/* drop onto canvas background: create new tracks */
|
/* drop onto canvas background: create new tracks */
|
||||||
|
|
||||||
InstrumentSelector is; // instantiation builds instrument-list and sets default.
|
InstrumentSelector is; // instantiation builds instrument-list and sets default.
|
||||||
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, sample, is.selected_instrument());
|
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, sample, is.selected_instrument(), false);
|
||||||
|
|
||||||
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
||||||
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
|
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
|
||||||
|
|
@ -450,7 +450,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, samplepos_t sample, do
|
||||||
|
|
||||||
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
||||||
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,
|
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,
|
||||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample);
|
SrcBest, SMFTrackName, SMFTempoIgnore, sample, boost::shared_ptr<PluginInfo>(), false);
|
||||||
} else {
|
} else {
|
||||||
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, sample);
|
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, sample);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,8 @@ public:
|
||||||
/** Import existing media */
|
/** Import existing media */
|
||||||
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality,
|
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality,
|
||||||
ARDOUR::MidiTrackNameSource, ARDOUR::MidiTempoMapDisposition, samplepos_t&,
|
ARDOUR::MidiTrackNameSource, ARDOUR::MidiTempoMapDisposition, samplepos_t&,
|
||||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument=boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
|
||||||
|
bool with_markers = false) = 0;
|
||||||
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,
|
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,
|
||||||
samplepos_t&,
|
samplepos_t&,
|
||||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
||||||
|
|
|
||||||
|
|
@ -1764,6 +1764,7 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s,
|
||||||
, instrument_combo (false)
|
, instrument_combo (false)
|
||||||
, copy_files_btn ( _("Copy files to session"))
|
, copy_files_btn ( _("Copy files to session"))
|
||||||
, smf_tempo_btn (_("Use MIDI Tempo Map (if defined)"))
|
, smf_tempo_btn (_("Use MIDI Tempo Map (if defined)"))
|
||||||
|
, smf_marker_btn (_("Import MIDI markers (if any)"))
|
||||||
, selected_audio_track_cnt (selected_audio_tracks)
|
, selected_audio_track_cnt (selected_audio_tracks)
|
||||||
, selected_midi_track_cnt (selected_midi_tracks)
|
, selected_midi_track_cnt (selected_midi_tracks)
|
||||||
, _import_active (false)
|
, _import_active (false)
|
||||||
|
|
@ -1815,6 +1816,7 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s,
|
||||||
options.attach (midi_track_name_combo, 2, 3, 1, 2, FILL, SHRINK, 8, 0);
|
options.attach (midi_track_name_combo, 2, 3, 1, 2, FILL, SHRINK, 8, 0);
|
||||||
|
|
||||||
options.attach (smf_tempo_btn, 2, 3, 3, 4, FILL, SHRINK, 8, 0);
|
options.attach (smf_tempo_btn, 2, 3, 3, 4, FILL, SHRINK, 8, 0);
|
||||||
|
options.attach (smf_marker_btn, 2, 3, 4, 5, FILL, SHRINK, 8, 0);
|
||||||
|
|
||||||
l = manage (new Label);
|
l = manage (new Label);
|
||||||
l->set_markup (_("<b>Instrument</b>"));
|
l->set_markup (_("<b>Instrument</b>"));
|
||||||
|
|
@ -1992,6 +1994,13 @@ SoundFileOmega::get_use_smf_tempo_map () const
|
||||||
return smf_tempo_btn.get_active ();
|
return smf_tempo_btn.get_active ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SoundFileOmega::get_use_smf_markers () const
|
||||||
|
{
|
||||||
|
return smf_marker_btn.get_active ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImportDisposition
|
ImportDisposition
|
||||||
SoundFileOmega::get_channel_disposition () const
|
SoundFileOmega::get_channel_disposition () const
|
||||||
{
|
{
|
||||||
|
|
@ -2068,6 +2077,7 @@ SoundFileOmega::do_something (int action)
|
||||||
samplepos_t where;
|
samplepos_t where;
|
||||||
MidiTrackNameSource mts = get_midi_track_name_source ();
|
MidiTrackNameSource mts = get_midi_track_name_source ();
|
||||||
MidiTempoMapDisposition mtd = (get_use_smf_tempo_map () ? SMFTempoUse : SMFTempoIgnore);
|
MidiTempoMapDisposition mtd = (get_use_smf_tempo_map () ? SMFTempoUse : SMFTempoIgnore);
|
||||||
|
bool with_midi_markers = get_use_smf_markers ();
|
||||||
|
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case ImportAtEditPoint:
|
case ImportAtEditPoint:
|
||||||
|
|
@ -2089,7 +2099,7 @@ SoundFileOmega::do_something (int action)
|
||||||
_import_active = true;
|
_import_active = true;
|
||||||
|
|
||||||
if (copy_files_btn.get_active()) {
|
if (copy_files_btn.get_active()) {
|
||||||
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument);
|
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument, with_midi_markers);
|
||||||
} else {
|
} else {
|
||||||
PublicEditor::instance().do_embed (paths, chns, mode, where, instrument);
|
PublicEditor::instance().do_embed (paths, chns, mode, where, instrument);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -302,11 +302,13 @@ public:
|
||||||
|
|
||||||
Gtk::CheckButton copy_files_btn;
|
Gtk::CheckButton copy_files_btn;
|
||||||
Gtk::CheckButton smf_tempo_btn;
|
Gtk::CheckButton smf_tempo_btn;
|
||||||
|
Gtk::CheckButton smf_marker_btn;
|
||||||
|
|
||||||
void set_mode (Editing::ImportMode);
|
void set_mode (Editing::ImportMode);
|
||||||
Editing::ImportMode get_mode() const;
|
Editing::ImportMode get_mode() const;
|
||||||
ARDOUR::MidiTrackNameSource get_midi_track_name_source () const;
|
ARDOUR::MidiTrackNameSource get_midi_track_name_source () const;
|
||||||
bool get_use_smf_tempo_map () const;
|
bool get_use_smf_tempo_map () const;
|
||||||
|
bool get_use_smf_markers () const;
|
||||||
Editing::ImportPosition get_position() const;
|
Editing::ImportPosition get_position() const;
|
||||||
Editing::ImportDisposition get_channel_disposition() const;
|
Editing::ImportDisposition get_channel_disposition() const;
|
||||||
ARDOUR::SrcQuality get_src_quality() const;
|
ARDOUR::SrcQuality get_src_quality() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue