3

I want to analyse the recorded microphone-sound of my Android application.

Unfortunately the Visualizer is only able to work on an AudioTrack that is currently being played back. Currently I'm recording with AudioRecord and copy the data into an AudioTrack where the visualizer is listening on. But this architecture causes a terrible playback-record-loop.

One workaround was to turn the volume of the AudioTrack down to the lowest possible level while recording, but this doesn't sound like a good solution at all.

Is there any alternative to the Visualizer class that provides means to capture FFT-data from the recorded track?

Alexander Pacha
  • 7,455
  • 3
  • 56
  • 87
  • Out of curiosity what happens if you pass the audio session id of the `AudioRecord` object to the `Visualizer`? `Visualiser mVisualizer = new Visualizer(mAudioRecord.getAudioSessionId());` – Brett Duncavage Apr 10 '13 at 01:16
  • `AudioRecord` unfortunately does not provide a method like `getAudioSessionId()`. Another problem with my temporary workaround is, that lowering the volume of the device, will also mute the audioTrack which means that no analysis is going on anymore. – Alexander Pacha Apr 12 '13 at 01:52
  • According to the docs (http://developer.android.com/reference/android/media/AudioRecord.html#getAudioSessionId()) it does have `getAudioSessionId()` granted it's only available in API level 16 and higher. – Brett Duncavage Apr 12 '13 at 03:37
  • 1
    `RuntimeException`: Cannot initialize Visualizer engine, error -4 – Alexander Pacha Apr 12 '13 at 03:43
  • Heh, OK. Well at least we know that doesn't work. – Brett Duncavage Apr 12 '13 at 03:44
  • Hey @Alexander, could you post a full working example somewhere please? – Rocel Jun 23 '14 at 22:44
  • Possible duplicate of [Android audio FFT to retrieve specific frequency magnitude using audiorecord](https://stackoverflow.com/questions/5774104/android-audio-fft-to-retrieve-specific-frequency-magnitude-using-audiorecord) – Eric Aya May 31 '17 at 09:30

2 Answers2

0

additional. it says

AudioFlinger createEffect_l() effect Visualizer (flags 00000008) created on wrong thread type 3 AudioEffect set(): AudioFlinger could not create effect, status: -22

after searching "created on wrong thread type" it found that there's something wrong with Visualizing input signal. I struggled so far but was fruitless.

minimanimo
  • 177
  • 3
  • 11
0

I solved it now, by analyzing the data directly from the AudioRecord as described in Android audio FFT to retrieve specific frequency magnitude using audiorecord.

Alexander Pacha
  • 7,455
  • 3
  • 56
  • 87