diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-03-17 13:33:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-03-20 16:41:02 +0100 |
| commit | 870f02f07ee51ee478006260e2c3b683e591b0c9 (patch) | |
| tree | 0df3a83d06c3c627b3b16664ff45a574d630d747 | |
| parent | 90a4d88bf00dc4d038621227f6878c013b289a88 (diff) | |
Remove the bools and default parameters from SoundAsset::start_write().
They were more confusing than they were worth.
| -rw-r--r-- | examples/make_dcp.cc | 2 | ||||
| -rw-r--r-- | src/sound_asset.cc | 12 | ||||
| -rw-r--r-- | src/sound_asset.h | 17 | ||||
| -rw-r--r-- | test/dcp_test.cc | 6 | ||||
| -rw-r--r-- | test/decryption_test.cc | 2 | ||||
| -rw-r--r-- | test/encryption_test.cc | 2 | ||||
| -rw-r--r-- | test/mca_test.cc | 2 | ||||
| -rw-r--r-- | test/sound_asset_writer_test.cc | 4 | ||||
| -rw-r--r-- | test/sync_test.cc | 4 | ||||
| -rw-r--r-- | test/test.cc | 2 |
10 files changed, 37 insertions, 16 deletions
diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc index 7f387db2..60f5608a 100644 --- a/examples/make_dcp.cc +++ b/examples/make_dcp.cc @@ -74,7 +74,7 @@ main () When creating the object we specify the sampling rate (48kHz) and the number of channels (2). */ auto sound_asset = std::make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE); - auto sound_writer = sound_asset->start_write("DCP/sound.mxf"); + auto sound_writer = sound_asset->start_write("DCP/sound.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); /* Write some sine waves */ std::array<float, 48000> left; diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 8002f37a..56d13951 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -221,13 +221,19 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand shared_ptr<SoundAssetWriter> -SoundAsset::start_write(boost::filesystem::path file, bool atmos_sync, bool include_mca_subdescriptors) +SoundAsset::start_write( + boost::filesystem::path file, + AtmosSync atmos_sync, + MCASubDescriptors include_mca_subdescriptors + ) { - if (atmos_sync && _channels < 14) { + if (atmos_sync == AtmosSync::ENABLED && _channels < 14) { throw MiscError ("Insufficient channels to write ATMOS sync (there must be at least 14)"); } - return shared_ptr<SoundAssetWriter>(new SoundAssetWriter(this, file, atmos_sync, include_mca_subdescriptors)); + return shared_ptr<SoundAssetWriter>( + new SoundAssetWriter(this, file, atmos_sync == AtmosSync::ENABLED, include_mca_subdescriptors == MCASubDescriptors::ENABLED) + ); } diff --git a/src/sound_asset.h b/src/sound_asset.h index e9a2736d..e51f1854 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -75,7 +75,22 @@ public: explicit SoundAsset (boost::filesystem::path file); SoundAsset (Fraction edit_rate, int sampling_rate, int channels, LanguageTag language, Standard standard); - std::shared_ptr<SoundAssetWriter> start_write(boost::filesystem::path file, bool atmos_sync = false, bool include_mca_subdescriptors = true); + enum class AtmosSync { + ENABLED, + DISABLED + }; + + enum class MCASubDescriptors { + ENABLED, + DISABLED + }; + + std::shared_ptr<SoundAssetWriter> start_write( + boost::filesystem::path file, + AtmosSync atmos_sync, + MCASubDescriptors mca_subdescriptors + ); + std::shared_ptr<SoundAssetReader> start_read () const; bool equals ( diff --git a/test/dcp_test.cc b/test/dcp_test.cc index 71564238..03c5e2a9 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE (dcp_test2) auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE); ms->set_metadata (mxf_meta); - auto sound_writer = ms->start_write ("build/test/DCP/dcp_test2/audio.mxf"); + auto sound_writer = ms->start_write("build/test/DCP/dcp_test2/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); SF_INFO info; info.format = 0; @@ -206,7 +206,7 @@ test_rewriting_sound(string name, bool modify) auto reader = A_sound->asset()->start_read(); auto sound = make_shared<dcp::SoundAsset>(A_sound->asset()->edit_rate(), A_sound->asset()->sampling_rate(), A_sound->asset()->channels(), dcp::LanguageTag("en-US"), dcp::Standard::SMPTE); - auto writer = sound->start_write(path("build") / "test" / name / "pcm_8246f87f-e1df-4c42-a290-f3b3069ff021.mxf", {}); + auto writer = sound->start_write(path("build") / "test" / name / "pcm_8246f87f-e1df-4c42-a290-f3b3069ff021.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); bool need_to_modify = modify; for (int i = 0; i < A_sound->asset()->intrinsic_duration(); ++i) { @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE (dcp_test5) auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE); ms->set_metadata (mxf_meta); - auto sound_writer = ms->start_write ("build/test/DCP/dcp_test5/audio.mxf"); + auto sound_writer = ms->start_write("build/test/DCP/dcp_test5/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); SF_INFO info; info.format = 0; diff --git a/test/decryption_test.cc b/test/decryption_test.cc index c24402bf..757a6986 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE (decryption_test2) auto sound_asset = std::make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE); sound_asset->set_key (key); sound_asset->set_context_id (context_id); - auto sound_writer = sound_asset->start_write(dir / "sound.mxf"); + auto sound_writer = sound_asset->start_write(dir / "sound.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); std::array<float, 48000> left; std::array<float, 48000> right; for (int i = 0; i < 48000; ++i) { diff --git a/test/encryption_test.cc b/test/encryption_test.cc index 2b9a6bea..29b8f1fb 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE (encryption_test) auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction (24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE); ms->set_metadata (mxf_metadata); ms->set_key (key); - auto sound_writer = ms->start_write ("build/test/DCP/encryption_test/audio.mxf"); + auto sound_writer = ms->start_write("build/test/DCP/encryption_test/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); SF_INFO info; info.format = 0; diff --git a/test/mca_test.cc b/test/mca_test.cc index fc5dda25..fc6a76d3 100644 --- a/test/mca_test.cc +++ b/test/mca_test.cc @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test) BOOST_AUTO_TEST_CASE (write_mca_descriptors_to_mxf_test) { auto sound_asset = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 6, dcp::LanguageTag("en-US"), dcp::Standard::SMPTE); - auto writer = sound_asset->start_write("build/test/write_mca_descriptors_to_mxf_test.mxf"); + auto writer = sound_asset->start_write("build/test/write_mca_descriptors_to_mxf_test.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); float* samples[6]; for (int i = 0; i < 6; ++i) { diff --git a/test/sound_asset_writer_test.cc b/test/sound_asset_writer_test.cc index a413a174..d5a66489 100644 --- a/test/sound_asset_writer_test.cc +++ b/test/sound_asset_writer_test.cc @@ -48,7 +48,7 @@ void no_padding_test(boost::filesystem::path path, std::function<void (shared_ptr<dcp::SoundAssetWriter>, boost::random::mt19937&, boost::random::uniform_int_distribution<>&)> write) { dcp::SoundAsset asset({24, 1}, 48000, 6, dcp::LanguageTag{"en-GB"}, dcp::Standard::SMPTE); - auto writer = asset.start_write(path); + auto writer = asset.start_write(path, {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); boost::random::mt19937 rng(1); boost::random::uniform_int_distribution<> dist(0, 32767); @@ -119,7 +119,7 @@ void padding_test(boost::filesystem::path path, std::function<void (shared_ptr<dcp::SoundAssetWriter>, boost::random::mt19937&, boost::random::uniform_int_distribution<>&)> write) { dcp::SoundAsset asset({24, 1}, 48000, 14, dcp::LanguageTag{"en-GB"}, dcp::Standard::SMPTE); - auto writer = asset.start_write(path); + auto writer = asset.start_write(path, {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); boost::random::mt19937 rng(1); boost::random::uniform_int_distribution<> dist(0, 32767); diff --git a/test/sync_test.cc b/test/sync_test.cc index ba235bd4..67920e2f 100644 --- a/test/sync_test.cc +++ b/test/sync_test.cc @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE (sync_test1) } } - shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", true); + auto writer = asset.start_write("build/test/foo.mxf", {}, dcp::SoundAsset::AtmosSync::ENABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); /* Compare the sync bits made by SoundAssetWriter to the "proper" ones in the MXF */ BOOST_CHECK (ref == writer->create_sync_packets()); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE (sync_test2) asset._id = "e004046e09234f90a4ae4355e7e83506"; boost::system::error_code ec; boost::filesystem::remove ("build/test/foo.mxf", ec); - auto writer = asset.start_write ("build/test/foo.mxf", true); + auto writer = asset.start_write("build/test/foo.mxf", {}, dcp::SoundAsset::AtmosSync::ENABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); int const frames = 2000; float** junk = new float*[channels]; diff --git a/test/test.cc b/test/test.cc index 1b23b177..76ed92f4 100644 --- a/test/test.cc +++ b/test/test.cc @@ -301,7 +301,7 @@ simple_sound(boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_m } ms->_language = language; ms->set_metadata (mxf_meta); - shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix)); + auto sound_writer = ms->start_write(path / dcp::String::compose("audio%1.mxf", suffix), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); int const samples_per_frame = sample_rate / 24; |
