diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-28 20:00:09 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-29 01:08:53 +0100 |
| commit | 08ed784d80fc2108fa95b3b5089b7bb44a6ee48f (patch) | |
| tree | f2c89eb05f2c1fe5b7a197a023f56657b73db03a | |
| parent | 87133162b564d29592eefbbddc02399e880504b6 (diff) | |
Add --gain option to dcpomatic_create.
| -rw-r--r-- | src/lib/create_cli.cc | 7 | ||||
| -rw-r--r-- | src/lib/create_cli.h | 1 | ||||
| -rw-r--r-- | src/tools/dcpomatic_create.cc | 3 | ||||
| -rw-r--r-- | test/create_cli_test.cc | 9 |
4 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 8d7c59287..9453cc167 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -55,7 +55,8 @@ string CreateCLI::_help = " --j2k-bandwidth <Mbit/s> J2K bandwidth in Mbit/s\n" " --left-eye next piece of content is for the left eye\n" " --right-eye next piece of content is for the right eye\n" - " --channel <channel> next piece of content should be mapped to audio channel L, R, C, Lfe, Ls or Rs\n"; + " --channel <channel> next piece of content should be mapped to audio channel L, R, C, Lfe, Ls or Rs\n" + " --gain next piece of content should have the given audio gain (in dB)\n"; template <class T> @@ -133,6 +134,7 @@ CreateCLI::CreateCLI (int argc, char* argv[]) int j2k_bandwidth_int = 0; auto next_frame_type = VideoFrameType::TWO_D; optional<dcp::Channel> channel; + optional<float> gain; int i = 1; while (i < argc) { @@ -200,6 +202,7 @@ CreateCLI::CreateCLI (int argc, char* argv[]) }; argument_option(i, argc, argv, "", "--channel", &claimed, &error, &channel, convert_channel); + argument_option(i, argc, argv, "", "--gain", &claimed, &error, &gain); if (!claimed) { if (a.length() > 2 && a.substr(0, 2) == "--") { @@ -210,9 +213,11 @@ CreateCLI::CreateCLI (int argc, char* argv[]) c.path = a; c.frame_type = next_frame_type; c.channel = channel; + c.gain = gain; content.push_back (c); next_frame_type = VideoFrameType::TWO_D; channel = {}; + gain = {}; } } diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h index 9cd790536..ed42e669c 100644 --- a/src/lib/create_cli.h +++ b/src/lib/create_cli.h @@ -39,6 +39,7 @@ public: boost::filesystem::path path; VideoFrameType frame_type; boost::optional<dcp::Channel> channel; + boost::optional<float> gain; }; bool version; diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index 1c11de3e3..3a240ec85 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -146,6 +146,9 @@ main (int argc, char* argv[]) stream->set_mapping (mapping); } } + if (j->audio && i.gain) { + j->audio->set_gain (*i.gain); + } } } diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc index 93d33fa85..aae243d99 100644 --- a/test/create_cli_test.cc +++ b/test/create_cli_test.cc @@ -169,4 +169,13 @@ BOOST_AUTO_TEST_CASE (create_cli_test) cc = run ("dcpomatic2_create --channel foo fred.wav"); BOOST_REQUIRE (cc.error); BOOST_CHECK (boost::algorithm::starts_with(*cc.error, "dcpomatic2_create: foo is not valid for --channel")); + + cc = run ("dcpomatic2_create fred.wav --gain -6 jim.wav --gain 2 sheila.wav"); + BOOST_REQUIRE_EQUAL (cc.content.size(), 3U); + BOOST_CHECK_EQUAL (cc.content[0].path, "fred.wav"); + BOOST_CHECK (!cc.content[0].gain); + BOOST_CHECK_EQUAL (cc.content[1].path, "jim.wav"); + BOOST_CHECK_CLOSE (*cc.content[1].gain, -6, 0.001); + BOOST_CHECK_EQUAL (cc.content[2].path, "sheila.wav"); + BOOST_CHECK_CLOSE (*cc.content[2].gain, 2, 0.001); } |
