- 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)
- );
-
- /* 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.
+ boost::shared_ptr<dcp::SoundAsset> sound_asset (new dcp::SoundAsset (dcp::Fraction (24, 1), 48000, 2));
+ boost::shared_ptr<dcp::SoundAssetWriter> sound_writer = sound_asset->start_write ("DCP/sound.mxf", dcp::SMPTE);
+
+ /* Write some sine waves */
+ float* audio[2];
+ audio[0] = new float[48000];
+ audio[1] = new float[48000];
+ for (int i = 0; i < 48000; ++i) {
+ audio[0][i] = sin (2 * M_PI * i * 440 / 48000) * 0.25;
+ audio[1][i] = sin (2 * M_PI * i * 880 / 48000) * 0.25;
+ }
+ sound_writer->write (audio, 48000);
+
+ /* And tidy up */
+ delete[] audio[0];
+ delete[] audio[1];
+ sound_writer->finalize ();
+
+ /* Now create a reel */
+ boost::shared_ptr<dcp::Reel> reel (new 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.