I have a recording app and want to use this as visualizer, but when receiving audio and setting into it, i am not able to find the proper blast form or any thing nicer in that..
![image](https://user-images.githubusercontent.com/24537492/51698235-b1cc0380-202f-11e9-921e-6a133b1534c6.png)
public int RECORDER_SAMPLERATE = 44100;
private final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_MONO;
private final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
BufferElements2Rec = AudioRecord.getMinBufferSize(RECORDER_SAMPLERATE,
RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING);
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
RECORDER_SAMPLERATE, RECORDER_CHANNELS,
RECORDER_AUDIO_ENCODING, BufferElements2Rec * 2);
Thread recordingThread = new Thread("recorder") {
@Override
public void run() {
super.run();
if (Looper.myLooper() == null) {
Looper.prepare();
}
audioRecord.setRecordPositionUpdateListener(recordPositionUpdateListener, new Handler(Looper.myLooper()));
audioRecord.setPositionNotificationPeriod((int) BufferElements2Rec);
//We need to read first chunk to motivate recordPositionUpdateListener.
//Mostly, for lower versions - https://code.google.com/p/android/issues/detail?id=53996
bufferReadResult = audioRecord.read(buffer, 0, BufferElements2Rec);
Looper.loop();
}
};
audioRecord.startRecording();
recordingThread.start();
private AudioRecord.OnRecordPositionUpdateListener recordPositionUpdateListener = new AudioRecord.OnRecordPositionUpdateListener() {
@Override
public void onMarkerReached(AudioRecord recorder) {
//empty for now
}
@Override
public void onPeriodicNotification(AudioRecord recorder) {
if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING
&& audioRecord.read(buffer, 0, buffer.length) != -1) {
// mHorizon.updateView(buffer);
byte[] data = new byte[buffer.length];
for (int j = 0; j < buffer.length; j++) {
byte tmp = (byte) (buffer[j]);
data[j] = tmp;
}
mVisualizer.setRawAudioBytes(data);
}
}
};
Help is really appreciate asap.
Already spent almost two for combo..
![screenshot_10](https://user-images.githubusercontent.com/24537492/51698343-eb9d0a00-202f-11e9-9efa-e5404547f185.png)