コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: juyingnan/VS
 private void SoundPlay(WaveOut waveOut, BinauralBeatsWaveOscillator wave, Polyline line, int leftFrequency, int rightFrequency, short amplitude)
 {
     double volumeGainFactor = 0.01;
     waveOut.Volume = (float)(amplitudeSlider.Value * volumeGainFactor);
     wave.LeftFrequency = leftFrequency;
     wave.RightFrequency = rightFrequency;
     wave.Amplitude = amplitude;
     waveOut.Play();
     waveGraphDrawing(line, wave, waveOut);
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: juyingnan/VS
 private void waveGraphDrawing(Polyline line, BinauralBeatsWaveOscillator wave, WaveOut waveOut)
 {
     line.Points.Clear();
     double halfCanvasActualHeight = waveGraphCanvas.ActualHeight / 2;
     double minusHalfCanvasActualHeight = halfCanvasActualHeight * (-1);
     for (int i = 0; i < waveGraphCanvas.ActualWidth; i++)
     {
         line.Points.Add(new Point(i, (double)wave.drawBuffer[2*i] / (double)wave.Amplitude * minusHalfCanvasActualHeight * waveOut.Volume + halfCanvasActualHeight));
     }
     waveTip.Text = string.Format("Current Wave: {0}\t Frequency: {1}\t Amplitude: {2}\t", wave.currentType, wave.LeftFrequency, (int)(wave.Amplitude * waveOut.Volume));
 }