- _edit_rate = desc.EditRate.Numerator;
- assert (desc.EditRate.Denominator == 1);
- _intrinsic_duration = desc.ContainerDuration;
-}
-
-SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int channels, int sampling_rate)
- : MXFAsset (directory, mxf_name, 0, fps, 0, false)
- , _channels (channels)
- , _sampling_rate (sampling_rate)
-{
-
-}
-
-string
-SoundAsset::path_from_channel (Channel channel, vector<string> const & files)
-{
- unsigned int const c = int (channel);
- assert (c < files.size ());
- return files[c];
-}
-
-void
-SoundAsset::construct (boost::function<string (Channel)> get_path, MXFMetadata const & metadata)
-{
- ASDCP::Rational asdcp_edit_rate (_edit_rate, 1);
-
- ASDCP::PCM::WAVParser pcm_parser_channel[_channels];
- if (pcm_parser_channel[0].OpenRead (get_path(LEFT).c_str(), asdcp_edit_rate)) {
- boost::throw_exception (FileError ("could not open WAV file for reading", get_path(LEFT)));
- }
-
- ASDCP::PCM::AudioDescriptor audio_desc;
- pcm_parser_channel[0].FillAudioDescriptor (audio_desc);
- audio_desc.ChannelCount = 0;
- audio_desc.BlockAlign = 0;
- audio_desc.EditRate = asdcp_edit_rate;
- audio_desc.AvgBps = audio_desc.AvgBps * _channels;
-
- Channel channels[] = {
- LEFT,
- RIGHT,
- CENTRE,
- LFE,
- LS,
- RS,
- /* XXX: not quite sure what these should be yet */
- CHANNEL_7,
- CHANNEL_8
- };
-
- assert (int(_channels) <= int(sizeof(channels) / sizeof(Channel)));
-
- ASDCP::PCM::FrameBuffer frame_buffer_channel[_channels];
- ASDCP::PCM::AudioDescriptor audio_desc_channel[_channels];
-
- for (int i = 0; i < _channels; ++i) {
-
- string const path = get_path (channels[i]);
-
- if (ASDCP_FAILURE (pcm_parser_channel[i].OpenRead (path.c_str(), asdcp_edit_rate))) {
- boost::throw_exception (FileError ("could not open WAV file for reading", path));
- }
-
- pcm_parser_channel[i].FillAudioDescriptor (audio_desc_channel[i]);
- frame_buffer_channel[i].Capacity (ASDCP::PCM::CalcFrameBufferSize (audio_desc_channel[i]));