diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-12 19:26:57 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-12 19:26:57 +0000 |
| commit | e412564a57a5898a8f5f49c42bede37e76f0c41c (patch) | |
| tree | d52d6b98f5acb3567360852a36f863c90b8a2d88 /src | |
| parent | 41daa5821b3d3b0f450094fbf0d1e37a449f482c (diff) | |
Add simple support for generating audio MXFs from part of a WAV file (for multi-reel DCP generation).
Diffstat (limited to 'src')
| -rw-r--r-- | src/dcp.cc | 4 | ||||
| -rw-r--r-- | src/reel.cc | 3 | ||||
| -rw-r--r-- | src/sound_asset.cc | 22 | ||||
| -rw-r--r-- | src/sound_asset.h | 7 |
4 files changed, 29 insertions, 7 deletions
@@ -457,9 +457,7 @@ CPL::write_xml () const (*i)->write_to_cpl (os); } - os << " </AssetList>\n" - << " </Reel>\n" - << " </ReelList>\n" + os << " </ReelList>\n" << "</CompositionPlaylist>\n"; os.close (); diff --git a/src/reel.cc b/src/reel.cc index 52a4f0fb..8995f874 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -44,6 +44,9 @@ Reel::write_to_cpl (ostream& s) const if (_main_subtitle) { _main_subtitle->write_to_cpl (s); } + + s << " </AssetList>\n" + << " </Reel>\n"; } bool diff --git a/src/sound_asset.cc b/src/sound_asset.cc index e987239a..98266b28 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -42,12 +42,15 @@ using boost::lexical_cast; using namespace libdcp; SoundAsset::SoundAsset ( - vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length + vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length, int start_frame ) : MXFAsset (directory, mxf_name, progress, fps, 0, length) , _channels (files.size ()) , _sampling_rate (0) + , _start_frame (start_frame) { + assert (_channels); + construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files)); } @@ -56,18 +59,22 @@ SoundAsset::SoundAsset ( string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, - int fps, int length, int channels + int fps, int length, int start_frame, int channels ) : MXFAsset (directory, mxf_name, progress, fps, 0, length) , _channels (channels) , _sampling_rate (0) + , _start_frame (start_frame) { + assert (_channels); + construct (get_path); } SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int entry_point, int length) : MXFAsset (directory, mxf_name, 0, fps, entry_point, length) , _channels (0) + , _start_frame (0) { ASDCP::PCM::MXFReader reader; if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) { @@ -96,7 +103,7 @@ void SoundAsset::construct (boost::function<string (Channel)> get_path) { ASDCP::Rational asdcp_fps (_fps, 1); - + ASDCP::PCM::WAVParser pcm_parser_channel[_channels]; if (pcm_parser_channel[0].OpenRead (get_path(LEFT).c_str(), asdcp_fps)) { throw FileError ("could not open WAV file for reading", get_path(LEFT)); @@ -153,6 +160,15 @@ SoundAsset::construct (boost::function<string (Channel)> get_path) throw FileError ("could not open audio MXF for writing", path().string()); } + /* Skip through up to our _start_frame; this is pretty inefficient... */ + for (int i = 0; i < _start_frame; ++i) { + for (int j = 0; j < _channels; ++j) { + if (ASDCP_FAILURE (pcm_parser_channel[j].ReadFrame (frame_buffer_channel[j]))) { + throw MiscError ("could not read audio frame"); + } + } + } + for (int i = 0; i < _length; ++i) { for (int j = 0; j < _channels; ++j) { diff --git a/src/sound_asset.h b/src/sound_asset.h index 3189c067..9fb1d60b 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -44,6 +44,7 @@ public: * @param progress Signal to inform of progress. * @param fps Frames per second. * @param length Length in frames. + * @param start_frame Frame in the source to start writing from. */ SoundAsset ( std::vector<std::string> const & files, @@ -51,7 +52,8 @@ public: std::string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, - int length + int length, + int start_frame ); /** Construct a SoundAsset, generating the MXF from some WAV files. @@ -62,6 +64,7 @@ public: * @param progress Signal to inform of progress. * @param fps Frames per second. * @param length Length in frames. + * @param start_frame Frame in the source to start writing from. * @param channels Number of audio channels. */ SoundAsset ( @@ -71,6 +74,7 @@ public: boost::signals2::signal<void (float)>* progress, int fps, int length, + int start_frame, int channels ); @@ -106,6 +110,7 @@ private: /** Number of channels in the asset */ int _channels; int _sampling_rate; + int _start_frame; }; } |
