Comments (4)
if someone here I can leave it
from example-bots.
Volume is not a trivial matter. You need to understand PCM to be able to do that. As such, there will be no examples for changing volume.
from example-bots.
Im using this, is working
`
private double Volume { get; set; } = 0.10;
private unsafe void RescaleVolume(byte[] data)
{
fixed (byte* ptr8 = data)
{
var ptr16 = (short*)ptr8;
for (var i = 0; i < data.Length / 2; i++)
*(ptr16 + i) = (short)(*(ptr16 + i) * this.Volume);
}
}
[Command("volume")]
public async Task VolumeAsync(CommandContext ctx, double vol)
{
Volume = vol / 100;
await ctx.RespondAsync($"Volumen puesto en {(vol).ToString()}%");
}
And i change the play command while for this:
[Command("play")]
public async Task Play(CommandContext ctx, [RemainingText] string file)
{
var vnext = ctx.Client.GetVoiceNextClient();
var vnc = vnext.GetConnection(ctx.Guild);
if (vnc == null)
throw new InvalidOperationException("Not connected in this guild.");
if (!File.Exists(file))
throw new FileNotFoundException("File was not found.");
await ctx.RespondAsync("👌");
await vnc.SendSpeakingAsync(true); // send a speaking indicator
var psi = new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $@"-i ""{file}"" -ac 2 -f s16le -ar 48000 pipe:1",
RedirectStandardOutput = true,
UseShellExecute = false
};
var ffmpeg = Process.Start(psi);
var ffout = ffmpeg.StandardOutput.BaseStream;
var buff = new byte[3840];
var br = 0;
while ((br = ffout.Read(buff, 0, buff.Length)) > 0)
{
if (br < buff.Length) // not a full sample, mute the rest
for (var i = br; i < buff.Length; i++)
buff[i] = 0;
if (Volume != 1.0)
RescaleVolume(buff);
await vnc.SendAsync(buff, 20);
}
await vnc.SendSpeakingAsync(false); // we're not speaking anymore
}
`
from example-bots.
I know - that's my code. It's still not a clean way, and I am not willing to suggest that. FFmpeg might be offering some options.
from example-bots.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-bots.