0

在 NAudio 中使用 signalGenerator 时,我尝试更改 sampleRate。但是是只读的,有理由吗?
我可以毫不费力地覆盖它吗?

public void MaakGeluid(int sampleRate) {
        waveOut = new WaveOut();
        waveOut.DesiredLatency = 100;
        sg = new SignalGenerator();
        sg.Frequency = Frequency;
        sg.WaveFormat.SampleRate = sampleRate;
        sg.Type = Sgt;
        waveOut.Init(sg);
    }
4

1 回答 1

1

不可以,您必须在 SignalGenerator 构造函数中指定采样率。ISampleProvider 不能简单地即时更改其采样率,因为您的 WaveOut 将期待该采样率的数据。

您可以在播放时更改信号发生器的频率。

于 2013-11-29T18:49:16.960 回答