X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2FFormat.java;h=59ba9ef9d921f7c861209108fb1756dc32e9c49e;hb=fcd64fc58fa16983938cfab4510e9cf555e9e1e4;hp=84a070d3265a788b370a73d96260ca20c1bb0d29;hpb=abbc1761cc1ff6eb1b4a68b73eaa1064233b4d6b;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/Format.java b/src/main/java/net/pterodactylus/sonitus/data/Format.java index 84a070d..59ba9ef 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Format.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Format.java @@ -25,6 +25,15 @@ package net.pterodactylus.sonitus.data; */ public class Format { + /** Constant for an unknown number of channels. */ + public static final int UNKNOWN_CHANNELS = -1; + + /** Constant for an unknown frequency. */ + public static final int UNKNOWN_FREQUENCY = -1; + + /** Constant for an unknown format. */ + public static final String UNKNOWN_ENCODING = "UNKNOWN"; + /** The number of channels of this format. */ private final int channels; @@ -82,6 +91,46 @@ public class Format { } // + // MUTATORS + // + + /** + * Returns a format with the same parameters as this format and the given + * number of channels. + * + * @param channels + * The new number of channels + * @return A new format with the given number of channels + */ + public Format channels(int channels) { + return new Format(channels, frequency, encoding); + } + + /** + * Returns a new format with the same parameters as this format and the given + * frequency. + * + * @param frequency + * The new frequency + * @return A new format with the given frequency + */ + public Format frequency(int frequency) { + return new Format(channels, frequency, encoding); + } + + /** + * Returns a new format with the same parameters as this format and the given + * encoding. + * + * @param encoding + * The new encoding + * @return A new format with the given encoding + */ + public Format encoding(String encoding) { + return new Format(channels, frequency, encoding); + } + + // // OBJECT METHODS // @@ -101,7 +150,7 @@ public class Format { @Override public String toString() { - return String.format("%d Channels, %d Hz, %s", channels, frequency, encoding); + return String.format("%d Channel%s, %d Hz, %s", channels, channels != 1 ? "s" : "", frequency, encoding); } }