gauravk95 / gauravk95/audio-visualizer-android

How to use this library with live recording

Open
#21 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
895
Forks
142
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am working on an Audio recording function. I want the recorded Audio to be saved into the internal cache directory of my app so that I can later process it and send it to my server. I have taken the `RECORD_AUDIO_PERMISSION` in my Android Manifest.

Below is the code I am using for recording audio and save it to a file.

```
String uuid = UUID.randomUUID().toString();
fileName = getExternalCacheDir().getAbsolutePath() + "/" + uuid + ".3gp";

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setOutputFile(fileName);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

try {
recorder.prepare();
recorder.start();
} catch (IOException e) {}
```

The above code to work fine but I am facing another issue. I want to create a Waveform effect for my app for which I am using this library. I know the below code can be used to pass on bytes to the visualizer.

```
//get reference to visualizer
mVisualizer = findViewById(R.id.blast);

//TODO: get the raw audio bytes

//pass the bytes to visualizer
mVisualizer.setRawAudioBytes(bytes);
```

Now, my question is how can I get the Bytes in real-time of the Audio which is being recorded and being saved? Should I read the file and extract recent bytes from it at regular intervals or is there any other method to achieve this?

Any help would be appreciated

Thanks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.