public interface Controlled {
/**
+ * Returns the name of this controlled component.
+ *
+ * @return The name of this controlled component
+ */
+ public String name();
+
+ /**
* Returns the controllers offered by this component.
*
* @return The controllers of this component
*/
public abstract class AudioProcessingFilter extends DummyFilter {
+ /**
+ * Creates a new audio processing filter with the given name.
+ *
+ * @param name
+ * The name of the filter
+ */
+ protected AudioProcessingFilter(String name) {
+ super(name);
+ }
+
//
// DUMMYFILTER METHODS
//
*/
public class DummyFilter implements Filter {
+ /** The name of this filter. */
+ private final String name;
+
/** The input stream from which to read. */
private InputStream inputStream;
/** The current metadata. */
private Metadata metadata;
+ /**
+ * Creates a new dummy filter with the given name.
+ *
+ * @param name
+ * The name of the filter
+ */
+ public DummyFilter(String name) {
+ this.name = name;
+ }
+
//
// CONTROLLED METHODS
//
@Override
+ public String name() {
+ return name;
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
/** The external process. */
private Process process;
+ /**
+ * Creates a new external filter with the given name.
+ *
+ * @param name
+ * The name of the filter
+ */
+ protected ExternalFilter(String name) {
+ super(name);
+ }
+
//
// FILTER METHODS
//
*/
public abstract class ExternalMp3Decoder extends ExternalFilter {
+ /**
+ * Creates a new external MP3 decoder.
+ *
+ * @param name
+ * The name of the filter
+ */
+ protected ExternalMp3Decoder(String name) {
+ super(name);
+ }
+
@Override
public Metadata metadata() {
return super.metadata().encoding("PCM");
*/
public abstract class ExternalMp3Encoder extends ExternalFilter {
+ /**
+ * Creates a new external MP3 encoder.
+ *
+ * @param name
+ * The name of the filter
+ */
+ protected ExternalMp3Encoder(String name) {
+ super(name);
+ }
+
@Override
public Metadata metadata() {
return super.metadata().encoding("MP3");
* The location of the binary
*/
public FlacDecoder(String binary) {
+ super("FLAC Decoder");
this.binary = binary;
}
* The location of the binary
*/
public LameMp3Decoder(String binary) {
+ super("LAME Decoder");
this.binary = binary;
}
* The bitrate to encode to (in kbps)
*/
private LameMp3Encoder(String binary, Preset preset, int bitrate) {
+ super("LAME Encoder");
this.binary = binary;
this.preset = Optional.fromNullable(preset);
this.bitrate = (bitrate < 0) ? Optional.<Integer>absent() : Optional.<Integer>of(bitrate);
* The location of the binary
*/
public OggVorbisDecoder(String binary) {
+ super("Ogg Vorbis Decoder");
this.binary = binary;
}
* The filter to use if the predicate matches the metadata
*/
public PredicateFilter(Predicate<Metadata> metadataPredicate, Filter filter) {
+ super(String.format("%s (maybe)", filter.name()));
this.metadataPredicate = metadataPredicate;
this.filter = filter;
}
/**
* Creates a new rate limiting filter.
*
+ * @param name
+ * The name of the filter
* @param rate
* The limiting rate (in bytes/second)
*/
- public RateLimitingFilter(int rate) {
- this(rate, 0);
+ public RateLimitingFilter(String name, int rate) {
+ this(name, rate, 0);
}
/**
* Creates a new rate limiting filter.
*
+ * @param name
+ * The name of the filter
* @param rate
* The limiting rate (in bytes/second)
* @param fastStartTime
* The amount of time at the start of the filtering during which no delay
* will occur (in milliseconds)
*/
- public RateLimitingFilter(int rate, long fastStartTime) {
+ public RateLimitingFilter(String name, int rate, long fastStartTime) {
+ super(name);
this.rate = rate;
this.counter = (long) (-rate * (fastStartTime / 1000.0));
}
* The new sampling rate
*/
public SoxResampleFilter(String binary, int rate) {
+ super(String.format("Resample to %s kHz", rate / 1000.0));
this.binary = binary;
this.rate = rate;
}
/** Creates a new stereo separation filter. */
public StereoSeparationFilter() {
+ super("Stereo Separation");
separationKnob = new Knob("Separation", 1.0);
}
/**
* Creates a new time counter filter that automatically resets the counter when
* the metadata is {@link #metadataUpdated(Metadata) updated}.
+ *
+ * @param name
+ * The name of the filter
*/
- public TimeCounterFilter() {
- this(true);
+ public TimeCounterFilter(String name) {
+ this(name, true);
}
/**
* Creates a new time counter filter.
*
+ * @param name
+ * The name of the filter
* @param resetOnMetadataUpdate
* {@code true} if the counter should automatically be reset if the metadata
* is updated, {@code false} otherwise
*/
- public TimeCounterFilter(boolean resetOnMetadataUpdate) {
+ public TimeCounterFilter(String name, boolean resetOnMetadataUpdate) {
+ super(name);
this.resetOnMetadataUpdate = resetOnMetadataUpdate;
}
/** Creates a new audio sink. */
public AudioSink() {
- super();
volumeFader = new Fader("Volume") {
@Override
//
@Override
+ public String name() {
+ return "Audio Output";
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Arrays.<Controller<?>>asList(volumeFader, muteSwitch);
}
//
@Override
+ public String name() {
+ return path;
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
//
@Override
+ public String name() {
+ return String.format("icecast://%s:%d/%s", server, port, mountPoint);
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
//
@Override
+ public String name() {
+ return path;
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
//
@Override
+ public String name() {
+ return "Multisource";
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
/** The URL of the stream. */
private final String streamUrl;
+ /** The name of the station. */
+ private final String streamName;
+
/** The metadata stream. */
private final MetadataStream metadataStream;
metadata = new Metadata(new FormatMetadata(audioParameters.get("ice-channels"), audioParameters.get("ice-samplerate"), "MP3"), new ContentMetadata());
metadataStream = new MetadataStream(new BufferedInputStream(httpUrlConnection.getInputStream()), metadataInterval);
+ streamName = httpUrlConnection.getHeaderField("ICY-Name");
}
//
//
@Override
+ public String name() {
+ return streamName;
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
return;
}
ControlledPane controlledPane = new ControlledPane(controlled);
- tabbedPane.addTab(controlled.toString(), controlledPane);
+ tabbedPane.addTab(controlled.name(), controlledPane);
}
}