1

我一直在尝试解决一个困扰了数周的问题!基本上,我正在开发的软件可以录制音频,然后播放。该软件可以录制多个声音文件,然后一个接一个地播放(使其看起来像是一个连续的声音文件)。但是,我遇到的问题是,从第二个声音文件开始,第二个、第三个、第四个(等等)文件的顶部似乎有一个“滴答作响”。

这个滴答声是第一个声音文件的最后几毫秒。我所指的“滴答声”类似于黑胶唱片快速跳跃的声音。

到目前为止,我还没有找到问题的根源,是否有人对可能导致此问题的原因有任何想法?

谢谢

编辑:在下面添加了一些方法。

好的,所以下面的方法是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
        }
    }
4

1 回答 1

1

我建议不要关闭和打开 WaveOut,而是始终打开一个 WaveOut 实例。创建一个新的 IWaveProvider,其 Read 方法首先返回第一个 WAV 文件中的所有数据,然后返回第二个 WAV 文件中的所有数据。

为了找到滴答声的来源,我会首先在 Windows Media Player 中仔细检查录制的 WAV 文件本身没有滴答声。

于 2011-04-14T06:28:44.547 回答