From b0415b032429c4fc8d19a96fc7a34ff92bf656d5 Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Thu, 23 Jun 2022 21:06:49 +0100 Subject: [PATCH] Downloader: link preferred bitrate to JDA requested format. --- src/main/java/moe/nekojimi/chords/Downloader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/moe/nekojimi/chords/Downloader.java b/src/main/java/moe/nekojimi/chords/Downloader.java index 0abb3ad..24892c6 100644 --- a/src/main/java/moe/nekojimi/chords/Downloader.java +++ b/src/main/java/moe/nekojimi/chords/Downloader.java @@ -28,6 +28,7 @@ import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonReader; import moe.nekojimi.chords.Downloader.DownloadTask; +import net.dv8tion.jda.api.audio.AudioSendHandler; /** * @@ -40,7 +41,7 @@ public class Downloader implements Consumer private static final int INFO_TIMEOUT = 10; private static final int FORMAT_TIMEOUT = 5; - private static final int BITRATE_TARGET = 64_000; + private static final int BITRATE_TARGET = (int) AudioSendHandler.INPUT_FORMAT.getSampleRate(); private static final Pattern FORMAT_PATTERN = Pattern.compile("^([\\w]+)\\s+([\\w]+)\\s+(\\w+ ?\\w*)\\s+(.*)$"); public static final Pattern DESTINATION_PATTERN = Pattern.compile("Destination: (.*\\.wav)");