Resample / upsample sound frames from 8 to 48 kHz (Java / Android)

The application I'm trying to create for andriod records frames at 48 kHz (PCM 16bits and mono) and sends them to the network. In addition, there is an incoming audio stream at a frequency of 8 kHz. So, I get 8Khz sampled frames and play them back (my AudioTrack object is set to 8Khz), but when I play them back everything works, but the latency is HUGE. It takes about 3 seconds until you hear nothing.

I think that if I can increase the received frames from 8 to 48 kHz and play them, there will not be such a huge latency of playback. In fact, when I record and play frames at the same speed, the latency is really low. The bad news is that I have to do it this way: send to 48 kHz and get 8 kHz.

As explained earlier, I am trying to increase the sound level (16 bit PCM) from 8 to 48 kHz. Does anyone know any java routine / library / API that does this?

I know the basics of upsampling a discrete signal, but I believe that there is too much to develop and implement my own FIR filter and convolution using the audio stream .... In addition, this is all my knowledge.

So ... can anyone help me? Does anyone know of any Java library / procedure that I can use? Any suggestions or alternatives

+5
source share
3 answers

. , :

(C- , , , ).

void resample (short * output, short * input, int n)
{
  // output ought to be 6 times as large as input (48000/8000).

  int i;
  for (i=0; i<n-1; i++)
  {
    output[i*6+0] = input[i]*6/6 + input[i+1]*0/6;
    output[i*6+1] = input[i]*5/6 + input[i+1]*1/6;
    output[i*6+2] = input[i]*4/6 + input[i+1]*2/6;
    output[i*6+3] = input[i]*3/6 + input[i+1]*3/6;
    output[i*6+4] = input[i]*2/6 + input[i+1]*4/6;
    output[i*6+5] = input[i]*1/6 + input[i+1]*5/6;
  }

, . , , .

, c c libresample Android-NDK java JNI. . JNI - , , . NDK .

http://www.mega-nerd.com/SRC/index.html

+6

(https://github.com/hutm/JSSRC, https://github.com/simingweng/android-pcm-resample, https://github.com/ashqal/android-libresample). , 48000 44100 ( , ).

: https://github.com/JorenSix/TarsosDSP

This is a large pure Java library that runs on Android (no javax.sound dependencies) and is capable of many things, but if you just take the FilterKit, Resampler, and SampelBuffers classes in the be.tarsos.dsp.resample package, it works very well and easy to use.

0
source

All Articles