Domanda

I working on an android app which records audio. For best audio quality it is better to use a buffer of shorts while reading?

//aRecorder.read(shortBuffer, 0, shortBuffer.length);
aRecorder.read(byteBuffer, 0, byteBuffer.length);

Using short[] isn't the same as using byte[] and considering a sample from 2 bytes(byteBuf[i] and byteBuf[i+1])? If I use short[], I must convert it anyway to ByteBuffer to write it on a file.

I'm asking this because I want to know if I switch to buffer of shorts, my recordings will be more accurate? For example, shortBuffer[0] contains the same information as byteBuffer[0] and byteBuffer[1] ?

The recordings could be in 16 bits PCM or 8 bits PCM (User can choose the sample rate, nr of channels, PCM 16 or 8, etc)

I must mention that the output file will be in WAV format.

È stato utile?

Soluzione

There is no difference between using a Short or Byte buffer, it is just two representations of the same underlying data.

The only difference I can think of is that you are limiting your options on how to access the data during recording, since in short your minimum data representation would be 16 bit (short size) but then again you can just xAnd any part of the short object to get one of its bytes.

if you are doing a real time audio processing of any kind you better use byte to easy data minipulation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top