- std::vector<std::string> sound_files;
- sound_files.push_back ("examples/sine_440_-12dB.wav");
- sound_files.push_back ("examples/sine_880_-12dB.wav");
-
- /* Now we can create the sound asset using these files */
- boost::shared_ptr<libdcp::SoundAsset> sound_asset (
- new libdcp::SoundAsset (sound_files, "My Film DCP", "audio.mxf", 0, 24, 48, false, false)
- );
-
- /* Now that we have the assets, we can create a Reel to put them in and add it to the CPL */
- cpl->add_reel (
- boost::shared_ptr<libdcp::Reel> (
- new libdcp::Reel (picture_asset, sound_asset, boost::shared_ptr<libdcp::SubtitleAsset> ())
- )
- );
-
- /* Finally, we call this to write the XML description files to the DCP. After this, the DCP
- is ready to ingest and play.
+ 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");
+
+ /* Write some sine waves */
+ std::array<float, 48000> left;
+ std::array<float, 48000> right;
+ for (int i = 0; i < 48000; ++i) {
+ left[i] = sin (2 * M_PI * i * 440 / 48000) * 0.25;
+ right[i] = sin (2 * M_PI * i * 880 / 48000) * 0.25;
+ }
+ std::array<float*, 2> audio;
+ audio[0] = left.data();
+ audio[1] = right.data();
+ sound_writer->write (audio.data(), 48000);
+
+ /* And finish off */
+ sound_writer->finalize ();
+
+ /* Now create a reel */
+ auto reel = std::make_shared<dcp::Reel>();
+
+ /* Add picture and sound to it. The zeros are the `entry points', i.e. the first
+ (video) frame from the assets that the reel should play.