Exemple #1
0
        // Sets the packet table containing information about the number of valid frames in a file and where they begin and end
        // for the file types that support this information.
        // Calling this function makes sure we write out the priming and remainder details to the destination file
        static void WritePacketTableInfo(AudioConverter converter, AudioFile destinationFile)
        {
            if (!destinationFile.IsPropertyWritable(AudioFileProperty.PacketTableInfo))
            {
                return;
            }

            // retrieve the leadingFrames and trailingFrames information from the converter,
            AudioConverterPrimeInfo primeInfo = converter.PrimeInfo;

            // we have some priming information to write out to the destination file
            // The total number of packets in the file times the frames per packet (or counting each packet's
            // frames individually for a variable frames per packet format) minus mPrimingFrames, minus
            // mRemainderFrames, should equal mNumberValidFrames.

            AudioFilePacketTableInfo?pti_n = destinationFile.PacketTableInfo;

            if (pti_n == null)
            {
                return;
            }

            AudioFilePacketTableInfo pti = pti_n.Value;

            // there's priming to write out to the file
            // get the total number of frames from the output file
            long totalFrames = pti.ValidFrames + pti.PrimingFrames + pti.RemainderFrames;

            pti.PrimingFrames   = primeInfo.LeadingFrames;
            pti.RemainderFrames = primeInfo.TrailingFrames;
            pti.ValidFrames     = totalFrames - pti.PrimingFrames - pti.RemainderFrames;

            destinationFile.PacketTableInfo = pti;
        }
		// Sets the packet table containing information about the number of valid frames in a file and where they begin and end
		// for the file types that support this information.
		// Calling this function makes sure we write out the priming and remainder details to the destination file	
		static void WritePacketTableInfo (AudioConverter converter, AudioFile destinationFile)
		{
			if (!destinationFile.IsPropertyWritable (AudioFileProperty.PacketTableInfo))
				return;

			// retrieve the leadingFrames and trailingFrames information from the converter,
			AudioConverterPrimeInfo primeInfo = converter.PrimeInfo;

			// we have some priming information to write out to the destination file
			// The total number of packets in the file times the frames per packet (or counting each packet's
            // frames individually for a variable frames per packet format) minus mPrimingFrames, minus
            // mRemainderFrames, should equal mNumberValidFrames.

			AudioFilePacketTableInfo? pti_n = destinationFile.PacketTableInfo;
			if (pti_n == null)
				return;

			AudioFilePacketTableInfo pti = pti_n.Value;

			// there's priming to write out to the file
			// get the total number of frames from the output file
			long totalFrames = pti.ValidFrames + pti.PrimingFrames + pti.RemainderFrames;
			Debug.WriteLine ("Total number of frames from output file: {0}", totalFrames);
						
			pti.PrimingFrames = primeInfo.LeadingFrames;
			pti.RemainderFrames = primeInfo.TrailingFrames;
			pti.ValidFrames = totalFrames - pti.PrimingFrames - pti.RemainderFrames;

			destinationFile.PacketTableInfo = pti;
		}