public override bool ValueEquals(WithPresentation other)
        {
            if (!base.ValueEquals(other))
            {
                return(false);
            }

            ManagedAudioMedia otherz = other as ManagedAudioMedia;

            if (otherz == null)
            {
                return(false);
            }

            if (otherz.HasActualAudioMediaData != HasActualAudioMediaData)
            {
                //System.Diagnostics.Debug.Fail("! ValueEquals !");
                return(false);
            }
            if (HasActualAudioMediaData && !AudioMediaData.ValueEquals(otherz.AudioMediaData))
            {
                //System.Diagnostics.Debug.Fail("! ValueEquals !");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public Paste(ProjectView.ProjectView view, double pasteTime)
            : base(view)
        {
            mNode = view.SelectedNodeAs <PhraseNode>();
            //AudioSelection selection = (AudioSelection)view.Selection;
            mMediaBefore = mNode.Audio.Copy();
            mMediaAfter  = mMediaBefore.Copy();
            urakawa.media.data.audio.ManagedAudioMedia copy;
            if (view.Clipboard is AudioClipboard)
            {
                AudioClipboard clipboard = (AudioClipboard)view.Clipboard;

                copy = view.Presentation.MediaFactory.CreateManagedAudioMedia();
                WavAudioMediaData mediaData = ((WavAudioMediaData)((PhraseNode)clipboard.Node).Audio.AudioMediaData).Copy(
                    new Time((long)(clipboard.AudioRange.SelectionBeginTime * Time.TIME_UNIT)),
                    new Time((long)(clipboard.AudioRange.SelectionEndTime * Time.TIME_UNIT))
                    );
                copy.AudioMediaData = mediaData;
            }
            else
            {
                copy = ((PhraseNode)view.Clipboard.Node).Audio.Copy();
            }
            urakawa.media.data.audio.ManagedAudioMedia after;

            after = mMediaAfter.Split(new Time((long)(pasteTime * Time.TIME_UNIT)));

            double begin = mMediaAfter.Duration.AsMilliseconds;

            mSelectionAfter = new AudioSelection(mNode, view.Selection.Control,
                                                 new AudioRange(begin, begin + copy.Duration.AsMilliseconds));
            mMediaAfter.AudioMediaData.MergeWith(copy.AudioMediaData);
            mMediaAfter.AudioMediaData.MergeWith(after.AudioMediaData);
            SetDescriptions(Localizer.Message("paste_audio"));
        }
        /// <summary>
        /// Fires the <see cref="MediaDataChanged"/> event
        /// </summary>
        /// <param name="source">
        /// The source, that is the <see cref="ManagedAudioMedia"/> whoose <see cref="audio.AudioMediaData"/> has changed
        /// </param>
        /// <param name="newData">The new <see cref="audio.AudioMediaData"/></param>
        /// <param name="prevData">The <see cref="audio.AudioMediaData"/> prior to the change</param>
        protected void NotifyMediaDataChanged(ManagedAudioMedia source, AudioMediaData newData, AudioMediaData prevData)
        {
            EventHandler <MediaDataChangedEventArgs> d = MediaDataChanged;

            if (d != null)
            {
                d(this, new MediaDataChangedEventArgs(source, newData, prevData));
            }
        }
        /// <summary>
        /// Gets a copy of the <see cref="Media"/>
        /// </summary>
        /// <returns>The copy</returns>
        protected override Media CopyProtected()
        {
            ManagedAudioMedia cp = (ManagedAudioMedia)base.CopyProtected();

            if (HasActualAudioMediaData)
            {
                cp.AudioMediaData = AudioMediaData.Copy();
            }
            return(cp);
        }
        /// <summary>
        /// Exports the external audio media to a destination <see cref="Presentation"/>
        /// </summary>
        /// <param name="destPres">The destination presentation</param>
        /// <returns>The exported external audio media</returns>
        protected override Media ExportProtected(Presentation destPres)
        {
            ManagedAudioMedia exported = (ManagedAudioMedia)base.ExportProtected(destPres);

            if (HasActualAudioMediaData)
            {
                exported.AudioMediaData = AudioMediaData.Export(destPres) as AudioMediaData;
            }

            return(exported);
        }
        /// <summary>
        /// Splits <c>this</c> at a given <see cref="Time"/>
        /// </summary>
        /// <param name="splitPoint">The <see cref="Time"/> at which to split -
        /// must be between clip begin and clip end <see cref="Time"/>s</param>
        /// <returns>
        /// A newly created <see cref="AbstractAudioMedia"/> containing the audio after <paramref localName="splitPoint"/>,
        /// <c>this</c> retains the audio before <paramref localName="splitPoint"/>.
        /// </returns>
        /// <exception cref="exception.MethodParameterIsNullException">
        /// Thrown when <paramref name="splitPoint"/> is <c>null</c>
        /// </exception>
        /// <exception cref="exception.MethodParameterIsOutOfBoundsException">
        /// Thrown when <paramref name="splitPoint"/> is not between clip begin and clip end
        /// </exception>
        protected override AbstractAudioMedia SplitProtected(Time splitPoint)
        {
            ManagedAudioMedia secondPartMAM = Presentation.MediaFactory.Create <ManagedAudioMedia>();

            if (HasActualAudioMediaData)
            {
                AudioMediaData secondPartData = AudioMediaData.Split(splitPoint);
                secondPartMAM.AudioMediaData = secondPartData;
            }

            return(secondPartMAM);
        }
        private void AppendAudioData(string filename, ManagedAudioMedia amd)
        {
            uint dataLength;
            AudioLibPCMFormat info = GetInfo("audiotest1-mono-22050Hz-16bits.wav", out dataLength);

            mManagedAudioMedia1.AudioMediaData.PCMFormat = new PCMFormatInfo(info);
            Stream fs = GetRawStream("audiotest1-mono-22050Hz-16bits.wav");

            try
            {
                amd.AudioMediaData.AppendPcmData(fs, new TimeDelta(info.ConvertBytesToTime(dataLength)));
            }
            finally
            {
                fs.Close();
            }
        }