C#で音量[]の音量を変更しようとしています。私はFFMPEGでサウンドファイルを読んで、その場で音量を変えたいと思っています。私はいくつかの例を見つけましたが、私はそれらを理解しませんでした。C#音量をどのように設定しますか[]
public void SendAudio(string pathOrUrl)
{
cancelVid = false;
isPlaying = true;
mProcess = Process.Start(new ProcessStartInfo
{ // FFmpeg requireqs us to spawn a process and hook into its stdout, so we will create a Process
FileName = "ffmpeg",
Arguments = "-i " + (char)34 + pathOrUrl + (char)34 + // Here we provide a list of arguments to feed into FFmpeg. -i means the location of the file/URL it will read from
" -f s16le -ar 48000 -ac 2 pipe:1", // Next, we tell it to output 16-bit 48000Hz PCM, over 2 channels, to stdout.
UseShellExecute = false,
RedirectStandardOutput = true, // Capture the stdout of the process
Verb = "runas"
});
while (!isRunning(mProcess)) { Task.Delay(1000); }
int blockSize = 3840; // The size of bytes to read per frame; 1920 for mono
byte[] buffer = new byte[blockSize];
byte[] gainBuffer = new byte[blockSize];
int byteCount;
while (true && !cancelVid) // Loop forever, so data will always be read
{
byteCount = mProcess.StandardOutput.BaseStream // Access the underlying MemoryStream from the stdout of FFmpeg
.Read(buffer, 0, blockSize); // Read stdout into the buffer
if (byteCount == 0) // FFmpeg did not output anything
break; // Break out of the while(true) loop, since there was nothing to read.
if (cancelVid)
break;
disAudioClient.Send(buffer, 0, byteCount); // Send our data to Discord
}
disAudioClient.Wait(); // Wait for the Voice Client to finish sending data, as ffMPEG may have already finished buffering out a song, and it is unsafe to return now.
isPlaying = false;
Console.Clear();
Console.WriteLine("Done Playing!");
を「私はいくつかの例を発見し、私はそれらを理解didntの。」あなたは何を理解していませんでしたか?コードをデバッグしようとしましたか? –
彼らはちょうど物を変換し、それらを全く説明しませんでした。 – McLucario
@cFrozenDeath投稿を無作為にdownvotingしていただきありがとうございます。今すぐこの質問に誰も答えません。 – McLucario