You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of audio passed through DSharpPlus with VoiceNext has noise in it.
Provided problem.mp4 (recorded from soundcard out) for example, test.mp4 (cut down version because of copyright) is the input
Details
Tried running on both Windows 10 and Ubuntu 20.04 with discord clients tried on both Windows 10 and Android. Any combination has the same issue.
Tried both .NET 6.0 and .NET 7.0
Packages tried with both NuGet and cloning release/4.3
DSharpPlus v4.3.0
DSharpPlus.CommandsNext v4.3.0
DSharpPlus.Interactivity v4.3.0
DSharpPlus.Rest v4.3.0
DSharpPlus.SlashCommands v4.3.0
DSharpPlus.VoiceNext v4.3.0
DSharpPlus.VoiceNext.Natives v1.0.0
FFMPEG: Tried both pre-compiled and self-compiled
Pre-compiled version: ffmpeg version 2022-12-08-git-9ca139b2aa-essentials_build
Self-compiled version: ffmpeg version N-110021-g85b185b504-ffmpeg-windows-build-helpers
Reproduce
Created new project in Visual Studio 2022
Used NuGet to install DSharpPlus v4.3.0 / Natives 1.0.0
Added test.mp4, ffmpeg.exe and a TOKEN.txt to the output bin folder
Added provided code to Program.cs
Run program, join discord channel and do '/join' followed by '/play path: test.mp4'
Listen to noisy audio
Program.cs
using System.Diagnostics;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using DSharpPlus.VoiceNext;
using Microsoft.Extensions.Logging;
internal class Program {
public DiscordClient _client;
public SlashCommandsExtension _slashCommands;
public static void Main(string[] args) {
Program program = new();
program.RunAsync().Wait();
}
public Program() {
string discordToken = File.ReadAllText("TOKEN.txt");
_client = new DiscordClient(new DiscordConfiguration {
Token = discordToken,
TokenType = TokenType.Bot,
Intents = DiscordIntents.All,
MinimumLogLevel = LogLevel.Warning
});
_client.UseVoiceNext();
_slashCommands = _client.UseSlashCommands();
_slashCommands.RegisterCommands<MediaCommands>();
}
public async Task RunAsync() {
await _client.ConnectAsync(new("nothing", ActivityType.Playing), UserStatus.Online);
await Task.Delay(-1);
}
internal class MediaCommands : ApplicationCommandModule {
public static Stream? ConvertAudioToPcm(string filePath) {
Process? ffmpeg = Process.Start(new ProcessStartInfo {
FileName = "ffmpeg",
Arguments = $@"-i ""{filePath}"" -ac 2 -f s16le -ar 48000 pipe:1",
RedirectStandardOutput = true,
UseShellExecute = false
});
return ffmpeg?.StandardOutput.BaseStream;
}
[SlashCommand("join", "joins")]
public async Task JoinCommand(InteractionContext ctx) {
DiscordChannel channel = ctx.Member.VoiceState?.Channel;
await channel.ConnectAsync();
}
[SlashCommand("play", "plays")]
public async Task PlayCommand(InteractionContext ctx, [Option("path", "path")] string path) {
VoiceNextExtension vnext = ctx.Client.GetVoiceNext();
VoiceNextConnection connection = vnext.GetConnection(ctx.Guild);
VoiceTransmitSink transmit = connection.GetTransmitSink();
Stream? pcm = ConvertAudioToPcm(path);
await pcm.CopyToAsync(transmit);
await pcm.DisposeAsync();
}
[SlashCommand("leave", "leaves")]
public async Task LeaveCommand(InteractionContext ctx) {
VoiceNextExtension vnext = ctx.Client.GetVoiceNext();
VoiceNextConnection connection = vnext.GetConnection(ctx.Guild);
connection.Disconnect();
}
}
}
Extra
Did not have this problem with Anarchy, but decided to try and switch to DSharpPlus since it seems more actively maintained and has better documentation. Used the same ffmpeg.exe and libs for that.
I've also tried a bunch of different settings with ffmpeg on the test.mp4 file but could not replicate the result without DSharpPlus and since it doesn't happen in Anarchy i'm assuming there's something wrong with DSharpPlus's VoiceNext module?
The text was updated successfully, but these errors were encountered:
VNext in general isn't actively maintained and unfortunately all the active maintainers (myself included) struggles to understand the VNext codebase. We've wanted to rewrite it for awhile now, however nobody has been able to follow through with it.
Unfortunately I cannot provide any solutions, nor am I aware of any alternatives that's compatible with DSharpPlus.
If any progress is made on VNext, I'll be sure to update this issue. Apologies for the inconvenience.
Summary
A lot of audio passed through DSharpPlus with VoiceNext has noise in it.
Provided problem.mp4 (recorded from soundcard out) for example, test.mp4 (cut down version because of copyright) is the input
Details
Tried running on both Windows 10 and Ubuntu 20.04 with discord clients tried on both Windows 10 and Android. Any combination has the same issue.
Tried both .NET 6.0 and .NET 7.0
Packages tried with both NuGet and cloning release/4.3
DSharpPlus v4.3.0
DSharpPlus.CommandsNext v4.3.0
DSharpPlus.Interactivity v4.3.0
DSharpPlus.Rest v4.3.0
DSharpPlus.SlashCommands v4.3.0
DSharpPlus.VoiceNext v4.3.0
DSharpPlus.VoiceNext.Natives v1.0.0
FFMPEG: Tried both pre-compiled and self-compiled
Pre-compiled version: ffmpeg version 2022-12-08-git-9ca139b2aa-essentials_build
Self-compiled version: ffmpeg version N-110021-g85b185b504-ffmpeg-windows-build-helpers
Reproduce
Created new project in Visual Studio 2022
Used NuGet to install DSharpPlus v4.3.0 / Natives 1.0.0
Added test.mp4, ffmpeg.exe and a TOKEN.txt to the output bin folder
Added provided code to Program.cs
Run program, join discord channel and do '/join' followed by '/play path: test.mp4'
Listen to noisy audio
Program.cs
Extra
Did not have this problem with Anarchy, but decided to try and switch to DSharpPlus since it seems more actively maintained and has better documentation. Used the same ffmpeg.exe and libs for that.
I've also tried a bunch of different settings with ffmpeg on the test.mp4 file but could not replicate the result without DSharpPlus and since it doesn't happen in Anarchy i'm assuming there's something wrong with DSharpPlus's VoiceNext module?
The text was updated successfully, but these errors were encountered: