summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2009-06-11 19:49:12 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2009-06-11 19:49:12 +0000
commit24e852b5149da9a10f9fbfc5b4e99979a8aa118b (patch)
treeaf1ade64c6ebbf26431d93bf491a9becaa5e478e
parent5f5fd5996ee84d5a47b21986d5de0e8846788f24 (diff)
CD Marker export patch from Andreas Ruge
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5172 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/export_dialog.cc153
1 files changed, 99 insertions, 54 deletions
diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc
index 142f425f80..e7ad83b836 100644
--- a/gtk2_ardour/export_dialog.cc
+++ b/gtk2_ardour/export_dialog.cc
@@ -648,11 +648,18 @@ ExportDialog::export_toc_file (Locations::LocationList& locations, const string&
return;
}
- string filepath = path + ".toc";
- ofstream out (filepath.c_str());
long unsigned int last_end_time = spec.start_frame, last_start_time = spec.start_frame;
gchar buf[18];
-
+
+ /* Build the toc's file name from the specified audio file name. */
+ string basename = Glib::path_get_basename(path);
+ size_t ext_pos = basename.rfind('.');
+ if (ext_pos != string::npos) {
+ basename = basename.substr(0, ext_pos); /* strip file extension, if there is one */
+ }
+ string filepath = Glib::build_filename(Glib::path_get_dirname(path), basename + ".toc");
+
+ ofstream out (filepath.c_str());
if (!out) {
error << string_compose(_("Editor: cannot open \"%1\" as export file for CD toc file"), filepath) << endmsg;
return;
@@ -717,7 +724,7 @@ ExportDialog::export_toc_file (Locations::LocationList& locations, const string&
out << " }" << endl << "}" << endl;
frames_to_cd_frames_string (buf, last_end_time - spec.start_frame, session->frame_rate());
- out << "FILE \"" << path << "\" " << buf;
+ out << "FILE \"" << Glib::path_get_basename(path) << "\"" << buf;
if ((*i)->is_mark()) {
// a mark track location needs to look ahead to the next marker's start to determine length
@@ -781,12 +788,19 @@ ExportDialog::export_cue_file (Locations::LocationList& locations, const string&
return;
}
- string filepath = path + ".cue";
- ofstream out (filepath.c_str());
gchar buf[18];
long unsigned int last_track_end = spec.start_frame;
int numtracks = 0, tracknum = 0, indexnum = 0;
-
+
+ /* Build the cue sheet's file name from the specified audio file name. */
+ string basename = Glib::path_get_basename(path);
+ size_t ext_pos = basename.rfind('.');
+ if (ext_pos != string::npos) {
+ basename = basename.substr(0, ext_pos); /* strip file extension, if there is one */
+ }
+ string filepath = Glib::build_filename(Glib::path_get_dirname(path), basename + ".cue");
+
+ ofstream out (filepath.c_str());
if (!out) {
error << string_compose(_("Editor: cannot open \"%1\" as export file for CD cue file"), filepath) << endmsg;
return;
@@ -806,39 +820,66 @@ ExportDialog::export_cue_file (Locations::LocationList& locations, const string&
out << "REM Cue file generated by Ardour" << endl;
out << "TITLE \"" << session->name() << "\"" << endl;
+
+ out << "FILE \"" << Glib::path_get_basename(path) << "\" ";
+
+ /* The cue sheet syntax has originally five file types:
+ WAVE : 44.1 kHz, 16 Bit (little endian)
+ AIFF : 44.1 kHz, 16 Bit (big endian)
+ BINARY : 44.1 kHz, 16 Bit (little endian)
+ MOTOROLA : 44.1 kHz, 16 Bit (big endian)
+ MP3
+
+ We want to use cue sheets not only as CD images but also as general playlyist
+ format, thus for WAVE and AIFF we don't care if it's really 44.1 kHz/16 Bit, the
+ soundfile's header shows it anyway. But for the raw formats, i.e. BINARY
+ and MOTOROLA we do care, because no header would tell us about a different format.
- if ((header_format_combo.get_active_text() == N_("WAV"))) {
- out << "FILE \"" << path << "\" WAVE" << endl;
+ For all other formats we just make up our own file type. MP3 is not supported
+ at the moment.
+ */
+ int file_format = sndfile_header_format_from_string (header_format_combo.get_active_text ());
+ if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV) {
+ out << "WAVE";
+ } else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AIFF) {
+ out << "AIFF";
+ } else if ( ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW)
+ && (sndfile_bitdepth_format_from_string(bitdepth_format_combo.get_active_text()) == SF_FORMAT_PCM_16)
+ && (sample_rate_combo.get_active_text() == _("44.1kHz")) ) {
+ /* raw audio, 16 Bit, 44.1 kHz */
+ if (sndfile_endian_format_from_string(endian_format_combo.get_active_text()) == SF_ENDIAN_LITTLE) {
+ out << "BINARY";
+ } else {
+ out << "MOTOROLA";
+ }
} else {
- out << "FILE \"" << path << "\" " << (header_format_combo.get_active_text()) << endl;
+ out << (header_format_combo.get_active_text());
}
+ out << endl;
if (false && numtracks == 0) {
- /* the user has supplied no track markers.
- the entire export is treated as one track.
- */
-
- numtracks++;
- tracknum++;
- indexnum = 0;
- out << endl << "TRACK " << tracknum << " AUDIO" << endl;
- out << "FLAGS " ;
-
- out << "DCP " << endl;
-
- /* use the session name*/
-
- if (session->name() != "") {
- out << "TITLE \"" << session->name() << "\"" << endl;
- }
-
- /* no pregap in this case */
-
- out << "INDEX 00 00:00:00" << endl;
- indexnum++;
- out << "INDEX 01 00:00:00" << endl;
- indexnum++;
- last_track_end = spec.end_frame;
+ /* the user has supplied no track markers.
+ the entire export is treated as one track.
+ */
+
+ numtracks++;
+ tracknum++;
+ indexnum = 0;
+
+ snprintf (buf, sizeof(buf), " TRACK %02d AUDIO", tracknum);
+ out << buf << endl;
+ out << " FLAGS DCP" << endl;
+
+ /* use the session name*/
+
+ out << " TITLE \"" << session->name() << "\"" << endl;
+
+ /* No pregap is specified in this case, adding the default pregap
+ is left to the burning application. */
+
+ out << " INDEX 01 00:00:00" << endl;
+ indexnum = 2;
+ last_track_end = spec.end_frame;
}
if (temp.size()) {
@@ -855,39 +896,43 @@ ExportDialog::export_cue_file (Locations::LocationList& locations, const string&
tracknum++;
indexnum = 0;
- out << endl << "TRACK " << tracknum << " AUDIO" << endl;
- out << "FLAGS " ;
-
+
+ snprintf (buf, sizeof(buf), " TRACK %02d AUDIO", tracknum);
+ out << buf << endl;
+
+ out << " FLAGS" ;
if ((*i)->cd_info.find("scms") != (*i)->cd_info.end()) {
- out << "SCMS ";
+ out << " SCMS";
} else {
- out << "DCP ";
+ out << " DCP";
}
-
if ((*i)->cd_info.find("preemph") != (*i)->cd_info.end()) {
- out << "PRE";
+ out << " PRE";
}
out << endl;
if ((*i)->cd_info.find("isrc") != (*i)->cd_info.end()) {
- out << "ISRC " << (*i)->cd_info["isrc"] << endl;
-
+ out << " ISRC " << (*i)->cd_info["isrc"] << endl;
}
+
if ((*i)->name() != "") {
- out << "TITLE \"" << (*i)->name() << "\"" << endl;
+ out << " TITLE \"" << (*i)->name() << "\"" << endl;
}
if ((*i)->cd_info.find("performer") != (*i)->cd_info.end()) {
- out << "PERFORMER \"" << (*i)->cd_info["performer"] << "\"" << endl;
+ out << " PERFORMER \"" << (*i)->cd_info["performer"] << "\"" << endl;
}
if ((*i)->cd_info.find("string_composer") != (*i)->cd_info.end()) {
- out << "SONGWRITER \"" << (*i)->cd_info["string_composer"] << "\"" << endl;
+ out << " SONGWRITER \"" << (*i)->cd_info["string_composer"] << "\"" << endl;
}
- snprintf (buf, sizeof(buf), "INDEX %02d", indexnum);
- out << buf;
- frames_to_cd_frames_string (buf, last_track_end - spec.start_frame, session->frame_rate());
- out << buf << endl;
+
+ /* only print "Index 00" if not at the same position as "Index 01" */
+ if (last_track_end != (*i)->start()) {
+ frames_to_cd_frames_string (buf, last_track_end - spec.start_frame, session->frame_rate());
+ out << " INDEX 00" << buf << endl;
+ }
+
indexnum++;
if ((*i)->is_mark()) {
@@ -910,7 +955,7 @@ ExportDialog::export_cue_file (Locations::LocationList& locations, const string&
if ((tracknum > 0) && ((*i)->start() < last_track_end)) {
/*this is an index and it lies within a track*/
- snprintf (buf, sizeof(buf), "INDEX %02d", indexnum);
+ snprintf (buf, sizeof(buf), " INDEX %02d", indexnum);
out << buf;
frames_to_cd_frames_string (buf,(*i)->start() - spec.start_frame, session->frame_rate());
out << buf << endl;
@@ -964,7 +1009,7 @@ ExportDialog::do_export ()
filepath += ".aiff";
}
} else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64) {
- if (filepath.find (".w64") != filepath.length() - 5) {
+ if (filepath.find (".w64") != filepath.length() - 4) {
filepath += ".w64";
}
} else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_FLAC) {
@@ -986,7 +1031,7 @@ ExportDialog::do_export ()
if (!Profile->get_sae() && export_cd_markers_allowed) {
if (cue_file_combo.get_active_text () != _("None")) {
- do_export_cd_markers (file_entry.get_text(), cue_file_combo.get_active_text ());
+ do_export_cd_markers (filepath, cue_file_combo.get_active_text ());
}
if (cuefile_only_checkbox.get_active()) {