■ SignalGenerator 클래스를 사용해 WAV 파일을 생성하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System; using System.IO; using NAudio.Wave; using NAudio.Wave.SampleProviders; string targetDirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "NAudio"); Directory.CreateDirectory(targetDirectoryPath); string targetFilePath = Path.Combine(targetDirectoryPath, "test.wav"); SignalGenerator signalGenerator = new SignalGenerator(44100, 2) { Type = SignalGeneratorType.Sweep, Frequency = 500, FrequencyEnd = 3000, Gain = 0.2f, SweepLengthSecs = 20 }; WaveFileWriter.CreateWaveFile16(targetFilePath, signalGenerator.Take(TimeSpan.FromSeconds(20))); |