2

I am reading audio samples from bluetooth headset in my android application. The bluetooth SCO works at 8KHz sampling frequency for Audio IN. But i need 16KHz audio samples from bluetooth headset, So i need to use upsampling.

I searched here and also in other websites regarding upsampling in Android, but no use. If anybody knows about predefined Java libraries for upsampling pleases answer to my question.

Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
  • related: http://stackoverflow.com/questions/3260424/resample-upsample-sound-frames-from-8khz-to-48khz-java-android – Prof. Falken Oct 05 '12 at 07:27
  • IDK if you can use this API in android, but javasound lets you do this, and here are some nice samples: http://www.jsresources.org/examples/AudioConverter.html – Bjorn Roche Oct 06 '12 at 02:41

2 Answers2

1

The upsampling should happen automatically if you request 16 kHz unless the device you're testing on has some strange implemetation of the audio HAL / audioflinger.

What will (should) happen if you request a sample rate that isn't supported by the input device is that the audio HAL will return an error code up to the audioflinger and suggest a sample rate to use. The audioflinger in turn will make an attempt to open an input stream with the supported sample rate and do resampling internally so that the application gets audio data at the rate it requested.

This should work as long as the requested sample rate is not greater than double the supported sample rate, so 8 -> 16 kHz upsampling should work. Whether the quality of this upsampling is good enough is something you'll have to judge yourself.

Michael
  • 57,169
  • 9
  • 80
  • 125
-1

The easiest is to just copy each value and double the frequency. This will not improve sound quality but not make it worse either. This is similar to how you can upscale an image to higher resolution. Without filtering, it will not look worse, but not better either, as long as you upscale with a non-fractional amount.

Can you tell the difference between this image;

enter image description here

and this?

The second image is actually twice the resolution, but looks the same.

As long as you scale a sound (or an image) with a non fractional number, no scaling artifacts are introduced.

However, various hints if you want to smoothen the up-sampled sound:

https://ccrma.stanford.edu/~jos/resample/

http://paulbourke.net/miscellaneous/interpolation/

http://leute.server.de/wilde/resample.html#Upsampling

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • I need best upsampling, because i am using this data for voice recognition. If I do as you told the recognition will be poor. – Yugandhar Babu Oct 05 '12 at 07:19
  • @YugandharBabu, it will be exactly as good or bad as the original 8kHz sound. – Prof. Falken Oct 05 '12 at 07:22
  • http://paulbourke.net/miscellaneous/interpolation/ <--- various math to interpolate – Prof. Falken Oct 05 '12 at 07:24
  • 1
    It will most definitely NOT be "as good or bad as the original." Duplicating samples will introduce aliasing artefacts. However, upsampling will add no new information and for the sake of VR you are best off if you can use the original data. – Bjorn Roche Oct 06 '12 at 02:40
  • 1
    There is no way doubling samples will introduce any artifacts @BjornRoche. Is is completely analogous to how upscaling an image to 640x480 from 320x240 will not make the image look better nor worse. It will look exactly the same. – Prof. Falken Oct 06 '12 at 06:41