From 577d2d5723539b8dc25d09a9a51963985f1c449f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 29 Jul 2012 00:15:53 +0200 Subject: [PATCH] Add audio codec helper class. --- .../demoscenemusic/utils/AudioCodecs.java | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java diff --git a/src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java b/src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java new file mode 100644 index 0000000..baa4e92 --- /dev/null +++ b/src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java @@ -0,0 +1,86 @@ +/* + * DemosceneMusic - AudioCodecFilter.java - Copyright © 2012 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.demoscenemusic.utils; + +import java.util.HashMap; +import java.util.Map; + +/** + * Helper for audio codec descriptions. + * + * @author David ‘Bombe’ Roden + */ +public class AudioCodecs { + + /** Descriptions for audio codecs. */ + public static final Map codecDescriptions = new HashMap(); + + static { + codecDescriptions.put("mp3", new AudioCodecDescription("MPEG 1 Layer 3", "MP3", true, false)); + codecDescriptions.put("vorbis", new AudioCodecDescription("Ogg Vorbis", "Vorbis", true, false)); + codecDescriptions.put("aac", new AudioCodecDescription("Advanced Audio Coding", "AAC", true, false)); + codecDescriptions.put("flac", new AudioCodecDescription("Free Lossless Audio Codec", "FLAC", true, true)); + codecDescriptions.put("WAV", new AudioCodecDescription("Waveform Audio", "WAV", true, true)); + codecDescriptions.put("mod", new AudioCodecDescription("Module", "MOD", false, true)); + } + + /** + * Bundles descriptions for various audio codecs. For simplicity reasons, + * file formats such as MOD, IT, or SID are also treated as audio codecs + * even though they are not. + * + * @author David ‘Bombe’ Roden + */ + public final static class AudioCodecDescription { + + /** The full name of the codec. */ + public final String name; + + /** The short name of the codec. */ + public final String shortName; + + /** Whether this is a streaming codec. */ + public final boolean streaming; + + /** Whether this codec is lossless. */ + public final boolean lossless; + + /** + * Creates a new audio codec description. + * + * @param name + * The full name of the codec + * @param shortName + * The short name of the codec + * @param streaming + * {@code true} if the codec is a streaming audio codec, + * {@code false} otherwise + * @param lossless + * {@code true} if the codec is a lossless audio codec, + * {@code false} otherwise + */ + AudioCodecDescription(String name, String shortName, boolean streaming, boolean lossless) { + this.name = name; + this.shortName = shortName; + this.streaming = streaming; + this.lossless = lossless; + } + + } + +} -- 2.7.4