felixpalmer / android-visualizer Goto Github PK
View Code? Open in Web Editor NEWTakes the input from the Android MediaPlayer and displays visualizations, like in iTunes or WinAmp
Takes the input from the Android MediaPlayer and displays visualizations, like in iTunes or WinAmp
i know it will change the height of the bars by sound inc but i want change little bit height how i can i change
I have released my music visualizer app "Astral 3d worlds", which is inspired by your open source project. I can send you the paid version for free if you want to see how it looks like. This is not an issue and you can close it anytime. I didn't find your mail, so that is why I contacted you this way.
Your project is mentioned in the product page on Google play:
headline says all.
Cheers!
Rainer
This error log:
04-20 18:38:53.406 9750 21279 E : Request requires android.permission.MODIFY_AUDIO_SETTINGS
04-20 18:38:53.406 24553 24553 E AudioEffect: set(): AudioFlinger could not create effect, status: -1
04-20 18:38:53.406 24553 24553 E visualizers-JNI: Visualizer initCheck failed -3
04-20 18:38:53.406 24553 24553 E Visualizer-JAVA: Error code -3 when initializing Visualizer.
04-20 18:38:53.407 24553 24553 D AndroidRuntime: Shutting down VM
04-20 18:38:53.409 24553 24553 E AndroidRuntime: FATAL EXCEPTION: main
04-20 18:38:53.409 24553 24553 E AndroidRuntime: Process: de.appwerft.hoerdat, PID: 24553
04-20 18:38:53.409 24553 24553 E AndroidRuntime: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3
This permission is in manifest: android.permission.MODIFY_AUDIO_SETTINGS
I has app, I want to use visualizer, But mediaplayer in service,
I can't link it with visualize on activity?
Please help me.
THanks pro.
Hi Felix,
as reported you lib runs now as Titanium module.
Problem: on NEXU5 and NEXUS6P it only works if the audio signal goes to bluetooth or headphone. If I use the loudspeaker, then I see flatline. I'm using audioSessioID 0.
Edit: if I plugg in the headset in NEXUS5 then it works, if I now plugg out the visualisation keeps, on NEXUS6P after outplugging the visualtion disappears
Cheers!
How recreate visualizer after rotate screen???
Now, after rotate screen his no show.
A visualizer can have an internal music player, which means that the app has its own built in player. It can also use the music from external music players( Winamp for instance). Visualization for external players does not work on the new Galaxy devices.
I have played music with external players, while debugging the visualizer apps. The bytes in the updateVisualizerFFT method are always 0 for external players, when a visualizer is created with 0 as an argument.
This results in no visualization, since there is no signal to use for visualization.
It still works for internal players. The bytes in the updateVisualizerFFT are not 0 then, so the app has something to use for visualization, even when the visualizer is created with 0 as an argument.
This is caused by an Android code bug in the Digital Signal Processors, which are included in the new Galaxy and some HTC devices.
Several visualizer apps have this warning message:
"NOTE: To Galaxy S/S2/S3/S4, Galaxy Note 1/2, Galaxy Nexus and HTC Rezound owners: The visualizer will sporadically show a flatline with many music players, due to an Android bug related to the built-in DSP in these phones. This is a problem for all music visualizer apps on these phones, as evidenced by user reviews of other apps. Still looking for a work-around, but we'll probably have to wait for a future version of Android to fix it. If you have this problem, I apologize! Please email me and I will refund you."
Almost all visualizer apps on the market have this problem and can’t visualize from external players on the new Galaxy and some HTC devices.
It seems like it is possible to solve this problem, because external visualization works on the Morphyre Music Visualizer. It is right now the only visualizer on the market, where this works.
Hi, I am using red colors for the bars. I want the bars to fade really fast. If I use below code its not fading faster.
mFadePaint.setColor(Color.argb(238, 255, 255, 255));
However, if I replace above code with below code to make it fade faster, the output is, it does fades faster but the color is not red anymore its red with too much alpha.
mFadePaint.setColor(Color.argb(100, 255, 255, 255));
I want the bars to fade really fast while maintaining their original color i.e. red. How can I do it?
Can we use this visualizer while recording with MediaRecorder.
this is kindaa crazy to customize
one more thing using ogg instead of mp3 can bypass the 1min error cool isn't ?
Thanks for your work with the Visualizer class, especially the decoding of the FFT frame.
Your app synchronizes animation with the sound sampling rate with (invalidate).
* Pass FFT data to the visualizer. Typically this will be obtained from the
* Android Visualizer.OnDataCaptureListener call back. See
* {@link Visualizer.OnDataCaptureListener#onFftDataCapture }
* @param bytes
*/
public void updateVisualizerFFT(byte[] bytes) {
mFFTBytes = bytes;
invalidate();
}
The problem with this is that Visualizer's sound sampling mechanism is clunky. I have only seen a maximum sound buffer sampling rate of about 50ms which is crippling your graphics frame rate to about (20 fps) because of the synchronization with (invalidate).
The solution is to abandon Visualizer's data capture listener and set up a simple capture handler than runs at a nice smooth 60 fps.
Using a thread safe stack to store the capture frames will asynchronize the audio capturing and graphics rendering threads. Mirror smooth animation will result. Your graphics thread can feed on the stack asynchronously.
Your graphics are pretty basic and should be able to keep up, with room for even more fancy stuff.
It should result in peformance like this WebGL visualizer (which passes FFT data to the GPU as a texture!)
https://www.shadertoy.com/view/Xds3Rr
I was able to significantly reduce CPU overhead in my app by ripping out AudioData and passing a byte[] directly to the renderer. On an N7, CPU went from a steady 40% to 30%, which includes some complex audio processing that app does. Creating all of those objects in a tight loop is going to impose significant costs because of the work to instantiate the object and to garbage collect it.
If the goal of overloading render() is to have different method signatures for time-domain vs. frequency domain signals, just change the names of the methods to renderWaveform() and renderFFT().
I downloaded the code for "android-visualizer" and I tried to get it to work, but I got the error that I pasted below. What should I to get this to work?
My company is working on an Android visualizer with OpenGL 3d effects and we would like to reuse the code from "android-visualizer" if possible.
01-02 10:06:41.282: D/dalvikvm(5376): Late-enabling CheckJNI
01-02 10:06:41.306: I/dalvikvm(5376): Turning on JNI app bug workarounds for target SDK version 9...
01-02 10:06:41.813: E/MediaPlayer(5376): Unable to to create media player
01-02 10:06:41.915: D/MediaPlayer(5376): create failed:
01-02 10:06:41.915: D/MediaPlayer(5376): java.io.IOException: setDataSourceFD failed.: status=0x80000000
01-02 10:06:41.915: D/MediaPlayer(5376): at android.media.MediaPlayer.setDataSource(Native Method)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.media.MediaPlayer.create(MediaPlayer.java:740)
01-02 10:06:41.915: D/MediaPlayer(5376): at com.pheelicks.app.MainActivity.init(MainActivity.java:59)
01-02 10:06:41.915: D/MediaPlayer(5376): at com.pheelicks.app.MainActivity.onResume(MainActivity.java:39)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.Activity.performResume(Activity.java:4539)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2000)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread.access$600(ActivityThread.java:128)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.os.Looper.loop(Looper.java:137)
01-02 10:06:41.915: D/MediaPlayer(5376): at android.app.ActivityThread.main(ActivityThread.java:4514)
01-02 10:06:41.915: D/MediaPlayer(5376): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 10:06:41.915: D/MediaPlayer(5376): at java.lang.reflect.Method.invoke(Method.java:511)
01-02 10:06:41.915: D/MediaPlayer(5376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-02 10:06:41.915: D/MediaPlayer(5376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-02 10:06:41.915: D/MediaPlayer(5376): at dalvik.system.NativeStart.main(Native Method)
01-02 10:06:41.915: D/AndroidRuntime(5376): Shutting down VM
01-02 10:06:41.915: W/dalvikvm(5376): threadid=1: thread exiting with uncaught exception (group=0x40bcf1f8)
01-02 10:06:41.915: E/AndroidRuntime(5376): FATAL EXCEPTION: main
01-02 10:06:41.915: E/AndroidRuntime(5376): java.lang.RuntimeException: Unable to resume activity {com.pheelicks.visualizer/com.pheelicks.app.MainActivity}: java.lang.NullPointerException
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2458)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2000)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.access$600(ActivityThread.java:128)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.os.Looper.loop(Looper.java:137)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.main(ActivityThread.java:4514)
01-02 10:06:41.915: E/AndroidRuntime(5376): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 10:06:41.915: E/AndroidRuntime(5376): at java.lang.reflect.Method.invoke(Method.java:511)
01-02 10:06:41.915: E/AndroidRuntime(5376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-02 10:06:41.915: E/AndroidRuntime(5376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-02 10:06:41.915: E/AndroidRuntime(5376): at dalvik.system.NativeStart.main(Native Method)
01-02 10:06:41.915: E/AndroidRuntime(5376): Caused by: java.lang.NullPointerException
01-02 10:06:41.915: E/AndroidRuntime(5376): at com.pheelicks.app.MainActivity.init(MainActivity.java:60)
01-02 10:06:41.915: E/AndroidRuntime(5376): at com.pheelicks.app.MainActivity.onResume(MainActivity.java:39)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.Activity.performResume(Activity.java:4539)
01-02 10:06:41.915: E/AndroidRuntime(5376): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
01-02 10:06:41.915: E/AndroidRuntime(5376): ... 12 more
do support AudioTrack?
If the volume is high, the FFT values are also higher. This will make the music visualization dependent on the volume, which is not a good thing. It should be the same visualization for low and high volumes. I found an interesting and easy solution to that problem:
http://stackoverflow.com/questions/8048692/android-visualizer-fft-waveform-affected-by-device-volume
It works for apps, which have their own music player, because they then have a MediaPlayer object. The Equalizer and the Visualizer must have the same audio session id for this to work. That session id belongs to the MediaPlayer object.
The problem is that it does not work for external media players, like Spotify. The visualization becomes dependent on the volyme there. There is no option get a handle to a mediaplayer object for Spotfify, so I have to set the audioSessionID to 0. This means any player currently used. This will however make the volume code not work.
Has someone a good suggestion to make this work on external players too? It would help me a lot to keep improving my apps. The following are the code i added to the apps. The first code works and is for apps with their own player . The second code is for external players like Spotify and it does not work.
// Create the Visualizer object and attach it to our media player.
mVisualizer = null;
int sessionId = player.getAudioSessionId();
mEqualizer = new Equalizer(0, sessionId);
mEqualizer.setEnabled(true);
mVisualizer = new Visualizer(sessionId);
External players:
mVisualizer = null;
int sessionId = 0;
mEqualizer = new Equalizer(0, sessionId);
mEqualizer.setEnabled(true);
mVisualizer = new Visualizer(sessionId);
Has anyone here succeeded in implementing BPM syncing? Or will that demand more processing than the current Android processors can handle?
Fatal Exception: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3
at android.media.audiofx.Visualizer.(Visualizer.java)
at com.myApplication.android_visualizer.visualizer.VisualizerView.link(VisualizerView.java:85)
at com.myApplication.activities.RadioStationActivity.initVisualizer(RadioStationActivity.java:633)
at com.myApplication.activities.RadioStationActivity.checkPermissionsAndStartVisualization(RadioStationActivity.java:537)
at com.myApplication.activities.RadioStationActivity.onPlayingStarted(RadioStationActivity.java:525)
at com.myApplication.services.RadioService.onPrepared(RadioService.java:197)
at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1704)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Some time application get crash with this log
When i run the app..it works properly except the visualizer..As it should work as per song played..
My apps already visualize music from external and internal music players. I want to add live microphone sync, so my apps also visualize sound from the microphone. How can I implement that? I found no info about this on
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
There seems to be audio issues with Android 9. It could also be that the audio playing model has been changed in Android 9, but I can not find any information about this. The only audio related change seems to be "HD Audio: Improved performance and support for HD audio delivering clearer, sharper, and richer quality sound."
It is not only our apps that have issues with Android 9. I tested all the 10 top rated music visualizers. 40% of them have audio issues on Android 9, which makes the audio playing or the visualization not work anymore. I tested the same apps on a device with Android 8, where none of these problems appeared. This will cause big problems for the customers, when 40% of their music visualizer apps no longer work. Here are descriptions and stacktraces of the errors:
I have debugged and researched and found that setDataCaptureListener in Visualizer causes this problem. This is probably not a driver problem, since I see on the Play console that it happens on both Samsung and Motorola.
Visualizer is moving randomly..As it should working as per songs beat..
Hi. First of all thanks for such a great code. Nice work. I am implementing it one of my project but I am having a little problem. I don't want the old values of the bar to fade out. I want them to go instantly and not fade out. How can I achieve this?
I am using red color for the bars. I want the bars to fade really fast. If I use below code its not fading faster.
mFadePaint.setColor(Color.argb(238, 255, 255, 255));
However, if I replace above code with below code to make it fade faster, the output is it does fades faster but the color is not red anymore. Its red with too much alpha.
mFadePaint.setColor(Color.argb(100, 255, 255, 255));
I want the bars to fade really fast with maintaining their original color. How can I do it?
Hi Felix,
on NEXUS5 and NEXUS6p the visualizer only works if headphone is plug in or bluetooth is connected.
If I plug out the headphone:
V WiredAccessoryManager: notifyWiredAccessoryChanged: when=107798440914000 bits= mask=84
V WiredAccessoryManager: newName=h2w newState=0 headsetState=0 prev headsetState=2
I WiredAccessoryManager: MSG_NEW_DEVICE_STATE
V WiredAccessoryManager: headsetName: disconnected
and after I see:
D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=8
D audio_hw_primary: adev_set_parameters: enter: disconnect=8
W AudioTrack: dead IAudioTrack, PCM, creating a new one from obtainBuffer()
D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
D audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
D audio_hw_primary: disable_snd_device: snd_device(5: headphones)
I soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x5 of type 0 for Event 0
D msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
I soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1
D audio_hw_primary: enable_snd_device: snd_device(2: speaker)
D audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback speaker
D AudioFlinger: mixer(0xf4680000) throttle end: throttle time(12)
Edit: it works as aspected with AudioPlayer. The issue come only by using od Mediaplayer and this https://github.com/vbartacek/aacdecoder-android/blob/master/decoder/src/com/spoledge/aacdecoder/MultiPlayer.java player.
Help me
Hi Felix,
here is the module: https://github.com/AppWerft/Ti.AudioVisualizerView
I have implemented an static analysis tool for finding bugs in Android apps and I have found a NullPointerException (NPE) in the following class of your app:
What steps will reproduce the problem?
This will create a NPE in the activity. It is worth to mention that there are other scenarios in which this bug can be seen. For example, if the user receives a phone call, but before the phone call activity takes the foreground, the user tabs the Start or Stop button. This creates a race condition between the callbacks onPause and startPressed (onPause is called before startPressed). Other apps have had this problem as you can see in bug found in MyTracks [1].
What is the expected output? What do you see instead?
The app crashes. The app must not crash and maintain the same state when the user comeback to the app.
What version of the product are you using? On what operating system?
1.0 on a Samsung S4 Mini with Android 4.2.2.
Please provide any additional information below.
To fix this problem just check the mPlayer is not null or use a flag to know when a cleanup has been made.
I have some issues with the visualizer. The app draws a thin line in the middle of the canvas (about 5 pixels high) and draws the visualization into that. You cannot see it with the eyes. I had to zoom in to ensure it works. Is there someworkaounr for this?
The Visualizer documentation says that the returned bytes in getFFT()
are unsigned 8-bit numbers. Shouldn't rfk
and ifk
be converted to positive Java integers before using them like this, or am I missing something?
int rfk = data.bytes[mDivisions * i] & 0xff;
int ifk = data.bytes[mDivisions * i + 1] & 0xff;
Hello
I have used visualizer in my app and I get below system error randomly So I can not figure out actual issue. Can you please help me to solve this issue.
E/MediaPlayer(29188): Should have subtitle controller already set
A/libc(29188): Fatal signal 11 (SIGSEGV) at 0x42f20000 (code=2), thread 29529 (Visualizer)
Thanks
Girish
Hi Felix,
I have been using your visualiser and face the following issues. First of all, my ROM is AOSP based and I added Eleven and DSP from CM.
Hello,
I have just imported your project and then built for the first time but I get an error.
04-26 15:58:56.538: E/AndroidRuntime(1654): Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4
Google give me nothing except that that above returned code is ERROR_BAD_VALUE (Operation failed due to bad parameter value).
I think it is because my device does not support Visualizer engine. So, how can I do in this case?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.