*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public interface Filter extends Source, Sink {
+public interface Filter extends Controlled, Source, Sink {
}
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public interface Sink {
+public interface Sink extends Controlled {
/**
* Opens this sink using the format parameters of the given metadata.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public interface Source {
+public interface Source extends Controlled {
/**
* Returns the metadata of the audio stream.
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Filter;
import net.pterodactylus.sonitus.data.Metadata;
private Metadata metadata;
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// FILTER METHODS
//
package net.pterodactylus.sonitus.data.sink;
+import static javax.sound.sampled.FloatControl.Type.VOLUME;
+
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import java.util.logging.Logger;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Sink;
import net.pterodactylus.sonitus.data.Source;
+import net.pterodactylus.sonitus.data.controller.Fader;
import com.google.common.base.Preconditions;
/** The logger. */
private static final Logger logger = Logger.getLogger(AudioSink.class.getName());
+ /** The volume fader. */
+ private final Fader volumeFader;
+
/** The current metadata. */
private Metadata metadata;
/** The audio output. */
private SourceDataLine sourceDataLine;
+ /** Creates a new audio sink. */
+ public AudioSink() {
+ super();
+ volumeFader = new Fader() {
+
+ @Override
+ protected void valueSet(int value) {
+ if (sourceDataLine != null) {
+ FloatControl volumeControl = (FloatControl) sourceDataLine.getControl(VOLUME);
+ volumeControl.setValue(value * volumeControl.getMaximum() / (float) maximum());
+ }
+ }
+ };
+ }
+
+ //
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Arrays.<Controller>asList(volumeFader);
+ }
+
//
// SINK METHODS
//
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
import java.util.logging.Logger;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Sink;
this.path = path;
}
+ //
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
+ // SINK METHODS
+ //
+
@Override
public void open(Metadata metadata) throws IOException {
fileOutputStream = new FileOutputStream(path);
import java.net.Socket;
import java.net.URLEncoder;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Sink;
import net.pterodactylus.sonitus.io.InputStreamDrainer;
}
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// SINK METHODS
//
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
import net.pterodactylus.sonitus.io.IdentifyingInputStream;
}
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// SOURCE METHODS
//
import java.io.EOFException;
import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
import net.pterodactylus.sonitus.data.event.SourceFinishedEvent;
}
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// SOURCE METHODS
//
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import net.pterodactylus.sonitus.data.ContentMetadata;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.FormatMetadata;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
}
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public List<Controller> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// SOURCE METHODS
//