2 * Sonitus - LameMp3Decoder.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sonitus.data.filter;
20 import net.pterodactylus.sonitus.data.Metadata;
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.eventbus.EventBus;
26 * {@link ExternalMp3Decoder} implementation that uses LAME to decode an MP3.
28 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30 public class LameMp3Decoder extends ExternalMp3Decoder {
32 /** The location of the binary. */
33 private final String binary;
35 /** Whether to swap bytes in the decoded output. */
36 private boolean swapBytes;
39 * Creates a new LAME MP3 decoder.
44 * The location of the binary
46 public LameMp3Decoder(EventBus eventBus, String binary) {
47 super(eventBus, "LAME Decoder");
52 * Sets whether to swap bytes on the decoded output.
55 * {@code true} to swap the decoded bytes, {@code false} to use platform
57 * @return This MP3 decoder
59 public LameMp3Decoder swapBytes(boolean swapBytes) {
60 this.swapBytes = swapBytes;
65 // EXTERNALFILTER METHODS
69 protected String binary(Metadata metadata) {
74 protected Iterable<String> parameters(Metadata metadata) {
75 ImmutableList.Builder<String> parameters = ImmutableList.builder();
76 parameters.add("--mp3input").add("--decode").add("-t");
80 parameters.add("-").add("-");
81 return parameters.build();