#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <errno.h>
#include <unistd.h>
Editor::external_audio_dialog ()
{
vector<Glib::ustring> paths;
+ uint32_t track_cnt;
if (session == 0) {
MessageDialog msg (0, _("You can't import or embed an audiofile until you have a session loaded."));
return;
}
+ track_cnt = 0;
+
+ for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
+ AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*x);
+
+ if (!atv) {
+ continue;
+ } else if (atv->is_audio_track()) {
+ track_cnt++;
+ }
+ }
+
if (sfbrowser == 0) {
- sfbrowser = new SoundFileOmega (*this, _("Add existing audio"), session, selection->tracks.size());
+ sfbrowser = new SoundFileOmega (*this, _("Add existing audio"), session, track_cnt);
} else {
- sfbrowser->reset (selection->tracks.size());
+ sfbrowser->reset (track_cnt);
}
sfbrowser->show_all ();
case RESPONSE_OK:
sfbrowser->hide ();
break;
+
default:
// cancel from the browser - we are done
sfbrowser->hide ();
break;
}
+ SrcQuality quality = sfbrowser->get_src_quality();
+
if (sfbrowser->copy_files_btn.get_active()) {
- do_import (paths, chns, mode, where);
+ do_import (paths, chns, mode, quality, where);
} else {
do_embed (paths, chns, mode, where);
}
if (response == RESPONSE_APPLY) {
+ sfbrowser->clear_selection ();
goto again;
}
}
TrackSelection::iterator x;
for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
- if (dynamic_cast<AudioTimeAxisView*>(*x)) {
+
+ atv = dynamic_cast<AudioTimeAxisView*>(*x);
+
+ if (!atv) {
+ continue;
+ } else if (atv->is_audio_track()) {
--nth;
}
}
atv = dynamic_cast<AudioTimeAxisView*>(*x);
}
- if (!atv) {
+ if (!atv || !atv->is_audio_track()) {
return boost::shared_ptr<AudioTrack>();
}
}
void
-Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mode, nframes64_t& pos)
+Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mode, SrcQuality quality, nframes64_t& pos)
{
boost::shared_ptr<AudioTrack> track;
vector<ustring> to_import;
track = get_nth_selected_audio_track (nth++);
}
- if (import_sndfiles (to_import, mode, pos, 1, -1, track)) {
+ if (import_sndfiles (to_import, mode, quality, pos, 1, -1, track)) {
goto out;
}
to_import.clear ();
to_import.push_back (*a);
- if (import_sndfiles (to_import, mode, pos, -1, -1, track)) {
+ if (import_sndfiles (to_import, mode, quality, pos, -1, -1, track)) {
goto out;
}
/* create 1 region from all paths, add to 1 track,
ignore "track"
*/
- if (import_sndfiles (paths, mode, pos, 1, 1, track)) {
+ if (import_sndfiles (paths, mode, quality, pos, 1, 1, track)) {
goto out;
}
break;
reuse "track" across paths
*/
- if (import_sndfiles (to_import, mode, pos, 1, 1, track)) {
+ if (import_sndfiles (to_import, mode, quality, pos, 1, 1, track)) {
goto out;
}
}
int
-Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, nframes64_t& pos,
+Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality quality, nframes64_t& pos,
int target_regions, int target_tracks, boost::shared_ptr<AudioTrack>& track)
{
WindowTitle title = string_compose (_("importing %1"), paths.front());
import_status.cancel = false;
import_status.freeze = false;
import_status.done = 0.0;
-
+ import_status.quality = quality;
+
interthread_progress_connection = Glib::signal_timeout().connect
(bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100);
region_name = region_name_from_path (afs->path(), false, true, sources.size(), n);
- cerr << "got region name " << region_name << endl;
-
regions.push_back (boost::dynamic_pointer_cast<AudioRegion>
(RegionFactory::create (just_one, 0, (*x)->length(), region_name, 0,
Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External))));
for (vector<boost::shared_ptr<AudioRegion> >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) {
finish_bringing_in_audio (*r, input_chan, output_chan, pos, mode, track);
-
+
if (target_tracks != 1) {
track.reset ();
} else {
}
}
+ /* setup peak file building in another thread */
+
+ for (SourceList::iterator x = sources.begin(); x != sources.end(); ++x) {
+ SourceFactory::setup_peakfile (*x, true);
+ }
+
return 0;
}
Editor::finish_bringing_in_audio (boost::shared_ptr<AudioRegion> region, uint32_t in_chans, uint32_t out_chans, nframes64_t& pos,
ImportMode mode, boost::shared_ptr<AudioTrack>& existing_track)
{
-
switch (mode) {
case ImportAsRegion:
/* relax, its been done */
{
if (!existing_track) {
- if (selection->tracks.empty()) {
- return -1;
- }
-
- AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(selection->tracks.front());
-
- if (!atv) {
+ existing_track = get_nth_selected_audio_track (0);
+
+ if (!existing_track) {
return -1;
}
-
- existing_track = atv->audio_track();
}
boost::shared_ptr<Playlist> playlist = existing_track->diskstream()->playlist();