1 package org.daisy.pipeline.audio;
2
3 import java.io.File;
4 import java.net.URI;
5 import java.time.Duration;
6
7
8
9
10 public final class AudioClip {
11
12 public final URI src;
13 public final Duration clipBegin;
14 public final Duration clipEnd;
15
16 public AudioClip(File src, Duration clipBegin, Duration clipEnd) {
17 this(src == null ? null : src.toURI(), clipBegin, clipEnd);
18 }
19
20 public AudioClip(URI src, Duration clipBegin, Duration clipEnd) {
21 if (clipBegin == null || clipEnd == null || src == null)
22 throw new NullPointerException();
23 if (clipBegin.compareTo(Duration.ZERO) < 0)
24 throw new IllegalArgumentException("Clip begin can not be negative");
25 if (clipEnd.compareTo(clipBegin) < 0)
26 throw new IllegalArgumentException("Clip end can not come before clip begin");
27 this.src = src;
28 this.clipBegin = clipBegin;
29 this.clipEnd = clipEnd;
30 }
31
32 @Override
33 public String toString() {
34 return "[src: " + src + ", clipBegin: " + clipBegin + ", clipEnd: " + clipEnd + "]";
35 }
36 }