-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recording on WasapiCapture,a lot of noise. #473
Comments
|
Me too. The recorded audio lasted a long time, but I didn't record it that long and it was all noise
|
You are not supposed to define a wavformat yourself.
The WaveWriter will not convert the input to any desired output format. It will just write the raw data and place the necessary headers in order to write a valid .wav file.
Pass the capture.WaveFormat to the WaveWriter and it will be good or make sure to convert the captured data to the output format.
If the format is correct, the sound won’t be noisy and will also match in length.
Von: eugeneYz ***@***.***>
Gesendet: Mittwoch, 6. März 2024 03:25
An: filoe/cscore ***@***.***>
Cc: Subscribed ***@***.***>
Betreff: Re: [filoe/cscore] Recording on WasapiCapture,a lot of noise. (Issue #473)
Me too. The recorded audio lasted a long time, but I didn't record it that long and it was all noise
private WasapiCapture capture;
private WaveWriter writer;
public void StartRecording(string fileName)
{
capture = new WasapiCapture();
capture.Initialize();
// 设置录音格式
var waveFormat = new WaveFormat(16000, 16, 1); // 16000Hz, 16bit, Mono
writer = new WaveWriter(fileName, waveFormat);
capture.DataAvailable += (s, e) =>
{
// 将捕获的音频数据写入文件
writer.Write(e.Data, e.Offset, e.ByteCount);
};
capture.Start();
}
public void StopRecording()
{
capture.Stop();
capture.Dispose();
writer.Dispose();
}
—
Reply to this email directly, view it on GitHub <#473 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABHXVYMXGYS6VTMMA4PVCDTYWZ463AVCNFSM57GWIFV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXHE4TMMRRHAYA> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/ABHXVYPTKQBMZXXBCSQEO3LYWZ463A5CNFSM57GWIFV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOOYB5GRA.gif> Message ID: ***@***.*** ***@***.***> >
|
I have to define a Waveformat myself because the API that receives the audio specifies this format.Are there any other solutions?
赵铮
***@***.***
…------------------ 原始邮件 ------------------
发件人: "filoe/cscore" ***@***.***>;
发送时间: 2024年3月6日(星期三) 下午3:02
***@***.***>;
***@***.******@***.***>;
主题: Re: [filoe/cscore] Recording on WasapiCapture,a lot of noise. (Issue #473)
You are not supposed to define a wavformat yourself.
The WaveWriter will not convert the input to any desired output format. It will just write the raw data and place the necessary headers in order to write a valid .wav file.
Pass the capture.WaveFormat to the WaveWriter and it will be good or make sure to convert the captured data to the output format.
If the format is correct, the sound won’t be noisy and will also match in length.
Von: eugeneYz ***@***.***>
Gesendet: Mittwoch, 6. März 2024 03:25
An: filoe/cscore ***@***.***>
Cc: Subscribed ***@***.***>
Betreff: Re: [filoe/cscore] Recording on WasapiCapture,a lot of noise. (Issue #473)
Me too. The recorded audio lasted a long time, but I didn't record it that long and it was all noise
private WasapiCapture capture;
private WaveWriter writer;
public void StartRecording(string fileName)
{
capture = new WasapiCapture();
capture.Initialize();
// 设置录音格式
var waveFormat = new WaveFormat(16000, 16, 1); // 16000Hz, 16bit, Mono
writer = new WaveWriter(fileName, waveFormat);
capture.DataAvailable += (s, e) =>
{
// 将捕获的音频数据写入文件
writer.Write(e.Data, e.Offset, e.ByteCount);
};
capture.Start();
}
public void StopRecording()
{
capture.Stop();
capture.Dispose();
writer.Dispose();
}
—
Reply to this email directly, view it on GitHub <#473 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABHXVYMXGYS6VTMMA4PVCDTYWZ463AVCNFSM57GWIFV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXHE4TMMRRHAYA> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/ABHXVYPTKQBMZXXBCSQEO3LYWZ463A5CNFSM57GWIFV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOOYB5GRA.gif> Message ID: ***@***.*** ***@***.***> >
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I`m recording on WasapiCapture , sampleRate:16000, bits:16 and channels:1. There is a lot of noise when the sound is high. Is there a good solution?
The text was updated successfully, but these errors were encountered: