26 #include <gtkmm/messagedialog.h>
28 #include <glib/gstdio.h>
65 ExportDialog dialog (*
this,
_(
"Export"), ExportProfileManager::RegularExport);
91 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data (
"marker"))) == 0) {
92 fatal <<
_(
"programming error: marker canvas item has no marker object pointer!") <<
endmsg;
99 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->
end() > l->
start())) {
110 if (selection->regions.empty()) {
120 RouteTimeAxisView & rtv (dynamic_cast<RouteTimeAxisView &> (selection->regions.front()->get_time_axis_view()));
127 }
else if (midi_region) {
131 int ret = dialog.run ();
133 case Gtk::RESPONSE_ACCEPT:
143 if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
145 MessageDialog checker (
_(
"File Exists!"),
147 Gtk::MESSAGE_WARNING,
150 checker.set_title (
_(
"File Exists!"));
152 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
153 checker.add_button (
_(
"Overwrite Existing File"), RESPONSE_ACCEPT);
154 checker.set_default_response (RESPONSE_CANCEL);
156 checker.set_wmclass (
X_(
"midi_export_file_exists"), PROGRAM_NAME);
157 checker.set_position (Gtk::WIN_POS_MOUSE);
159 ret = checker.run ();
162 case Gtk::RESPONSE_ACCEPT:
167 ::g_unlink (path.c_str());
175 (void) midi_region->clone (path);
182 for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
205 for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
215 if (with_processing) {
216 r = track->
bounce_range (region->position(), region->position() + region->length(), itt, track->
main_outs(),
false);
230 gain_t gain_buffer[chunk_size];
234 vector<boost::shared_ptr<AudioFileSource> > sources;
237 const string sound_directory = _session->session_directory().sound_path();
248 if (path.length() == 0) {
250 for (uint32_t n=0; n < nchans; ++n) {
252 for (cnt = 0; cnt < 999999; ++cnt) {
254 snprintf (s,
sizeof(s),
"%s/%s_%" PRIu32
".wav", sound_directory.c_str(),
258 snprintf (s,
sizeof(s),
"%s/%s_%" PRIu32
"-%" PRId32
".wav", sound_directory.c_str(),
264 if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
278 SourceFactory::createWritable (DataType::AUDIO, *_session,
280 false, _session->frame_rate()));
287 sources.push_back (fs);
295 to_read = region->
length();
301 this_time = min (to_read, chunk_size);
307 if (region->
read_at (buf, buf, gain_buffer, pos, this_time) != this_time) {
311 if (fs->
write (buf, this_time) != this_time) {
317 to_read -= this_time;
324 now = localtime (&tnow);
327 (*src)->update_header (0, *now, tnow);
328 (*src)->mark_immutable ();
336 (*i)->mark_for_remove ();
347 if (selection->tracks.empty()) {
351 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
355 if ((atv = dynamic_cast<AudioTimeAxisView*>(*i)) == 0) {
363 if (playlist && write_audio_range (*playlist, atv->
track()->
n_channels(), ts) == 0) {
380 gain_t gain_buffer[chunk_size];
385 vector<boost::shared_ptr<AudioFileSource> > sources;
387 const string sound_directory = _session->session_directory().sound_path();
389 uint32_t channels = count.
n_audio();
391 for (uint32_t n=0; n < channels; ++n) {
393 for (cnt = 0; cnt < 999999; ++cnt) {
395 snprintf (s,
sizeof(s),
"%s/%s_%" PRIu32
".wav", sound_directory.c_str(),
399 snprintf (s,
sizeof(s),
"%s/%s_%" PRIu32
"-%" PRId32
".wav", sound_directory.c_str(),
403 if (!Glib::file_test (s, Glib::FILE_TEST_EXISTS)) {
417 SourceFactory::createWritable (DataType::AUDIO, *_session,
419 false, _session->frame_rate()));
426 sources.push_back (fs);
431 for (list<AudioRange>::iterator i = range.begin(); i != range.end();) {
433 nframes = (*i).length();
439 this_time = min (nframes, chunk_size);
441 for (uint32_t n=0; n < channels; ++n) {
445 if (playlist.
read (buf, buf, gain_buffer, pos, this_time, n) != this_time) {
449 if (fs->
write (buf, this_time) != this_time) {
454 nframes -= this_time;
458 list<AudioRange>::iterator tmp = i;
461 if (tmp != range.end()) {
465 nframes = (*tmp).start - (*i).end;
469 framepos_t this_time = min (nframes, chunk_size);
470 memset (buf, 0,
sizeof (
Sample) * this_time);
472 for (uint32_t n=0; n < channels; ++n) {
475 if (fs->
write (buf, this_time) != this_time) {
480 nframes -= this_time;
490 now = localtime (&tnow);
493 (*s)->update_header (0, *now, tnow);
494 (*s)->mark_immutable ();
504 (*i)->mark_for_remove ();
513 if (!selection->time.empty()) {
514 write_audio_selection (selection->time);
515 }
else if (!selection->regions.empty()) {
516 write_region_selection (selection->regions);
framecnt_t read(Sample *dst, Sample *mixdown, float *gain_buffer, framepos_t start, framecnt_t cnt, uint32_t chan_n=0)
LIBPBD_API Transmitter fatal
int write_region_selection(RegionSelection &)
bool is_audio_track() const
LIBARDOUR_API std::string legalize_for_path(const std::string &str)
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
void set_session(ARDOUR::Session *s)
void set_session(ARDOUR::Session *)
LIBPBD_API Transmitter error
LIBPBD_API Transmitter warning
std::ostream & endmsg(std::ostream &ostr)
boost::shared_ptr< ARDOUR::AudioRegion > audio_region() const
bool write_audio_range(ARDOUR::AudioPlaylist &, const ARDOUR::ChanCount &channels, std::list< ARDOUR::AudioRange > &)
std::string get_path() const
boost::shared_ptr< Delivery > main_outs() const
const PBD::ID & id() const
bool write_region(std::string path, boost::shared_ptr< ARDOUR::AudioRegion >)
boost::shared_ptr< ARDOUR::Track > track() const
boost::shared_ptr< Playlist > playlist()
LIBARDOUR_API PBD::PropertyDescriptor< bool > regions
void bounce_region_selection(bool with_processing)
framecnt_t source_length(uint32_t n) const
framepos_t position() const
uint32_t n_channels() const
virtual boost::shared_ptr< Region > bounce_range(framepos_t start, framepos_t end, InterThreadInfo &, boost::shared_ptr< Processor > endpoint, bool include_endpoint)=0
virtual framecnt_t write(Sample *src, framecnt_t cnt)
virtual framecnt_t read_at(Sample *buf, Sample *mixdown_buf, float *gain_buf, framepos_t position, framecnt_t cnt, uint32_t chan_n=0) const
framecnt_t length() const
boost::shared_ptr< ARDOUR::Route > route() const
int write_audio_selection(TimeSelection &)