Skip to content
This repository has been archived by the owner on May 8, 2022. It is now read-only.

Commit

Permalink
Yeah updates
Browse files Browse the repository at this point in the history
  • Loading branch information
WearifulCupid0 committed Mar 20, 2022
1 parent 517ae89 commit d4ba3d9
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 22 deletions.
3 changes: 2 additions & 1 deletion LavalinkServer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ dependencies {
implementation(group: 'com.github.natanbc', name: 'lavadsp', version: lavaDspVersion) {
exclude group: 'com.sedmelluq', module: 'lavaplayer'
}

implementation group: 'com.github.WearifulCupid0', name: 'lavadsp-extended', version: lavaDspExtension

implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlinVersion

implementation group: 'org.springframework', name: 'spring-websocket', version: springWebSocketVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import com.sedmelluq.discord.lavaplayer.source.http.HttpAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.iheart.iHeartAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.mixcloud.MixcloudAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.jamendo.JamendoAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.newgrounds.NewgroundsAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.ocremix.OcremixAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.odysee.OdyseeAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.reddit.RedditAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.local.LocalAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.soundcloud.*
import com.sedmelluq.discord.lavaplayer.source.soundgasm.SoundgasmAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.streamable.StreamableAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.tiktok.TiktokAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.tunein.TuneinAudioSourceManager
Expand Down Expand Up @@ -130,10 +130,10 @@ class AudioPlayerConfiguration {
if (sources.isIheart) audioPlayerManager.registerSourceManager(iHeartAudioSourceManager(search.isIheart))
if (sources.isJamendo) audioPlayerManager.registerSourceManager(JamendoAudioSourceManager(search.isJamendo))
if (sources.isMixcloud) audioPlayerManager.registerSourceManager(MixcloudAudioSourceManager(search.isMixcloud))
if (sources.isNewgrounds) audioPlayerManager.registerSourceManager(NewgroundsAudioSourceManager())
if (sources.isOcremix) audioPlayerManager.registerSourceManager(OcremixAudioSourceManager())
if (sources.isOdysee) audioPlayerManager.registerSourceManager(OdyseeAudioSourceManager(search.isOdysee))
if (sources.isReddit) audioPlayerManager.registerSourceManager(RedditAudioSourceManager())
if (sources.isSoundgasm) audioPlayerManager.registerSourceManager(SoundgasmAudioSourceManager())
if (sources.isStreamable) audioPlayerManager.registerSourceManager(StreamableAudioSourceManager())
if (sources.isTiktok) audioPlayerManager.registerSourceManager(TiktokAudioSourceManager())
if (sources.isTunein) audioPlayerManager.registerSourceManager(TuneinAudioSourceManager())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class AudioSourcesConfig {
private boolean iheart = true;
private boolean jamendo = true;
private boolean mixcloud = true;
private boolean newgrounds = true;
private boolean ocremix = true;
private boolean odysee = true;
private boolean reddit = true;
private boolean soundcloud = true;
private boolean soundgasm = true;
private boolean streamable = true;
private boolean tiktok = true;
private boolean tunein = true;
Expand Down Expand Up @@ -172,14 +172,6 @@ public void setMixcloud(boolean mixcloud) {
this.mixcloud = mixcloud;
}

public boolean isNewgrounds() {
return newgrounds;
}

public void setNewgrounds(boolean newgrounds) {
this.newgrounds = newgrounds;
}

public boolean isOcremix() {
return ocremix;
}
Expand All @@ -204,6 +196,14 @@ public void setReddit(boolean reddit) {
this.reddit = reddit;
}

public boolean isSoundgasm() {
return soundgasm;
}

public void setSoundgasm(boolean soundgasm) {
this.soundgasm = soundgasm;
}

public boolean isStreamable() {
return streamable;
}
Expand Down
54 changes: 48 additions & 6 deletions LavalinkServer/src/main/java/lavalink/server/io/SocketContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class SocketContext(
out.put("op", "event")
out.put("event", "VoiceConnectionClosed")
out.put("guildId", player.guildId.toString())
out.put("reason", reason ?: "")
out.put("reason", reason ?: JSONObject.NULL)
out.put("code", code)
out.put("byRemote", byRemote)

Expand All @@ -290,16 +290,13 @@ class SocketContext(
SocketServer.sendPlayerUpdate(this@SocketContext, player)
}

override fun gatewayReady(target: InetSocketAddress?, ssrc: Int) {
override fun gatewayReady(target: InetSocketAddress, ssrc: Int) {
val out = JSONObject()
out.put("op", "event")
out.put("event", "VoiceConnectionReady")
out.put("guildId", player.guildId.toString())
out.put("ssrc", ssrc)

if (target != null) {
out.put("address", target.getAddress().toString())
}
out.put("address", target.getAddress().toString())

send(out)

Expand All @@ -313,6 +310,51 @@ class SocketContext(
out.put("guildId", player.guildId.toString())

send(out)

SocketServer.sendPlayerUpdate(this@SocketContext, player)
}

override fun userConnected(id: String, audioSSRC: Int, videoSSRC: Int, rtxSSRC: Int) {
val out = JSONObject()
out.put("op", "event")
out.put("event", "VoiceUserConnected")
out.put("guildId", player.guildId.toString())
out.put("userId", id)
out.put("audioSSRC", audioSSRC)
out.put("videoSSRC", videoSSRC)
out.put("rtxSSRC", rtxSSRC)

send(out)
}

override fun userDisconnected(id: String) {
val out = JSONObject()
out.put("op", "event")
out.put("event", "VoiceUserDisconnected")
out.put("guildId", player.guildId.toString())
out.put("userId", id)

send(out)
}

override fun externalIPDiscovered(target: InetSocketAddress) {
val out = JSONObject()
out.put("op", "event")
out.put("event", "VoiceExternalIpDiscovered")
out.put("guildId", player.guildId.toString())
out.put("address", target.getAddress().toString())

send(out)
}

override fun sessionDescription(session: JsonObject) {
val out = JSONObject()
out.put("op", "event")
out.put("event", "VoiceSessionDescription")
out.put("guildId", player.guildId.toString())
out.put("session", JSONObject(session.toString()))

send(out)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class FilterChain {
private final ChannelMixConfig channelMixConfig = new ChannelMixConfig();
private final DistortionConfig distortionConfig = new DistortionConfig();
private final EchoConfig echoConfig = new EchoConfig();
private final EqualizerConfig equalizerConfig = new EqualizerConfig();
private final KaraokeConfig karaokeConfig = new KaraokeConfig();
private final LowPassConfig lowPassConfig = new LowPassConfig();
Expand All @@ -36,6 +37,7 @@ public class FilterChain {
public FilterChain(AudioPlayer player) {
filters.put(channelMixConfig.getClass(), channelMixConfig);
filters.put(distortionConfig.getClass(), distortionConfig);
filters.put(echoConfig.getClass(), echoConfig);
filters.put(equalizerConfig.getClass(), equalizerConfig);
filters.put(karaokeConfig.getClass(), karaokeConfig);
filters.put(lowPassConfig.getClass(), lowPassConfig);
Expand Down Expand Up @@ -103,6 +105,10 @@ public DistortionConfig getDistortionConfig() {
return distortionConfig;
}

public EchoConfig getEchoConfig() {
return echoConfig;
}

public EqualizerConfig getEqualizerConfig() {
return equalizerConfig;
}
Expand Down Expand Up @@ -179,6 +185,12 @@ public static void setFiltersFromJSON(JSONObject json, FilterChain filterChain)
distortionConfig.setOffset(distortion.optFloat("offset", distortionConfig.getOffset()));
distortionConfig.setScale(distortion.optFloat("scale", distortionConfig.getScale()));
}
if (json.has("echo")) {
JSONObject echo = json.getJSONObject("echo");
EchoConfig echoConfig = filterChain.getEchoConfig();
echoConfig.setDecay(echo.optFloat("decay", echoConfig.getDecay()));
echoConfig.setDelay(echo.optDouble("delay", echoConfig.getDelay()));
}
if (json.has("equalizer")) {
JSONArray array = json.getJSONObject("equalizer").getJSONArray("bands");
EqualizerConfig equalizerConfig = filterChain.getEqualizerConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package lavalink.server.player.filters.configs;

import lavalink.server.player.filters.FilterConfig;
import me.rohank05.echo.EchoPcmAudioFilter;
import com.sedmelluq.discord.lavaplayer.filter.AudioFilter;
import com.sedmelluq.discord.lavaplayer.filter.FloatPcmAudioFilter;
import com.sedmelluq.discord.lavaplayer.format.AudioDataFormat;
import org.json.JSONObject;

public class EchoConfig implements FilterConfig {
private float decay = -1;
private double delay = -1;

public float getDecay() {
return this.decay;
}

public double getDelay() {
return this.delay;
}

public void setDecay(float decay) {
this.decay = decay;
}

public void setDelay(double delay) {
this.delay = delay;
}

@Override
public String getFilterName() {
return "echo";
}

@Override
public boolean isEnabled() {
return FilterConfig.isSet(this.decay, -1) || FilterConfig.isSet((float) this.delay, -1);
}

@Override
public AudioFilter create(AudioDataFormat format, FloatPcmAudioFilter output) {
return new EchoPcmAudioFilter(output, format.channelCount, format.sampleRate)
.setDecay(this.decay)
.setDelay(this.delay);
}

@Override
public JSONObject encode() {
return new JSONObject().put("decay", this.decay).put("delay", this.delay);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void handle(MarkerState state) {
track.setPosition(segment.getEndTime());
JSONObject json = new JSONObject()
.put("op", "event")
.put("event", "TrackSegmentSkipped")
.put("event", "SponsorblockSegmentSkipped")
.put("guildId", this.player.getGuildId())
.put("segment", segment.encode());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void handleTrack(AudioTrack track, PlayerServicesHandler servicesH
if (!segments.isEmpty()) {
JSONObject json = new JSONObject()
.put("op", "event")
.put("event", "TrackSegmentLoaded")
.put("event", "SponsorblockSegmentLoaded")
.put("guildId", servicesHandler.getPlayer().getGuildId())
.put("segments",
new JSONArray(segments.stream().map(Segment::encode).collect(Collectors.toList())));
Expand All @@ -82,7 +82,7 @@ public static void handleTrack(AudioTrack track, PlayerServicesHandler servicesH
} catch (FriendlyException err) {
JSONObject out = new JSONObject()
.put("op", "event")
.put("event", "TrackSegmentFailed")
.put("event", "SponsorblockSegmentFailed")
.put("guildId", servicesHandler.getPlayer().getGuildId());

try {
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ subprojects {
ext {
//@formatter:off

lavaplayerVersion = 'e41833c31c'
lavaplayerVersion = '18fc3d2524'
lavaplayerIpRotatorVersion = '0.2.3'
jdaNasVersion = '1.1.0'
jappVersion = '1.3.2-MINN'
koeVersion = '3b6a6d073f'
lavaDspVersion = '0.7.7'
lavaDspExtension = 'bc066edd34'

springBootVersion = "${springBootVersion}"
springWebSocketVersion = '5.1.9.RELEASE'
Expand Down

0 comments on commit d4ba3d9

Please sign in to comment.