This project has moved and is read-only. For the latest updates, please go here.

Synthesis of a basic wave , and change the frequency

Nov 12, 2012 at 12:27 PM
Edited Nov 12, 2012 at 12:30 PM

Hello everyone ,

I'm a beginner with NAudio and I want to create a basic sinus wave and modify its frequency with the move of the mouse . I followed this tutorial .And in my MainWindow , I've just added

And my sinus wave changed its frequency but the changes are not fluid , anyone has some ideas how that can be more fluid ?


double GetFrequency(Rectangle sender, MouseEventArgs e)
// This function is just to convert the position of the mouse to a frequency { ... } private void Rectangle_MouseMove_2(object sender, MouseEventArgs e) { if(Mouse.LeftButton == MouseButtonState.Pressed) { sineWaveProvider.Frequency = (float)GetFrequency((Rectangle)sender, e);
// Here I change the frequency while playing
} } private void Rectangle_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e) { sineWaveProvider.Frequency = (float)GetFrequency((Rectangle)sender, e); sineWaveProvider.Amplitude = 0.25f; waveOut = new WaveOut(); waveOut.Init(sineWaveProvider); waveOut.Play();
// When you click , the sound starts playing
  } private void Rectangle_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e) { waveOut.Stop(); waveOut.Dispose(); waveOut = null;
// When you released, the sound stops } }
Nov 12, 2012 at 12:54 PM

for smooth frequency changes you need to implement a portamento algorithm. One way to do this is with a wavetable, where you slowly change the offset intot the wavetable you are operating with. It's a tricky algorithm if you are a beginner to DSP, but hopefully that points you in the right direction.

Nov 12, 2012 at 3:58 PM

I've found this that's totally solved my problem -->