简体   繁体   中英

Square Wave not generating properly usin NAudio

I am using NAudio to play a Square wave. When i record that sound in audacity and check the waveform.

It is not coming properly.

Waveform of NAudio generated sound NAudio生成声音的波形

Waveform of Audacity generated sound Audacity 生成声音的波形

Am i doing some thing Wrong ?

Code

sine20Seconds = new SignalGenerator()
{
    Gain = 0.5,
    Frequency = Convert.ToDouble(freqBox1.Text)                    
};
sine20Seconds.Type = SignalGeneratorType.Square;
wo = new WaveOutEvent();
wo.Init(sine20Seconds);
wo.Play();

Try changing

sine20Seconds.Type = SignalGeneratorType.Triangle;

to

sine20Seconds.Type = SignalGeneratorType.Square;

as per instructions here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM