public WavAudioMediaData Copy(Time timeBegin, Time timeEnd) { if (timeBegin == null || timeEnd == null) { throw new exception.MethodParameterIsNullException("Clip begin or clip end can not be null"); } if ( timeBegin.IsLessThan(Time.Zero) || timeEnd.IsLessThan(Time.Zero) || (timeEnd.IsGreaterThan(Time.Zero) && timeBegin.IsGreaterThan(timeEnd)) || timeEnd.IsGreaterThan(AudioDuration)) { throw new exception.MethodParameterIsOutOfBoundsException( String.Format("The given clip times are not valid, must be between 00:00:00.000 and {0} ([{1} --> {2})", AudioDuration, timeBegin, timeEnd)); } WavAudioMediaData copy = Copy(); if (timeEnd.IsGreaterThan(Time.Zero) && timeEnd.IsLessThan(AudioDuration)) { copy.RemovePcmData(timeEnd, AudioDuration); } if (timeBegin.IsGreaterThan(Time.Zero)) { copy.RemovePcmData(Time.Zero, timeBegin); } return(copy); }
/// <summary> /// Merges <c>this</c> with a given other <see cref="AudioMediaData"/>, /// appending the audio data of the other <see cref="AudioMediaData"/> to <c>this</c>, /// leaving the other <see cref="AudioMediaData"/> without audio data /// </summary> /// <param name="other">The given other AudioMediaData</param> /// <exception cref="exception.MethodParameterIsNullException"> /// Thrown when <paramref name="other"/> is <c>null</c> /// </exception> /// <exception cref="exception.InvalidDataFormatException"> /// Thrown when the PCM format of <c>this</c> is not compatible with that of <paramref name="other"/> /// </exception> public override void MergeWith(AudioMediaData other) { if (other == this) { throw new exception.OperationNotValidException("Can not merge a AudioMediaData with itself"); } if (other is WavAudioMediaData) { if (!PCMFormat.Data.IsCompatibleWith(other.PCMFormat.Data)) { throw new exception.InvalidDataFormatException( "Can not merge this with a WavAudioMediaData with incompatible audio data"); } Time thisInsertPoint = AudioDuration; WavAudioMediaData otherWav = (WavAudioMediaData)other; mWavClips.AddRange(otherWav.mWavClips); Time dur = otherWav.AudioDuration; NotifyAudioDataInserted(this, thisInsertPoint, dur); otherWav.RemovePcmData(Time.Zero); } else { base.MergeWith(other); } }