用c#中的dll记录5秒样本。 当我收听录音时,它听起来不是很响,所以当我录制样本时,我觉得有些不对劲。
该功能当前记录的时间为5秒。 我做错了什么?
谢谢!
//AUDIO RECORDING AND SAVING
private void startRecording(String location, float seconds)
{
silence = true;
//deviceNumber = NAudio.Wave.WaveIn.GetCapabilities(0);
deviceNumber = 0;
//setup audio stream in
sourceStream = new NAudio.Wave.WaveIn();
sourceStream.DeviceNumber = deviceNumber;
sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);
//NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream);
//save .wav file2
String wavLocation = appLocation + location + now.DayOfYear + @"_" + now.Year + @"_" + now.Hour + @"-" + now.Minute + @"-" + now.Second + @".wav";
sourceStream.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable);
waveWriter = new NAudio.Wave.WaveFileWriter(wavLocation, sourceStream.WaveFormat);
//record
sourceStream.StartRecording();
//set recording timer, end in 5s
myTimer.Interval = ((int)(seconds * 1000)) + 1000;
//when the timer ticks (at each interval), the function "stopRecording" is called.
//in stop recording, there is asynchronous code.
myTimer.Tick += new EventHandler(stopRecording);
myTimer.Start();
}