Fadi
Fadi

Reputation: 2370

how to change frequency ( pitch) and the amplitude in wave file using c#

how to change frequency (pitch) and the amplitude in wave file using c# like this but on wave file not tone http://www.youtube.com/watch?v=Tumpkl-xJuA

Upvotes: 3

Views: 7143

Answers (1)

dodgy_coder
dodgy_coder

Reputation: 13033

This answer here provides all you need to read a wave (.wav) audio file into a c# array. It normalises the values from -1.0 to 1.0.

So all you need to do is

  • Use the above code to read the file into a c# double array. It actually returns two arrays, one for the left and right stereo channels. Just uses one if its mono though.
  • Make the modifications to the c# array in memory:
    • Changing pitch means resampling the array at a lower or higher sample rate, in effect stretching or shrinking the waveform to adjust the frequency. You may need to use some form of interpolation at this point.
    • Amplitude adjustment can be done at the next step.
  • Write out the array into a new Wave file; refer to https://web.archive.org/web/20141213140451/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ for full Wave format specification ... its not that complex.

Upvotes: 1

Related Questions