You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for your hard work making this excellent library. According to the AudioRecord documentation, reading byte[]s from a buffer is only compatible with ENCODING_PCM_8BIT.
Reads audio data from the audio hardware for recording into a byte array. The format specified in the AudioRecord constructor should be ENCODING_PCM_8BIT to correspond to the data in the array.
I see that in your example you are indeed using reading a byte[] from the AudioRecord buffer, yet you're also specifying ENCODING_PCM_8BIT. Is there any way to use Horizon with a short[], or should we continue to use byte[] and specify ENCODING_PCM_8BIT?
The text was updated successfully, but these errors were encountered:
I am using short [] and with some modification and it is working Hope its help:-
public void onAudioChunkPulled(AudioChunk audioChunk, short[] buffer) {
if ( audioChunk.readCount() > 0) {
byte bys[] = new byte[audioChunk.readCount() * 2];
// Because arm byte order problem, so need high and low bit exchange
for (int i = 0; i < audioChunk.readCount(); i++) {
byte ss[] = getBytes(buffer[i]);
bys[i * 2] = ss[0];
bys[i * 2 + 1] = ss[1];
}
mHorizon.updateView(bys);
}
}
public byte[] getBytes(short s) {
byte[] buf = new byte[2];
for (int i = 0; i < buf.length; i++) {
buf[i] = (byte) (s & 0x00ff);
s >>= 8;
}
return buf;
}
Thank you for your hard work making this excellent library. According to the
AudioRecord
documentation, readingbyte[]
s from a buffer is only compatible with ENCODING_PCM_8BIT.https://developer.android.com/reference/android/media/AudioRecord.html#read(byte[], int, int)
I see that in your example you are indeed using reading a
byte[]
from theAudioRecord
buffer, yet you're also specifyingENCODING_PCM_8BIT
. Is there any way to use Horizon with ashort[]
, or should we continue to usebyte[]
and specifyENCODING_PCM_8BIT
?The text was updated successfully, but these errors were encountered: