Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Synthesis of a basic wave , and change the frequency

$
0
0

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 { ... } privatevoid 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
} } privatevoid 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
  } privatevoid Rectangle_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e) { waveOut.Stop(); waveOut.Dispose(); waveOut = null;
// When you released, the sound stops } }

Viewing all articles
Browse latest Browse all 5831

Trending Articles