Add operator!= and operator< for LanguageTag
[libdcp.git] / examples / make_dcp.cc
index 8683dc300a8374e9e61b2c8a528842b76bac86f4..22f6e72233ae6ec2d40ba04570f869e38f4ae74f 100644 (file)
 int
 main ()
 {
+       /* Set up libdcp */
+       dcp::init();
+
        /* Create a directory to put the DCP in */
-       boost::filesystem::create_directory ("DCP");
+       boost::filesystem::create_directory("DCP");
 
        /* Make a picture asset.  This is a file which combines JPEG2000 files together to make
           up the video of the DCP.  First, create the object, specifying a frame rate of 24 frames
           per second.
        */
 
-       auto picture_asset = std::make_shared<dcp::MonoPictureAsset>(dcp::Fraction (24, 1), dcp::Standard::SMPTE);
+       auto picture_asset = std::make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
 
        /* Start off a write to it */
        auto picture_writer = picture_asset->start_write("DCP/picture.mxf", false);
@@ -61,7 +64,7 @@ main ()
        /* Write 24 frames of the same JPEG2000 file */
        dcp::ArrayData picture("examples/help.j2c");
        for (int i = 0; i < 24; ++i) {
-               picture_writer->write (picture.data(), picture.size());
+               picture_writer->write (picture);
        }
 
        /* And finish off */
@@ -78,18 +81,18 @@ main ()
        auto sound_writer = sound_asset->start_write("DCP/sound.mxf", active_channels);
 
        /* Write some sine waves */
-       float* audio[2];
-       audio[0] = new float[48000];
-       audio[1] = new float[48000];
+       std::array<float, 48000> left;
+       std::array<float, 48000> right;
        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;
+               left[i] = sin (2 * M_PI * i * 440 / 48000) * 0.25;
+               right[i] = sin (2 * M_PI * i * 880 / 48000) * 0.25;
        }
-       sound_writer->write (audio, 48000);
+       std::array<float*, 2> audio;
+       audio[0] = left.data();
+       audio[1] = right.data();
+       sound_writer->write (audio.data(), 48000);
 
-       /* And tidy up */
-       delete[] audio[0];
-       delete[] audio[1];
+       /* And finish off */
        sound_writer->finalize ();
 
        /* Now create a reel */
@@ -98,12 +101,12 @@ main ()
        /* 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.
        */
-       reel->add (std::make_shared<dcp::ReelMonoPictureAsset>(picture_asset, 0));
-       reel->add (std::make_shared<dcp::ReelSoundAsset>(sound_asset, 0));
+       reel->add(std::make_shared<dcp::ReelMonoPictureAsset>(picture_asset, 0));
+       reel->add(std::make_shared<dcp::ReelSoundAsset>(sound_asset, 0));
 
        /* Make a CPL with this reel */
        auto cpl = std::make_shared<dcp::CPL>("My film", dcp::ContentKind::FEATURE);
-       cpl->add (reel);
+       cpl->add(reel);
 
        /* Write the DCP */
        dcp::DCP dcp ("DCP");