0

I am currently trying to implement a visualizer into my app that gets its data from the output mix.

My current code for initializing the visualizer up to the line of error:

private Visualizer audioOutput = null;

public void link(){
  AudioTrack visualizedTrack = null;
  final int minBufferSize = AudioTrack.getMinBufferSize(Visualizer.getMaxCaptureRate(), AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_8BIT);
  visualizedTrack = new AudioTrack(AudioManager.STREAM_MUSIC, Visualizer.getMaxCaptureRate(), AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_8BIT, minBufferSize, AudioTrack.MODE_STREAM);
  visualizedTrack.play();

  audioOutput = new Visualizer(0);

The error I get from that last line:

Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3

I'm running this code on an Nvidia Shield Tablet K1 if this information is of any use. I realize that the Visualizer method hasn't been the most well documented class and is known to cause trouble on some devices.

I know I'm getting error -3 due to some kind of bad parameter value but isn't 0 an acceptable one for getting the output mix?

I have the proper permissions RECORD_AUDIO and MODIFY_AUDIO_SETTINGS in my manifest:

 <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>

What am I missing here? I've been stuck on this for a while and would completely appreciate any help from anyone out there.

Umbreon
  • 1
  • 3

1 Answers1

0

It seems like there's some framework issue, but either way restart your device after pushing a build with those permissions. It should work!

Chris Rohit Brendan
  • 893
  • 1
  • 9
  • 20