我一直在尝试解决一个困扰了数周的问题!基本上,我正在开发的软件可以录制音频,然后播放。该软件可以录制多个声音文件,然后一个接一个地播放(使其看起来像是一个连续的声音文件)。但是,我遇到的问题是,从第二个声音文件开始,第二个、第三个、第四个(等等)文件的顶部似乎有一个“滴答作响”。
这个滴答声是第一个声音文件的最后几毫秒。我所指的“滴答声”类似于黑胶唱片快速跳跃的声音。
到目前为止,我还没有找到问题的根源,是否有人对可能导致此问题的原因有任何想法?
谢谢
编辑:在下面添加了一些方法。
好的,所以下面的方法是replay方法。
public override void Replay(long time)
{
if(this.StartTime <= time && this.EndTime >= time && (Speed >= 0.95 && Speed <= 1.05))
{
if (!locked)
{
locked = true;
//close the previous stream
CloseWaveOut();
//open the file
waveOut = new NativeDirectSoundOut(latency);
mainOutputStream = CreateInputStream(outputFilename);
if (waveOut != null && mainOutputStream != null)
{
//set the time position
long offset = time - StartTime;
if (offset > 0)
{
mainOutputStream.CurrentTime = TimeSpan.FromMilliseconds(Convert.ToDouble(offset));
}
//CurrentTime = TimeSpan.FromMilliseconds(Convert.ToDouble(time - StartTime));
waveOut.Init(mainOutputStream);
((WaveChannel32)mainOutputStream).Volume = Volume;
Console.WriteLine("waveOut Playing"); // Debugging purposes
waveOut.Play();
}
}
}
}
下面的方法是记录方法:
public override void Record(long time)
{
if (waveInStream == null && writer == null && !recorded)
{
//for record
writer = new WaveFileWriter(outputFilename, recordingFormat);
waveInStream = new WaveInStream(deviceNumber, recordingFormat, null);
waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();
this.StartTime = time;
Console.Out.WriteLine("Record Method called"); // Debugging Purposes
}
}