NO-OP: whitespace
* distinguish comments and commented-out-code * add space after function, before bracket
This commit is contained in:
parent
8b925fc395
commit
9777baae00
|
@ -82,12 +82,12 @@ Editor::external_pt_dialog ()
|
|||
return;
|
||||
}
|
||||
|
||||
Gtk::FileChooserDialog dialog(_("Import PT Session"), FILE_CHOOSER_ACTION_OPEN);
|
||||
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
||||
Gtk::FileChooserDialog dialog (_("Import PT Session"), FILE_CHOOSER_ACTION_OPEN);
|
||||
dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
||||
|
||||
while (true) {
|
||||
int result = dialog.run();
|
||||
int result = dialog.run ();
|
||||
|
||||
if (result == Gtk::RESPONSE_OK) {
|
||||
ptpath = dialog.get_filename ();
|
||||
|
@ -99,8 +99,8 @@ Editor::external_pt_dialog ()
|
|||
}
|
||||
}
|
||||
|
||||
if (ptpath.length()) {
|
||||
do_ptimport(ptpath, SrcBest);
|
||||
if (ptpath.length ()) {
|
||||
do_ptimport (ptpath, SrcBest);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -123,18 +123,18 @@ Editor::do_ptimport (std::string ptpath,
|
|||
bool onefailed = false;
|
||||
PTFFormat ptf;
|
||||
samplepos_t pos = -1;
|
||||
uint32_t srate = _session->sample_rate();
|
||||
uint32_t srate = _session->sample_rate ();
|
||||
|
||||
vector<ptflookup_t> ptfwavpair;
|
||||
vector<ptflookup_t> ptfregpair;
|
||||
|
||||
if (ptf.load(ptpath, srate) == -1) {
|
||||
if (ptf.load (ptpath, srate) == -1) {
|
||||
MessageDialog msg (_("Doesn't seem to be a valid PT session file"));
|
||||
msg.run ();
|
||||
return;
|
||||
} else {
|
||||
MessageDialog msg (string_compose (_("PT v%1 Session @ %2Hz\n\n%3 audio files\n%4 audio regions\n%5 active audio regions\n%6 midi regions\n%7 active midi regions\n\nContinue..."), (int)ptf.version, ptf.sessionrate, ptf.audiofiles.size(), ptf.regions.size() - ptf.midiregions.size(), ptf.tracks.size(), ptf.midiregions.size(), ptf.miditracks.size()));
|
||||
msg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
MessageDialog msg (string_compose (_("PT v%1 Session @ %2Hz\n\n%3 audio files\n%4 audio regions\n%5 active audio regions\n%6 midi regions\n%7 active midi regions\n\nContinue..."), (int)ptf.version, ptf.sessionrate, ptf.audiofiles.size (), ptf.regions.size () - ptf.midiregions.size (), ptf.tracks.size (), ptf.midiregions.size (), ptf.miditracks.size ()));
|
||||
msg.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
|
||||
int result = msg.run ();
|
||||
if (result != Gtk::RESPONSE_OK) {
|
||||
|
@ -151,21 +151,21 @@ Editor::do_ptimport (std::string ptpath,
|
|||
SourceList just_one;
|
||||
SourceList imported;
|
||||
|
||||
for (vector<PTFFormat::wav_t>::iterator a = ptf.audiofiles.begin(); a != ptf.audiofiles.end(); ++a) {
|
||||
for (vector<PTFFormat::wav_t>::iterator a = ptf.audiofiles.begin (); a != ptf.audiofiles.end (); ++a) {
|
||||
ptflookup_t p;
|
||||
|
||||
fullpath = Glib::build_filename (Glib::path_get_dirname(ptpath), "Audio Files");
|
||||
fullpath = Glib::build_filename (Glib::path_get_dirname (ptpath), "Audio Files");
|
||||
fullpath = Glib::build_filename (fullpath, a->filename);
|
||||
to_import.clear ();
|
||||
to_import.push_back (fullpath);
|
||||
ipw.show ();
|
||||
ok = import_sndfiles (to_import, Editing::ImportDistinctFiles, Editing::ImportAsRegion, quality, pos, 1, -1, track, false, instrument);
|
||||
if (!import_status.sources.empty()) {
|
||||
if (!import_status.sources.empty ()) {
|
||||
p.index1 = a->index;
|
||||
p.id = import_status.sources.back()->id();
|
||||
p.id = import_status.sources.back ()->id ();
|
||||
|
||||
ptfwavpair.push_back(p);
|
||||
imported.push_back(import_status.sources.back());
|
||||
ptfwavpair.push_back (p);
|
||||
imported.push_back (import_status.sources.back ());
|
||||
} else {
|
||||
onefailed = true;
|
||||
}
|
||||
|
@ -179,15 +179,14 @@ Editor::do_ptimport (std::string ptpath,
|
|||
msg.run ();
|
||||
}
|
||||
|
||||
for (vector<PTFFormat::region_t>::iterator a = ptf.regions.begin();
|
||||
a != ptf.regions.end(); ++a) {
|
||||
for (vector<ptflookup_t>::iterator p = ptfwavpair.begin();
|
||||
p != ptfwavpair.end(); ++p) {
|
||||
if ((p->index1 == a->wave.index) && (strcmp(a->wave.filename.c_str(), "") != 0)) {
|
||||
for (SourceList::iterator x = imported.begin();
|
||||
x != imported.end(); ++x) {
|
||||
if ((*x)->id() == p->id) {
|
||||
// Matched an uncreated ptf region to ardour region
|
||||
for (vector<PTFFormat::region_t>::iterator a = ptf.regions.begin ();
|
||||
a != ptf.regions.end (); ++a) {
|
||||
for (vector<ptflookup_t>::iterator p = ptfwavpair.begin ();
|
||||
p != ptfwavpair.end (); ++p) {
|
||||
if ((p->index1 == a->wave.index) && (strcmp (a->wave.filename.c_str (), "") != 0)) {
|
||||
for (SourceList::iterator x = imported.begin (); x != imported.end (); ++x) {
|
||||
if ((*x)->id () == p->id) {
|
||||
/* Matched an uncreated ptf region to ardour region */
|
||||
ptflookup_t rp;
|
||||
PropertyList plist;
|
||||
|
||||
|
@ -199,15 +198,15 @@ Editor::do_ptimport (std::string ptpath,
|
|||
plist.add (ARDOUR::Properties::whole_file, false);
|
||||
plist.add (ARDOUR::Properties::external, true);
|
||||
|
||||
just_one.clear();
|
||||
just_one.push_back(*x);
|
||||
just_one.clear ();
|
||||
just_one.push_back (*x);
|
||||
|
||||
boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
|
||||
regions.push_back(r);
|
||||
regions.push_back (r);
|
||||
|
||||
rp.id = regions.back()->id();
|
||||
rp.id = regions.back ()->id ();
|
||||
rp.index1 = a->index;
|
||||
ptfregpair.push_back(rp);
|
||||
ptfregpair.push_back (rp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,44 +218,43 @@ Editor::do_ptimport (std::string ptpath,
|
|||
vector<ptflookup_t> usedtracks;
|
||||
ptflookup_t utr;
|
||||
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.tracks.begin();
|
||||
a != ptf.tracks.end(); ++a) {
|
||||
for (vector<ptflookup_t>::iterator p = ptfregpair.begin();
|
||||
p != ptfregpair.end(); ++p) {
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.tracks.begin (); a != ptf.tracks.end (); ++a) {
|
||||
for (vector<ptflookup_t>::iterator p = ptfregpair.begin ();
|
||||
p != ptfregpair.end (); ++p) {
|
||||
|
||||
if (p->index1 == a->reg.index) {
|
||||
// Matched a ptf active region to an ardour region
|
||||
/* Matched a ptf active region to an ardour region */
|
||||
utr.index1 = a->index;
|
||||
utr.index2 = nth;
|
||||
utr.id = p->id;
|
||||
boost::shared_ptr<Region> r = RegionFactory::region_by_id (p->id);
|
||||
vector<ptflookup_t>::iterator lookuptr = usedtracks.begin();
|
||||
vector<ptflookup_t>::iterator lookuptr = usedtracks.begin ();
|
||||
vector<ptflookup_t>::iterator found;
|
||||
if ((found = std::find(lookuptr, usedtracks.end(), utr)) != usedtracks.end()) {
|
||||
DEBUG_TRACE (DEBUG::FileUtils, string_compose ("\twav(%1) reg(%2) ptf_tr(%3) ard_tr(%4)\n", a->reg.wave.filename.c_str(), a->reg.index, found->index1, found->index2));
|
||||
existing_track = get_nth_selected_audio_track(found->index2);
|
||||
// Put on existing track
|
||||
boost::shared_ptr<Playlist> playlist = existing_track->playlist();
|
||||
if ((found = std::find (lookuptr, usedtracks.end (), utr)) != usedtracks.end ()) {
|
||||
DEBUG_TRACE (DEBUG::FileUtils, string_compose ("\twav(%1) reg(%2) ptf_tr(%3) ard_tr(%4)\n", a->reg.wave.filename.c_str (), a->reg.index, found->index1, found->index2));
|
||||
existing_track = get_nth_selected_audio_track (found->index2);
|
||||
/* Put on existing track */
|
||||
boost::shared_ptr<Playlist> playlist = existing_track->playlist ();
|
||||
boost::shared_ptr<Region> copy (RegionFactory::create (r, true));
|
||||
playlist->clear_changes ();
|
||||
playlist->add_region (copy, a->reg.startpos);
|
||||
//_session->add_command (new StatefulDiffCommand (playlist));
|
||||
} else {
|
||||
// Put on a new track
|
||||
DEBUG_TRACE (DEBUG::FileUtils, string_compose ("\twav(%1) reg(%2) new_tr(%3)\n", a->reg.wave.filename.c_str(), a->reg.index, nth));
|
||||
list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (1, 2, 0, 1, string(), PresentationInfo::max_order, Normal));
|
||||
if (at.empty()) {
|
||||
/* Put on a new track */
|
||||
DEBUG_TRACE (DEBUG::FileUtils, string_compose ("\twav(%1) reg(%2) new_tr(%3)\n", a->reg.wave.filename.c_str (), a->reg.index, nth));
|
||||
list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (1, 2, 0, 1, "", PresentationInfo::max_order, Normal));
|
||||
if (at.empty ()) {
|
||||
return;
|
||||
}
|
||||
existing_track = at.back();
|
||||
existing_track = at.back ();
|
||||
std::string trackname;
|
||||
try {
|
||||
trackname = Glib::convert_with_fallback (a->name, "UTF-8", "UTF-8", "_");
|
||||
} catch (Glib::ConvertError& err) {
|
||||
trackname = string_compose ("Invalid %1", a->index);
|
||||
}
|
||||
// TODO legalize track name (no slashes, no colons)
|
||||
#if 0 // TODO -- "find_route_name" is currently private
|
||||
/* TODO legalize track name (no slashes, no colons) */
|
||||
#if 0 /* TODO -- "find_route_name" is currently private */
|
||||
/* generate a unique name by adding a number if needed */
|
||||
uint32_t id = 0;
|
||||
if (!_session->find_route_name (trackname.c_str (), id, trackname, false)) {
|
||||
|
@ -272,12 +270,12 @@ Editor::do_ptimport (std::string ptpath,
|
|||
//_session->add_command (new StatefulDiffCommand (playlist));
|
||||
nth++;
|
||||
}
|
||||
usedtracks.push_back(utr);
|
||||
usedtracks.push_back (utr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MIDI - Find list of unique midi tracks first
|
||||
/* MIDI - Find list of unique midi tracks first */
|
||||
typedef struct midipair {
|
||||
uint16_t ptfindex;
|
||||
string trname;
|
||||
|
@ -287,26 +285,24 @@ Editor::do_ptimport (std::string ptpath,
|
|||
uint16_t ith = 0;
|
||||
bool found;
|
||||
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.miditracks.begin();
|
||||
a != ptf.miditracks.end(); ++a) {
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.miditracks.begin (); a != ptf.miditracks.end (); ++a) {
|
||||
found = false;
|
||||
for (vector<midipair_t>::iterator b = uniquetr.begin();
|
||||
b != uniquetr.end(); ++b) {
|
||||
for (vector<midipair_t>::iterator b = uniquetr.begin (); b != uniquetr.end (); ++b) {
|
||||
if (b->trname == a->name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
uniquetr.push_back({ith, a->name});
|
||||
uniquetr.push_back ({ith, a->name});
|
||||
//printf(" : %d : %s\n", ith, a->name.c_str());
|
||||
ith++;
|
||||
}
|
||||
}
|
||||
|
||||
// MIDI - Create unique midi tracks and a lookup table for used tracks
|
||||
for (vector<midipair_t>::iterator a = uniquetr.begin();
|
||||
a != uniquetr.end(); ++a) {
|
||||
/* MIDI - Create unique midi tracks and a lookup table for used tracks */
|
||||
for (vector<midipair_t>::iterator a = uniquetr.begin ();
|
||||
a != uniquetr.end (); ++a) {
|
||||
ptflookup_t miditr;
|
||||
list<boost::shared_ptr<MidiTrack> > mt (_session->new_midi_track (
|
||||
ChanCount (DataType::MIDI, 1),
|
||||
|
@ -320,32 +316,31 @@ Editor::do_ptimport (std::string ptpath,
|
|||
Normal));
|
||||
}
|
||||
|
||||
// Select all MIDI tracks by selecting all tracks then subsetting to midi
|
||||
select_all_tracks();
|
||||
/* Select all MIDI tracks by selecting all tracks then subsetting to midi */
|
||||
select_all_tracks ();
|
||||
|
||||
TrackViewList miditracks;
|
||||
MidiTimeAxisView* mtv;
|
||||
TrackSelection::iterator x;
|
||||
|
||||
for (x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
|
||||
for (x = selection->tracks.begin (); x != selection->tracks.end (); ++x) {
|
||||
|
||||
mtv = dynamic_cast<MidiTimeAxisView*>(*x);
|
||||
|
||||
if (!mtv) {
|
||||
continue;
|
||||
} else if (mtv->is_midi_track()) {
|
||||
miditracks.push_back(dynamic_cast<TimeAxisView*>(*x));
|
||||
} else if (mtv->is_midi_track ()) {
|
||||
miditracks.push_back (dynamic_cast<TimeAxisView*> (*x));
|
||||
}
|
||||
}
|
||||
|
||||
selection->set(miditracks);
|
||||
selection->set (miditracks);
|
||||
|
||||
// MIDI - Add midi regions one-by-one to corresponding midi tracks
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.miditracks.begin();
|
||||
a != ptf.miditracks.end(); ++a) {
|
||||
/* MIDI - Add midi regions one-by-one to corresponding midi tracks */
|
||||
for (vector<PTFFormat::track_t>::iterator a = ptf.miditracks.begin (); a != ptf.miditracks.end (); ++a) {
|
||||
|
||||
boost::shared_ptr<MidiTrack> midi_track = get_nth_selected_midi_track(a->index);
|
||||
boost::shared_ptr<Playlist> playlist = midi_track->playlist();
|
||||
boost::shared_ptr<MidiTrack> midi_track = get_nth_selected_midi_track (a->index);
|
||||
boost::shared_ptr<Playlist> playlist = midi_track->playlist ();
|
||||
samplepos_t f = (samplepos_t)a->reg.startpos * srate / 1920000.;
|
||||
samplecnt_t length = (samplecnt_t)a->reg.length * srate / 1920000.;
|
||||
MusicSample pos (f, 0);
|
||||
|
@ -353,27 +348,24 @@ Editor::do_ptimport (std::string ptpath,
|
|||
PropertyList plist;
|
||||
plist.add (ARDOUR::Properties::start, 0);
|
||||
plist.add (ARDOUR::Properties::length, length);
|
||||
plist.add (ARDOUR::Properties::name, PBD::basename_nosuffix(src->name()));
|
||||
//printf(" : %d - trackname: (%s)\n", a->index, src->name().c_str());
|
||||
plist.add (ARDOUR::Properties::name, PBD::basename_nosuffix (src->name ()));
|
||||
//printf(" : %d - trackname: (%s)\n", a->index, src->name ().c_str ());
|
||||
boost::shared_ptr<Region> region = (RegionFactory::create (src, plist));
|
||||
// sets beat position
|
||||
/* sets beat position */
|
||||
region->set_position (pos.sample, pos.division);
|
||||
midi_track->playlist()->add_region (region, pos.sample, 1.0, false, pos.division);
|
||||
midi_track->playlist ()->add_region (region, pos.sample, 1.0, false, pos.division);
|
||||
|
||||
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
|
||||
boost::shared_ptr<MidiModel> mm = mr->midi_source(0)->model();
|
||||
boost::shared_ptr<MidiModel> mm = mr->midi_source (0)->model ();
|
||||
MidiModel::NoteDiffCommand *midicmd;
|
||||
midicmd = mm->new_note_diff_command ("Import ProTools MIDI");
|
||||
|
||||
for (vector<PTFFormat::midi_ev_t>::iterator
|
||||
j = a->reg.midi.begin();
|
||||
j != a->reg.midi.end(); ++j) {
|
||||
for (vector<PTFFormat::midi_ev_t>::iterator j = a->reg.midi.begin (); j != a->reg.midi.end (); ++j) {
|
||||
//printf(" : MIDI : pos=%f len=%f\n", (float)j->pos / 960000., (float)j->length / 960000.);
|
||||
Temporal::Beats start = (Temporal::Beats)(j->pos / 960000.);
|
||||
Temporal::Beats len = (Temporal::Beats)(j->length / 960000.);
|
||||
// PT C-2 = 0, Ardour C-1 = 0, subtract twelve to convert ?
|
||||
midicmd->add(boost::shared_ptr<Evoral::Note<Temporal::Beats> >
|
||||
(new Evoral::Note<Temporal::Beats>( (uint8_t)1, start, len, j->note, j->velocity )));
|
||||
/* PT C-2 = 0, Ardour C-1 = 0, subtract twelve to convert ? */
|
||||
midicmd->add (boost::shared_ptr<Evoral::Note<Temporal::Beats> > (new Evoral::Note<Temporal::Beats> ((uint8_t)1, start, len, j->note, j->velocity)));
|
||||
}
|
||||
mm->apply_command (_session, midicmd);
|
||||
boost::shared_ptr<Region> copy (RegionFactory::create (mr, true));
|
||||
|
@ -381,7 +373,7 @@ Editor::do_ptimport (std::string ptpath,
|
|||
playlist->add_region (copy, f);
|
||||
}
|
||||
|
||||
import_status.sources.clear();
|
||||
import_status.sources.clear ();
|
||||
|
||||
if (ok) {
|
||||
_session->save_state ("");
|
||||
|
|
Loading…
Reference in New Issue