mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Add options to set bit-depth and bwf to session-export util.
This commit is contained in:
parent
2f1405db5a
commit
0301326656
1 changed files with 96 additions and 19 deletions
|
|
@ -6,7 +6,9 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "pbd/basename.h"
|
#include "pbd/basename.h"
|
||||||
|
#include "pbd/enumwriter.h"
|
||||||
|
|
||||||
|
#include "ardour/broadcast_info.h"
|
||||||
#include "ardour/export_handler.h"
|
#include "ardour/export_handler.h"
|
||||||
#include "ardour/export_status.h"
|
#include "ardour/export_status.h"
|
||||||
#include "ardour/export_timespan.h"
|
#include "ardour/export_timespan.h"
|
||||||
|
|
@ -21,33 +23,69 @@ using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace SessionUtils;
|
using namespace SessionUtils;
|
||||||
|
|
||||||
|
struct ExportSettings
|
||||||
|
{
|
||||||
|
ExportSettings ()
|
||||||
|
: _samplerate (0)
|
||||||
|
, _sample_format (ExportFormatBase::SF_16)
|
||||||
|
, _normalize (false)
|
||||||
|
, _bwf (false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string samplerate () const
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << _samplerate;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string sample_format () const
|
||||||
|
{
|
||||||
|
return enum_2_string (_sample_format);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string normalize () const
|
||||||
|
{
|
||||||
|
return _normalize ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string bwf () const
|
||||||
|
{
|
||||||
|
return _bwf ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
|
int _samplerate;
|
||||||
|
ExportFormatBase::SampleFormat _sample_format;
|
||||||
|
bool _normalize;
|
||||||
|
bool _bwf;
|
||||||
|
};
|
||||||
|
|
||||||
static int export_session (Session *session,
|
static int export_session (Session *session,
|
||||||
std::string outfile,
|
std::string outfile,
|
||||||
std::string samplerate,
|
ExportSettings const& settings)
|
||||||
bool normalize)
|
|
||||||
{
|
{
|
||||||
ExportTimespanPtr tsp = session->get_export_handler()->add_timespan();
|
ExportTimespanPtr tsp = session->get_export_handler()->add_timespan();
|
||||||
boost::shared_ptr<ExportChannelConfiguration> ccp = session->get_export_handler()->add_channel_config();
|
boost::shared_ptr<ExportChannelConfiguration> ccp = session->get_export_handler()->add_channel_config();
|
||||||
boost::shared_ptr<ARDOUR::ExportFilename> fnp = session->get_export_handler()->add_filename();
|
boost::shared_ptr<ARDOUR::ExportFilename> fnp = session->get_export_handler()->add_filename();
|
||||||
boost::shared_ptr<AudioGrapher::BroadcastInfo> b;
|
boost::shared_ptr<ARDOUR::BroadcastInfo> b;
|
||||||
|
|
||||||
XMLTree tree;
|
XMLTree tree;
|
||||||
|
|
||||||
tree.read_buffer(std::string(
|
tree.read_buffer(std::string(
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
"<ExportFormatSpecification name=\"UTIL-WAV-16\" id=\"14792644-44ab-4209-a4f9-7ce6c2910cac\">"
|
"<ExportFormatSpecification name=\"UTIL-WAV-EXPORT\" id=\"b1280899-0459-4aef-9dc9-7e2277fa6d24\">"
|
||||||
" <Encoding id=\"F_WAV\" type=\"T_Sndfile\" extension=\"wav\" name=\"WAV\" has-sample-format=\"true\" channel-limit=\"256\"/>"
|
" <Encoding id=\"F_WAV\" type=\"T_Sndfile\" extension=\"wav\" name=\"WAV\" has-sample-format=\"true\" channel-limit=\"256\"/>"
|
||||||
" <SampleRate rate=\""+ samplerate +"\"/>"
|
" <SampleRate rate=\""+ settings.samplerate () +"\"/>"
|
||||||
" <SRCQuality quality=\"SRC_SincBest\"/>"
|
" <SRCQuality quality=\"SRC_SincBest\"/>"
|
||||||
" <EncodingOptions>"
|
" <EncodingOptions>"
|
||||||
" <Option name=\"sample-format\" value=\"SF_16\"/>"
|
" <Option name=\"sample-format\" value=\"" + settings.sample_format () + "\"/>"
|
||||||
" <Option name=\"dithering\" value=\"D_None\"/>"
|
" <Option name=\"dithering\" value=\"D_None\"/>"
|
||||||
" <Option name=\"tag-metadata\" value=\"true\"/>"
|
" <Option name=\"tag-metadata\" value=\"true\"/>"
|
||||||
" <Option name=\"tag-support\" value=\"false\"/>"
|
" <Option name=\"tag-support\" value=\"false\"/>"
|
||||||
" <Option name=\"broadcast-info\" value=\"false\"/>"
|
" <Option name=\"broadcast-info\" value=\"" + settings.bwf () +"\"/>"
|
||||||
" </EncodingOptions>"
|
" </EncodingOptions>"
|
||||||
" <Processing>"
|
" <Processing>"
|
||||||
" <Normalize enabled=\""+ (normalize ? "true" : "false") +"\" target=\"0\"/>"
|
" <Normalize enabled=\""+ settings.normalize () +"\" target=\"0\"/>"
|
||||||
" <Silence>"
|
" <Silence>"
|
||||||
" <Start>"
|
" <Start>"
|
||||||
" <Trim enabled=\"false\"/>"
|
" <Trim enabled=\"false\"/>"
|
||||||
|
|
@ -104,6 +142,12 @@ static int export_session (Session *session,
|
||||||
tsp->set_name (basename);
|
tsp->set_name (basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set broadcast info */
|
||||||
|
if (settings._bwf) {
|
||||||
|
b.reset (new BroadcastInfo);
|
||||||
|
b->set_from_session (*session, tsp->get_start ());
|
||||||
|
}
|
||||||
|
|
||||||
cout << "* Writing " << Glib::build_filename (fnp->get_folder(), tsp->name() + ".wav") << endl;
|
cout << "* Writing " << Glib::build_filename (fnp->get_folder(), tsp->name() + ".wav") << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -150,15 +194,18 @@ static void usage (int status) {
|
||||||
printf (UTILNAME " - export an ardour session from the commandline.\n\n");
|
printf (UTILNAME " - export an ardour session from the commandline.\n\n");
|
||||||
printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> <session/snapshot-name>\n\n");
|
printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> <session/snapshot-name>\n\n");
|
||||||
printf ("Options:\n\
|
printf ("Options:\n\
|
||||||
|
-b, --bitdepth <depth> set export-format (16, 24, 32, float)\n\
|
||||||
|
-B, --broadcast include broadcast wave header\n\
|
||||||
-h, --help display this help and exit\n\
|
-h, --help display this help and exit\n\
|
||||||
-n, --normalize normalize signal level (to 0dBFS)\n\
|
-n, --normalize normalize signal level (to 0dBFS)\n\
|
||||||
-o, --output <file> export output file name\n\
|
-o, --output <file> export output file name\n\
|
||||||
-s, --samplerate <rate> samplerate to use (default: 48000)\n\
|
-s, --samplerate <rate> samplerate to use\n\
|
||||||
-V, --version print version information and exit\n\
|
-V, --version print version information and exit\n\
|
||||||
\n");
|
\n");
|
||||||
printf ("\n\
|
printf ("\n\
|
||||||
This tool exports the session-range of a given ardour-session to a 16bit wav,\n\
|
This tool exports the session-range of a given ardour-session to a wave file,\n\
|
||||||
using the master-bus outputs.\n\
|
using the master-bus outputs.\n\
|
||||||
|
By default a 16bit signed .wav file at session-rate is exported.\n\
|
||||||
If the no output-file is given, the session's export dir is used.\n\
|
If the no output-file is given, the session's export dir is used.\n\
|
||||||
\n\
|
\n\
|
||||||
Note: the tool expects a session-name without .ardour file-name extension.\n\
|
Note: the tool expects a session-name without .ardour file-name extension.\n\
|
||||||
|
|
@ -171,13 +218,14 @@ Note: the tool expects a session-name without .ardour file-name extension.\n\
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
std::string rate = "48000";
|
ExportSettings settings;
|
||||||
std::string outfile;
|
std::string outfile;
|
||||||
bool normalize = false;
|
|
||||||
|
|
||||||
const char *optstring = "hno:s:V";
|
const char *optstring = "b:Bhno:s:V";
|
||||||
|
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
|
{ "bitdepth", 1, 0, 'b' },
|
||||||
|
{ "broadcast", 0, 0, 'B' },
|
||||||
{ "help", 0, 0, 'h' },
|
{ "help", 0, 0, 'h' },
|
||||||
{ "normalize", 0, 0, 'n' },
|
{ "normalize", 0, 0, 'n' },
|
||||||
{ "output", 1, 0, 'o' },
|
{ "output", 1, 0, 'o' },
|
||||||
|
|
@ -190,8 +238,35 @@ int main (int argc, char* argv[])
|
||||||
optstring, longopts, (int *) 0))) {
|
optstring, longopts, (int *) 0))) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
switch (atoi (optarg)) {
|
||||||
|
case 16:
|
||||||
|
settings._sample_format = ExportFormatBase::SF_16;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
settings._sample_format = ExportFormatBase::SF_24;
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
settings._sample_format = ExportFormatBase::SF_32;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
if (0 == strcmp (optarg, "float")) {
|
||||||
|
settings._sample_format = ExportFormatBase::SF_Float;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// no break
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Invalid Bit Depth\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'B':
|
||||||
|
settings._bwf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
normalize = true;
|
settings._normalize = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|
@ -202,9 +277,7 @@ int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const int sr = atoi (optarg);
|
const int sr = atoi (optarg);
|
||||||
if (sr >= 8000 && sr <= 192000) {
|
if (sr >= 8000 && sr <= 192000) {
|
||||||
stringstream ss;
|
settings._samplerate = sr;
|
||||||
ss << sr;
|
|
||||||
rate = ss.str();
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invalid Samplerate\n");
|
fprintf(stderr, "Invalid Samplerate\n");
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +286,7 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
printf ("ardour-utils version %s\n\n", VERSIONSTRING);
|
printf ("ardour-utils version %s\n\n", VERSIONSTRING);
|
||||||
printf ("Copyright (C) GPL 2015 Robin Gareus <robin@gareus.org>\n");
|
printf ("Copyright (C) GPL 2015,2017 Robin Gareus <robin@gareus.org>\n");
|
||||||
exit (0);
|
exit (0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -236,7 +309,11 @@ int main (int argc, char* argv[])
|
||||||
|
|
||||||
s = SessionUtils::load_session (argv[optind], argv[optind+1]);
|
s = SessionUtils::load_session (argv[optind], argv[optind+1]);
|
||||||
|
|
||||||
export_session (s, outfile, rate, normalize);
|
if (settings._samplerate == 0) {
|
||||||
|
settings._samplerate = s->nominal_frame_rate ();
|
||||||
|
}
|
||||||
|
|
||||||
|
export_session (s, outfile, settings);
|
||||||
|
|
||||||
SessionUtils::unload_session(s);
|
SessionUtils::unload_session(s);
|
||||||
SessionUtils::cleanup();
|
SessionUtils::cleanup();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue