Building a music visualiser - java

I am interested in building a music visualiser using fractal patterns for my final year project. I have googled quite a lot on it and I know a bit about fractals, however I was wondering what software would be used to 'animate' the graphics.
I know Java has a drawing API (AWT and Swing), but it's probably not the best for the animation factor. On the other hand there is also Flash that has new capabilities within as3 to produce such an effect, but if this app was to traverse into mobile development Flash wouldn't be a great choice. So there still exists a gray patch in my head regarding actual app development. Can anyone give me a head's up on where to start looking?

I would suggest that you first define what it is you want to build and then choose the best technology for the task. For audio visualization you will most likely be using some kind of Fourier data. This and the fractal math concepts should translate across programming languages well.
I will often build prototypes in ActionScript or Python just to understand the fundamentals of new topics. Once I have an understanding of the concepts and know the target platform, the prototypes are usually very helpful and sometimes can be easily ported over.
As for quickly prototyping audio visualizations you could use Processing ( java based ), openFrameworks ( c++ ), Cinder ( c++ ) or Flash.
Each of these technologies are cross-platform, allow you to read audio data in realtime, quickly create windows and provide easy to use drawing APIs.
Also, it sounds like you are thinking about mobile. I believe that both Cinder and openFrameworks can be used for iPhone development. As well, AS3 can be compiled into an AIR app which will run on the Android platform. Performance of Flash on Android devices varies greatly from device to device though.

Related

Use Java or other languages in a Flutter Application

Since I got no answer and not much feedback on this question: Android Flutter Analyze Audio Waveform
and found nothing online about what I'm looking for, I'll simply ask a broader question, since a comment on that answer told me to use native code and use a platform channel to connect it to flutter but when I asked some clarifications I got nothing.
So my question is If I can do operations in Java (which has been around since a much longer time, and thus has a way bigger documentation), and then use the outcome in Flutter.
More precisely, could I do these things in Java and Flutter:
1) Analyse Audio waveform and find peak points in specific frequencies, and use the timestamp to display them in flutter;
Edit 1:
What Are Peak Points?
This Is the waveform of different frequencies ranges (The Orange one is bass (80-255Hz)), and the Points circled in black are Peak Points. I should analyze the audio specter of a song and Find the peak points in certain frequencies. Then When I Find the Peaks I need to save the timestamps, for example, 16 seconds in and so on.
2) Edit 2:
I need to Edit some photos in a video, like a video collage, for which each frame of a 30 or 60fps video is an image.
3) Edit 3:
I need to add basic frame specific effects to the video, for example a blur that will change frame to frame, or a glare.
4) Adding Music to that video and save it to an mp4 or avi or any format.
5) Edit 4: Most Important thing, I don't want to this all in real time, but more like an After Effect like Render process, in which all the frames are rendered together. The Only thing that would be nice is a sort of progress bar telling the user that the Render is at frame, for example, 200 of 300, but I don't want to display any of the frames or the video, just to render it in background and then save it to an mp4 video that can be viewed after.
As You can see it's a difficult process to do in a language to which you hardly find a tutorial on how to play music due to its early state. But Uis and some other things in flutter are way easier to do and Flutter is also Multi-Platform. So I prefer to stick to Flutter language.
Edit 5:
I took a look at Qt and JUCE, and found out that Qt seems a valid alternative but it seems for what understood more like a "closed" system, I mean, for example I looked the multimedia library but for what I've understood, you can do basic stuff, for example play a video, but not collage frames and save it. (Don't know if I explained myself well). JUCE On the other side, looks better but it seems more for PC audio VST than for mobile applications including video rendering. And another thing is that these two are not free and open source like Flutter is.
Then There is Kivy, which could and could not be the best, because it is a Python port for Mobile Devices and I have a lot of experience with Python And I think it's one of the easier language to learn, but on the other side, it hasn't got that much UI power. and as you mentioned there could be problem using libraries on Android.
You stated I could use C++ or Java With Flutter, but with C++ you told that it's a difficult process. So My question turned out to be Could I write the process in java with a Normal Android Application And Then in some way use the functions in a Flutter App?
Edit 6:
I found a possivle alternative:
Kha (http://kha.tech/). But again found nothing on how to use it with Flutter. Could it be a good Idea?
I'm asking more of a confirmation on if I could use Java or any other language to do what I need in a Flutter Application. And If yes if it's complicated or not that much. (I'm a beginner sorta). But Some tutorial or links to kickstart the code would be helpful aswell!
Flutter at this time is great for building UIs but as you've mentioned, it doesn't have a lot of power or compatibility with libraries yet. A good part of the reason for that is that it doesn't have easy integration with c++, but I won't get into that now.
What you're asking is most likely possible but it's not going to be simple at all to do. First, it sounds like you're wanting to pull particular frames from a video, and display them - that's going to be an additional complication. And don't forget that on a mobile device you have somewhat limited processing power - things will have to be very asynchronous which can actually cause problems for flutter unless you're careful.
As to your points:
This is a very general ask. I'd advise looking up android audio processing libraries. I'm almost sure it's possible, but SO questions are not meant for asking advise on which framework to use. Try https://softwarerecs.stackexchange.com/.
Once again, fairly general and a bit unclear about what you're asking... Try sofwarerecs. I assume you're wanting to take several frames and make them into a video?
Some of those effects (i.e. zoom) you could definitely do with flutter using a Transform. But that would just be while playing in flutter rather then adding to the video files themselves. To do that, you'll have to use the video library in android/java code.
Once again, the video library should do this.
This should also be part of the video library.
I do know of one audio/video library off the top of my head called Processing that may do what you need, but not for sure. It does have an android sdk though. OpenCV would be another but only for video/image processing and I haven't used it directly with Java so I'm not sure how easy it is to use.
For how you'd actually go about implementing this along with flutter... you're going to need to use Platform Channels. I mentioned them in the comment to your other answer but figured you could look that up yourself. The documentation does do a much better job of explaining how that works and how to set it up than I can. But the TLDR is that essentially, what they allow you to do is to send serialized data from native code (java/kotlin/swift etc) to flutter code (dart) and vice-versa, which gets translated into similar data structures in the target language. You can set up various 'channels' upon which the data flows, and within those channels set up 'methods' which get called at either end, or simply send events back and forth.
The complication I mentioned at the beginning is that sending images back and forth across the channels between flutter and dart isn't all that optimal. You most likely won't get a smooth 24/30/60fps of images being sent from java to dart, and it might slow down the rest of the flutter ui significantly. So what you'll want to use for the actual viewport is instead a Texture, which simply displays data from the android side. You'll have to figure out how to write to a texture from android yourself, but there's lots of information available for that. Controls, the visualization of the audio, etc can be done directly in flutter with data that is retrieved from native.
What you'll have is essentially a remote control written in dart/flutter, which sends various commands to a audio/video processing library & wrapper code in Java.
If all that sounds complicated, that's because it is. And as much as flutter is very nice to build UIs in, I have doubts as to whether it's going to be worth the extra complications if you're only targeting android.
Not really related to the answer but rather some friendly advice:
There is one other thing I'll mention - I don't know your level of proficiency with programming and with different languages, but video/audio processing and such are generally not done in java but rather in actual native code (i.e. c/c++). As such, there are actually two levels of abstraction you're going to have to be dealing with here (to some degree as it will probably be abstracted somewhat or a lot depending on the library you're using) - c/c++ to java and java to dart.
You may want to cut out the middlemen and work more directly with native - in that case I'd recommend at least taking a look at Qt or JUCE as they may be more suitable than flutter for your particular use case. There's also Kivy (uses python) which may work well as there's a ton of image/video/audio processing libraries for Python somehow... although they may not all work on android and still have the c++ => python translation to some degree. You'll have to look into licensing etc though - Qt has a broad enough OS licence for most android apps, but JUCE you'd have to pay for unless you're doing open source. I'd have to recommend Qt slightly more than the others as it actually has native decoding of video frames etc, although you'd probably want to incorporate OpenCV or something for the more complicated effects you are talking about. But it would probably be on the same level of complicated as simply writing in java code, but with a slightly different UI style & easier integration with c++ libraries.

Video - sound - sensor capture in Java

I would like to develop an application which would be able to capture video from a webcam, capture sound from a mic and capture movement if a proximity sensor is available.
Initially I want it to run on windows but if able I might want to make it work on android later on.
I'm looking for something pretty straight forward and easy to understand.
My research has led me to Java Media Framework but it is too old and abandoned.
FMJ seems also old.
JavaCV appears to have poor documentation available.
My goal is to make a home detection app which uses the camera imagery, mic sound and sensors to detect and analyze home invasion.
I might take a leap and do it in .NET or other object oriented programming languages if
easier solutions present themselves.
How should I approach this, what are your suggestions?
One Solution is use JavaCV. So you can develop your desktop application using java and later can be ported in to android with fewer changes. As you said JavaCV haven't rich documentation. But JavaCV is just a wrapper to a OpenCV. So you can read OpenCV documentaion and find the relevant method(function) names. The methods in JavaCV has almost same names as OpenCV. So you can try those methods in JavaCV.
Next solution is use .NET to develop the system. There you can use
AForge.NET a rich library for .NET or Emgu CV .NET wrapper
for OpenCV. But you will be facing a problem when creating the
android app. Because you have to build it from scratch.

Porting Java OpenGL-based Android game to iOS (no native code)

I might be a little screwed here. I've been developing an engine for use in various games that I've been making for a long time now.
The engine is written in 100% Java(no NDK), and uses OpenGL ES 1x for rendering. its got textures, 3d mesh loading, animation, image based fonts, tilemaps, custom file types, and all that good stuff at around 8.5k lines of code, so you can probably see why I wouldn't want to recreate all that on iOS :(
Anyways, some of the engine relies on the Android SDK, but those parts can easily be removed/changed, leaving just the engine code and calls to opengl. However, never having developed anything on iOS before, I am a little clueless as to where I should begin with the porting.
I know that you need to develop using XCode(or is it objective-c?) on iOS, but would it be possible to use Java instead?
I would greatly appreciate it if anyone could just point me in the right direction. It would really suck to have to rewrite my entire engine in a different language.
No, there is no way to compile java code so it can run on ios ,and propably will not be in the future either because of the nature of the ios witch is a close platform .
Your best choise here is to rewrite your code to c witch i think its not very difficult since opengl commands stays the same plus you will see a performance boost

Android flash vs Java

I've been thinkin about games on android and was thinking - isn't it EASIER to make a game in flash than in android using Java with android SDK ? I've only experience with Flash/AS3 and it's quite easy to create user interface, animations, layout and to write scripts.
As of Flash CS3 there are motion detection objects, so we can create really interactive games.
However I've not seen any flash game related for a phone( I mean with orientation and so ). Is there something I am missing like flash too slow on a android enabled phone?
This applies to applications too. I would like to hear opinions about Flash vs Android :)
you can create game in flash and adobe air will convert it in apk. adobeAir is version where you can create any game and just 2 or 3 step that convert it in apk.so you can publish it or play it in your android phone
Flash is not supported on Android 2.1 and lower, and some manufacturers no longer provide software updates for their older devices. I think Flash will also probably be slower (which may not be an issue if your game isn't very computation/graphics heavy) and consume more battery. It also doesn't take advantage of multi-core processors right now, but that may change in the future.
On the other hand, if you write your game in Java for Android, you will be limited to one platform.
As a compromise, you could try something like Haxe, which allows you to compile your code into flash, Java and C++, among others.

Should I use Flash or Java?

I want to make some 2d games that I may want to submit to a game site, such as newgrounds.com. Even if I decide not to submit, I'd still like to know which is a better choice.
Which has a faster startup time?
Which performs faster in a 2d game?
Which IDE should I use?
Thanks in advance!
EDIT:
Also, a couple more quick questions.
I have used xna quite a bit, and silverlight a little. Where do I get started with flash? And what 2d libraries do i need? Also, is flash going to be anything like xna with an update loop and a draw loop?
The de facto standard for browser games is Flash. While there are game submission sites like ArcadePod.com that accept Java, most (including Newgrounds) are Flash exclusive.
Notably, Adobe Flash Pro and Adobe Flash Builder both cost $700.
Performance-wise and deployment-wise, Java using JOGL is probably the best I've seen in a browser.Check this out: https://jogl-demos.dev.java.net/applettest.html
That said, Flash and HTML5 should be hardware accelerated... at some point in the future. We should be seeing some very nice DHTML5 graphics libraries very soon. Combined with more Javascript-targeting compilers like GWT, I'm guessing that this is where we'll be seeing much game development in the future.
Definitley Flash over Java for in browser. Silverlight is also decent. Don't expect Flash or Silverlight to perform as well as XNA, as XNA makes use of the GPU with programmable shaders etc.
I recommend using FlashDevelop if you don't want to pay for any tools.
Realtime games in Flash use a loop. There are two ways of achieving this. The first is to create a Timer object and create a listener for it. The second is to listen to an ENTER_FRAME event (which is dependant on the Framerate you set). I personally use the second way of doing it. Since you can not guarantee the framerate its good practise to use a time delta to adjust values.
The best thing about Flash is there are a lot of mature engines out there, I will only focus on 2D ones here.
For physics, Box2D is the way to go, its a port of the C++ Box2D engine. Very powerful.
For keyboard input grab this class: KeyPoll
Depending on the type of game, the as3 game engine fixel might be useful
As for rendering, the simplest way is to use Sprites and Movieclips. You can draw programmatically, or if you use Adobe Flash Pro you can draw them by hand. An alternate way to render is to create a bitmap object and draw pixels to it.
I think it would be worth investing in a good book. For learning ActionScript3.0 everyone recommends Essential ActionScript 3.0 by Colin Mook.
For games development: Foundation Actionscript 3.0 Animation:
Making Things Move! and AdvancED ActionScript 3.0 Animation by Keith Peters are great. You can find his blog at Bit-101
And last but not least, a fairly new book The Essential Guide To Flash Games looks great but I have not read it yet.
Also if you search stackoverflow you will find similar questions about learning AS3 with links to online resources.
JavaFx is a very upcoming technology in developing both 2D/3D games and infact it gives same effect as Flash.you can have its libraries and inbuilt support IDE in Netbeans IDE.
I have developed both in Java2d/swings/graphics and Flash. Flash uses VECTOR Graphics which has a very good output irrespective of any screen resolution. Plus it will become fun and easier to design objects in flash rather doing everything by coding in Java.
That does not mean that you have everything ready in Flash. You still have to work with Actionscripts which obviously involves coding but it will be really fun once you learn it. You can always post your problems in this community where you have nice support for any actionscript related issues.
All the best!
If you are building a game, mass outreach is more important than any of the factors listed. Far more people have flash installed than JRE/Java Plugin, So I would advise you to go with Flash. Of course performance matters a lot, but getting people to play is more important.
For flash games, you can use Adobe creative suite or flex.
BTW, another good game development platform is MS silverlight, but thats out of the question too. It has even lesser market penetration than Java
Flash is better suited to 2D graphics rendering, was made for the browser environment, everyone has it installed and it's easier to learn than Java IMHO.
Here is a good way to get started looking for good libraries, although to be honest, Flash comes built-in with everything you "need", per se.
22 ActionScript 3.0 API's
Also, don't leave home without your API Documentation!
I'll try to dig through my history of API's and apps; it's been a while since I dabbled in AS3, but those were some nice times.
The sites you are looking to submit to will most likely take flash games over java versions.
I would recommend picking up flash its self and actionscript 3.
You may also want to pick up a free copy of the PushButton game engine which will take a lot of your development time away and allow you to focus more on actually building the games and not so much on getting the physics and collisions etc working.
http://pushbuttonengine.com/
In terms of user accessibility, I suggest flash.I believe it's easier to develop 2d games in flash...

Categories

Resources