Java - downsampling wav audio file

后端 未结 1 506
温柔的废话
温柔的废话 2021-01-12 19:45

Hi I need to downsample a wav audio file\'s sample rate from 44.1kHz to 8kHz. I have to do all the work manually with a byte array...it\'s for academic purposes.

I

1条回答
  •  有刺的猬
    2021-01-12 19:58

    I think you shouldn't use the average of those samples as that would be a median filter, not exactly downsampling. Just use every 5th/6th/7th sample and write that to the new file.

    That will probably have some aliasing artifacts but might overall be recognizable.

    Another, more complex solution but probably one with better results, quality-wise, would be to first convert your samples into a frequency distribution using a FFT or DFT and then convert it back with the appropriate sample rate. It's been a while since I have done such a thing but it's definitely doable. You may need to fiddle around a bit to get it working properly, though.

    Also when not taking a FT of the complete array but rather in segments you have the problem of the segment boundaries being 0. A few years ago when I played with those things I didn't come up with a viable solution to this (since it generates artifacts as well) but there probably is one if you read the right books :-)

    As for WMP complaining about the file: You did modify the header you write accordingly, right?

    0 讨论(0)
提交回复
热议问题