/// <summary> /// Creates a new <see cref="AudioClip"/> from <paramref name="source"/> with new <paramref name="start"/>. /// </summary> /// <param name="source">Base <see cref="AudioClip"/> where data is gotten.</param> /// <param name="name">Name of new <see cref="AudioClip"/>.</param> /// <param name="start">Start position in seconds.</param> /// <returns>New <see cref="AudioClip"/> with specified duration.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> or <paramref name="name"/> are <see langword="null"/>.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="name"/> is empty.</exception> /// <exception cref="ArgumentOutOfRangeException">Throw if <paramref name="start"/> is negative.</exception> public static AudioClip CreateSlice(this AudioClip source, string name, float start) => source.CreateSlice(name, start, source.length - start);
/// <summary> /// Creates a new <see cref="AudioClip"/> from <paramref name="source"/> with new <paramref name="start"/>. /// </summary> /// <param name="source">Base <see cref="AudioClip"/> where data is gotten.</param> /// <param name="start">Start position in seconds.</param> /// <returns>New <see cref="AudioClip"/> with specified duration.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentOutOfRangeException">Throw if <paramref name="start"/> is negative.</exception> public static AudioClip CreateSlice(this AudioClip source, float start) => source.CreateSlice($"{source.name}_start_{ToTime(start)}", start, source.length - start);
/// <summary> /// Creates a new <see cref="AudioClip"/> from <paramref name="source"/> with new <paramref name="start"/>. /// </summary> /// <param name="source">Base <see cref="AudioClip"/> where data is gotten.</param> /// <param name="start">Start position in seconds.</param> /// <param name="length">Lenght in seconds.</param> /// <returns>New <see cref="AudioClip"/> with specified duration.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentOutOfRangeException">Throw if <paramref name="start"/> is negative, <paramref name="length"/> isn't greater than 0 or the sum of <paramref name="start"/> and <paramref name="length"/> is greater than <c><paramref name="source"/>.length</c>.</exception> public static AudioClip CreateSlice(this AudioClip source, float start, float length) => source.CreateSlice($"{source.name}_start_{ToTime(start)}_end_{ToTime(start + length)}]", start, length);