diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-09 11:59:29 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-17 20:13:22 +0100 |
| commit | 66f5e0b713f4ae4066e92ff741d5d71f827a1c37 (patch) | |
| tree | 2c2384890690a3071e7e91b665f6c1f3beb08cc2 /test | |
| parent | ae6ba1b6e48e28292f76ea35121d99ac6cb1555b (diff) | |
Extract simple_sound() method.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 54 | ||||
| -rw-r--r-- | test/test.h | 2 |
2 files changed, 33 insertions, 23 deletions
diff --git a/test/test.cc b/test/test.cc index cd162d5a..c24f28cd 100644 --- a/test/test.cc +++ b/test/test.cc @@ -270,6 +270,36 @@ simple_picture (boost::filesystem::path path, string suffix) } +shared_ptr<dcp::SoundAsset> +simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta) +{ + shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-US"), dcp::SMPTE)); + ms->set_metadata (mxf_meta); + vector<dcp::Channel> active_channels; + active_channels.push_back (dcp::LEFT); + shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix), active_channels); + + SF_INFO info; + info.format = 0; + SNDFILE* sndfile = sf_open ("test/data/1s_24-bit_48k_silence.wav", SFM_READ, &info); + BOOST_CHECK (sndfile); + float buffer[4096*6]; + float* channels[1]; + channels[0] = buffer; + while (true) { + sf_count_t N = sf_readf_float (sndfile, buffer, 4096); + sound_writer->write (channels, N); + if (N < 4096) { + break; + } + } + + sound_writer->finalize (); + + return ms; +} + + shared_ptr<dcp::DCP> make_simple (boost::filesystem::path path, int reels) { @@ -295,29 +325,7 @@ make_simple (boost::filesystem::path path, int reels) string suffix = reels == 1 ? "" : dcp::String::compose("%1", i); shared_ptr<dcp::MonoPictureAsset> mp = simple_picture (path, suffix); - - shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-US"), dcp::SMPTE)); - ms->set_metadata (mxf_meta); - vector<dcp::Channel> active_channels; - active_channels.push_back (dcp::LEFT); - shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix), active_channels); - - SF_INFO info; - info.format = 0; - SNDFILE* sndfile = sf_open ("test/data/1s_24-bit_48k_silence.wav", SFM_READ, &info); - BOOST_CHECK (sndfile); - float buffer[4096*6]; - float* channels[1]; - channels[0] = buffer; - while (true) { - sf_count_t N = sf_readf_float (sndfile, buffer, 4096); - sound_writer->write (channels, N); - if (N < 4096) { - break; - } - } - - sound_writer->finalize (); + shared_ptr<dcp::SoundAsset> ms = simple_sound (path, suffix, mxf_meta); cpl->add (shared_ptr<dcp::Reel> ( new dcp::Reel ( diff --git a/test/test.h b/test/test.h index 2a064f96..4fc88424 100644 --- a/test/test.h +++ b/test/test.h @@ -34,6 +34,7 @@ namespace xmlpp { namespace dcp { class DCP; class MonoPictureAsset; + class SoundAsset; } extern boost::filesystem::path private_test; @@ -43,6 +44,7 @@ extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::list<std: extern void check_xml (std::string ref, std::string test, std::list<std::string> ignore, bool ignore_whitespace = false); extern void check_file (boost::filesystem::path ref, boost::filesystem::path check); extern std::shared_ptr<dcp::MonoPictureAsset> simple_picture (boost::filesystem::path path, std::string suffix); +extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta); extern std::shared_ptr<dcp::DCP> make_simple (boost::filesystem::path path, int reels = 1); extern std::shared_ptr<dcp::DCP> make_simple_with_interop_subs (boost::filesystem::path path); extern std::shared_ptr<dcp::DCP> make_simple_with_smpte_subs (boost::filesystem::path path); |
