Index: gtk2_ardour/export_dialog.cc =================================================================== --- gtk2_ardour/export_dialog.cc (revision 5128) +++ gtk2_ardour/export_dialog.cc (working copy) @@ -648,11 +648,18 @@ 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 @@ 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 @@ 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 @@ 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. - */ + /* 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 */ + numtracks++; + tracknum++; + indexnum = 0; - out << "INDEX 00 00:00:00" << endl; - indexnum++; - out << "INDEX 01 00:00:00" << endl; - indexnum++; - last_track_end = spec.end_frame; + 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 @@ 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 @@ 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 @@ 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 @@ 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()) {