■ SmbPitchShiftingSampleProvider 클래스의 PitchFactor 속성을 사용해 피치를 변조하는 방법을 보여준다.
▶ 예제 코드 (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 25 26 27 28 29 30 31 |
using System; using System.Threading; using NAudio.Wave; using NAudio.Wave.SampleProviders; string sourceAudioFilePath = @"D:\source.mp3"; double semitone = Math.Pow(2, 1.0 / 12); double upOneTone = semitone * semitone; double downOneTone = 1.0 / upOneTone; using(MediaFoundationReader reader = new MediaFoundationReader(sourceAudioFilePath)) { SmbPitchShiftingSampleProvider provider = new SmbPitchShiftingSampleProvider(reader.ToSampleProvider()); provider.PitchFactor = (float)upOneTone; using(WaveOutEvent waveOutEvent = new WaveOutEvent()) { waveOutEvent.Init(provider.Take(TimeSpan.FromSeconds(10))); waveOutEvent.Play(); while(waveOutEvent.PlaybackState == PlaybackState.Playing) { Thread.Sleep(500); } } } |