I have the following code:
mVisualizer = new Visualizer(0);
mVisualizer.setEnabled(false);
int capRate = Visualizer.getMaxCaptureRate();
int capSize = Visualizer.getCaptureSizeRange()[1];
mVisualizer.setCaptureSize(capSize);
Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener() {
public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes,
int samplingRate) {
for (int i=0;i<bytes.length;i++) {
if (bytes[i]!=-128) {
Log.w("Morphyre", "Found Nonzero sample "+bytes[i]);
break;
}
}
}
public void onFftDataCapture(Visualizer visualizer, byte[] bytes,
int samplingRate) {
}
};
int status = mVisualizer.setDataCaptureListener(captureListener,
capRate, true/*wave*/, false/*no fft needed*/);
mVisualizer.setEnabled(true);
The app has the 2 required permissions ( MODIFY_AUDIO_SETTINGS and RECORD_AUDIO )
According to the API docs, creating Visualizer(0) will use the 'Audio Output Mix' - however my code appears to initialise just fine (status==0), and the callbacks are called, but I never get data other than 128 (in the case of the wave callback) or 0 (in the case of the FFT) whenever I play with the default media player (on an HTC Sensation XE)
Am I doing something stupid here - or is it likely that my phone doesn't implement the Audio output Mix properly? If I use another audio player then it is fine.