0

I'm trying to convert a wav file from 48000 hz to 16000 hz.

I have all of the samples of the 48khz wav file inside of a float[] and I'm looking for a formula to turn these samples into a 16000 hz wav file.

I have searched google for that and every link i found was related to NAudio or other Libraries. I want to do that in plain C# as I'm doing this in unity. (Btw i also have access to the unity classes, like AudioClip if that helps)

any help would be greatly apapreciated

  • The issue will be to do it without introducing artifacts. I tried that once but I never got a good result.. – TaW Mar 08 '21 at 14:36
  • @TaW can you please elaborate on that a bit more, because i didn't quite understand it – Amirreza Moeini Yegane Mar 08 '21 at 14:42
  • 1
    Since you are reducing frequency be exactly 3, the dumb approach will be to simply use every third value. Refer to [resampling](https://en.wikipedia.org/wiki/Sample-rate_conversion) for other factors. – Sinatr Mar 08 '21 at 14:44
  • 1
    Well, I tried the 'dumb' approach, ie leaving out a 1/3 of the samples and the result had a terrible, loud noise. I should hve calculated the samples instead to distribute all changes/errors. I don't think I finished it at the time.. - (But that was a long time ago; maybe I had to got from 48->44.2 kHz ??) – TaW Mar 08 '21 at 14:46
  • See [downsampling](https://en.wikipedia.org/wiki/Downsampling_(signal_processing)), *"requires a lowpass filter before decimation"*. – Sinatr Mar 08 '21 at 14:51

0 Answers0