How to program a simple music sequencer for Android (Java) [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
What I want to do:
I would like to program a very simple music sequencer for Android. But I've never worked with audio on Android or in Java, respectively.
What the application should do:
play back samples (WAVE/OGG files)
play several audio channels simultaneously (e.g. the trumpet and the flute should play simultaneously, maximum of 10 instruments)
change the pitch of the samples (e.g. the trumpet WAVE file must be played in normal pitch (c4) and lower/higher pitch (e2/g6) and so on)
This is what the application should be able to do in general.
What components do I need? A normal media player (AudioManager?) won't work, right?
There are already some applications which do what I am thinking about:
FingerBeat for iOS
FL Studio Mobile for iOS
Uloops Studio for Android
Thanks in advance for your help!

There is very simple open source beat sequencer for Android called SoundFuse. They have description and screenshots on the page.
Here is the github repository.

You have not one simple requirement, but three very different requirements.
Playing WAV should be supported out of the box by the JRE with the help of the classes in javax.sound.sampled, it jsut requires some code to wire it up (not too sure about android).
Playing OGG is not supported out of the box. There is an open source implementation for OGG called jOrbis, see their web site. Again this can require some wiring code to hook into your application.
For a Sequencer, you could just use MIDI. Again it should be supported by the JRE, and if it is not on your platform, you can use Gervill - a pure Java MIDI sequencer (Project web site).
There is also a ModPlayer that can play good old Soundtracker and some others. This can also be abused as a Sequencer of some sort if you know the Soundtracker or Screamtracker module format (ancient format, but descriptions are still available on the net). Player with source can be found here. The Tracker formats are not all that ancient by the way, some of todays game engines still make use of them.
If you really want, you can cook up your own Sequencer, all the basic stuff if there in javax.sound.sampled. It just requires some basic knowledge about digital sound and a big lot of wiring code.
There is no single solution for all your needs, you will have to stitch you own together from the building blocks freely available.

I won't be able to provide a complete answer, but I will point you in the right direction.
Android does support .wav and .ogg decoding. According to: http://developer.android.com/guide/appendix/media-formats.html
I don't have any experience in audio, but your best bet seems to be the SoundPool class, it allows you to adjust pitch and volume and it seems to be able to play multiple sounds simultaneously: "Note that calling play() may cause another sound to stop playing if the maximum number of active streams is exceeded."
http://developer.android.com/reference/android/media/SoundPool.html
There also is a MediaPlayer class, but this is for more simple use. I don't think it allows pitch control.

I made something similar for my application (playing trombones sample). After a lot of experiencing, I found the best solution was to use AudioTrack.
Have a look at my source code:
http://code.google.com/p/trombonino/source/browse/trunk/src/com/trombonino
Especially
http://code.google.com/p/trombonino/source/browse/trunk/src/com/trombonino/Trombone.java
http://code.google.com/p/trombonino/source/browse/trunk/src/com/trombonino/WavFile.java

You will have problems with your timing on the Android system. To avoid your sequencer thread being interrupted by garbage collection you probably need to write the sequencer in native using the ndk.
Playing back the sounds is probably best to do using the ndk as well.
Take a look at https://code.google.com/p/high-performance-audio/
In the above Soundfuse example the sequencer uses SystemClock.sleep() that is never a good idea. Check Why using System.Threading.Thread.Sleep() is a bad practice?.
Realized this question is really old but will answer it anyway since no answer mentions the NDK.

Related

GUI for computer vision app [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'd like some opinions please on a GUI for my computer vision application. I have written an application in C++ using OpenCV which captures video from a high speed camera, carries out some image processing on the images and displays the results to a HighGUI window. I find myself tweaking variables on a regular basis and have therefore decided it would be easier and quicker to tweak those variables using a GUI on the fly. I have a few options:
Create a Java GUI that can talk to my C++ computer vision app using sockets
Integrate my application within a QT GUI
Use native Windows calls (e.g. MFC)
Which do you you guys think is my best option, bearing in mind that the GUI or sockets must not detract from the performance of the image processing part of the application?
(My target OS is Windows)
Many thanks in advance everyone for your inputs.
I would consider option 1 or 2, 3 seams definitely the worst, because you have to write all related to gui code on your own and it will be not portable.
1. Instead of this option i would consider creating GUI in Java and putting whole c++ code into library and using it in Java or even using native c++ code in Java. This solution should be faster than sending data via sockets.
2. QT seams the best option - it has big community, lot of tutorials and partially is integrated with OpenCV(http://opencv.willowgarage.com/documentation/cpp/highgui_qt_new_functions.html). Another advantage is that application created with QT and OpenCV should run on many operation systems. Also you may use Qt Creator or visual studio qt plugin to create gui.
You really don't want to deal with platform native code on Windows. The API is archaic, just like MFC is.
I don't think there's any benefit to isolating the GUI in a separate process.
I'd suggest using Qt Quick. You can very efficiently display images from OpenCV by binding them to a texture on a trivial scene graph item. You get a fluid, modern user interface and performant integration with OpenCV at the same time. It all blends, so to speak.
The easiest way to integrate your variables with QML is by using model-view paradigm. You can expose the variables form C++ by reimplementing a QAbstractListModel. The variable's value could be bound to the edit and display roles. The variable's name can be exposed as an additional role, called for example name. It's then a simple matter to use a ListView in Qt Quick to display the variable list and allow it to be tweaked at runtime. You can easily have "fancy" delegates for your items, say sliders.

Microcontroller and Robot Construction [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am looking for an answer to a question relating to programming and robots..
I have been learning java over the past 2 years, and just recently started working with and Arduino microcontroller for a robot that is near completion(2 servos, 1 ultrasonic sensor, 2 parallax servo-controllers, 12v battery, all in a toy car that i ripped apart).
I was hoping to build a much more complex machine that would do all of the following:
Control 4 servos that would move treads
Powers a few cameras, possibly relaying several feeds to a monitor or pc wirelessly to help with user-controlled movement
Control a pan-tilt servo system for a top mounted camera or paintball/airsoft gun or some such similar device
Maybe a gps system, so that having it can return to the user when low battery, or when the user is done controlling it( NOTE: Not a necessary component, but would be very nice)
My Question is this: What microcontroller or controller do you know of that could be used to control all of that effectively, and not be maxed out(Also hoping that the suggested could control multiple systems at once)? What programming language would effectively be able to control all of the above robot effectively(or is great for this type of system in general)? Does the programming language that must be used change depending on the microcontroller?
There may be more to that, but currently, the base at minimum must be built before I can go anywhere else. My budget is not large, and would prefer to keep this cheaper than $1000-$1500 excluding the mounted tool on top.
I'd say you should take a look at the Raspberry PI for the time being. It cannot do it all alone, you will have to combine it with a real micro controller as io expansion.
The raspi is cheap, and got a strong community, easy to get help when you are stuck.
For micro controller I would chose an ATmega328 from Atmel (~$4 on ebay). with that one you can stay Arduino compatible, which again has a super strong community.
I know the newer BeagleBoneBlack will be able to handle both tasks in one unit, but the product seems to be a little less mature right now, and the community is nowhere close to raspi or arduino!
Over at LetsMakeRobots we are building robots too, some even as advanced as your project, you might find some inspiration. And there are definitely some motor driver geeks there!
You're looking for an Arduino with an Adafruit motor shield to start with. I won't post a link to either due to the commercial nature but that will put you in the right direction. I'm not sure Stackoverflow is the right place to ask this question though. You may have much better luck elsewhere.

Media player libraries in Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am evaluating libraries for playing audio/video in Java. It does not need to be 100% Java; Java bindings to native libraries are perfectly OK. An external application that can be controlled from Java is also fine, as long as it can render video on a Java component.
The target platform is Linux. Windows support is a plus, but not required.
I have played with VLC using the VLCj bindings, and it works pretty well in general, but keeps crashing occasionally when put under stress. I have also used mplayer in slave mode, which looks good. But I'd like to evaluate other options as well.
These are the requirements:
Live playback of H.264, MPEG4 through RTP using RTSP. Extra points for MJPEG over HTTP.
Able to render video on a Java (Swing or AWT) Component
Open source, and actively maintained
Stable, rock-solid
Suggestions? Advice?
Ok, I've spent the last month playing with several options and these are the results:
VLC. This was my first thought, as everybody keeps saying that it "plays everything". I have used both the VLCj Java bindings, and the built-in remote interface (-I rc). I found this to work pretty well in general, but had some issues. I kept seeing ocassional crashes under heavy load (not VLCj's fault as it also happens when using the binary directly). Also I've found memory consumption to be relatively high when compared to other options.
MPlayer. This actually performs better than VLC in my experience, no crashes, and memory consumption is lower. No Java bindings, although the slave mode works very well.
GStreamer. Very powerful, very flexible, while still easy to get started with. Tried both the Java bindings and running the gst-launch binary from Java. Both approaches work remarkably well.
Xuggler looked good, however it seems to have issues with RTP (as stated in the FAQ). Since both GStreamer and MPlayer worked so well, I did not get past the initial research.
I found GStreamer to be the best solution given the requirements, with MPlayer being the second option.
have you looked at gstreamer?
I've also spent a while researching my options, and I've actually come to the conclusion that VLCJ is the best option - however here's the clincher, you need to run it out of process (especially with multiple players) for it to give you 100% reliable operation. That's the approach I'm taking and I've yet to see it crash. With it rock solid in this way it also has other advantages:
It can play pretty much anything. Yes it's a bit of a cliche, but this includes DVDs, Youtube videos, pretty much any video file...
Should support Linux / Mac / Windows, though I've yet to verify Mac working.
Actively maintained, and if you ask a good (as in well thought out) question on the discussion group the owner often replies in minute in my experience!
Open source, and the Google group activity at the time of writing is high.
Uses all the graphics acceleration VLC does
Able to play to any heavyweight Canvas component (and if you use the direct player, you get the BufferedImage to display anywhere you like, even in JOGL 3D land if you're that crazy!
I haven't found it that heavy on the resources front either, though I haven't done any thorough testing (but 3 players work fine in tandem as well as my relatively power-hungry application on my 4 year old basic laptop!)
Disadvantages? There's no official framework for out of process players, so you have to build one yourself (see here for how I did it). And you do sometimes have to do some fiddling to get it working. But as far as I can see, it's working well for me so far!

What should a developer know before building cellphone apps? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to start making cellphone apps with Android as first choice but not the only one. I have 10 years of experience with Java, C#, C++ in commercial applications and I know that many things and practices for this applications are not valid for cellphones. Where do I start reading? How do I adapt my way of thinking to this new environment as quickly as posible? I plan to make some money with it sometime in the future as an extra income or a career change maybe, who know. Any resource or advice you could recommend will be very welcome. Thanks in advance.
Just start with Android Developer site http://developer.android.com/index.html.
It contains all you need for the beginning. Also take a look onto Commonsware android books,
those are really great both for beginners and experienced programmers - http://commonsware.com/books.html.
You could start with two great books listed as reference [1] (Ableson F. et al., Unlocking Android, 2009. Manning Publications Co., ISBN 978-1-933988-67-2) and [4] (Conder S. and Darcey L., Android Wireless Application Development, 2009. Addison-Wesley, ISBN 978-0-321-62709-4) in my degree thesis. Both have an extensive walk-through of Android, which you as a developer should know. You'll get all you need from "Hello World" to deploy an actual application in the Android Market.
Android is the place to start, since you already know Java and C# and C++. You can even use native classes in Java written in C or C++ if you have some useful standard classes in your library. More on Natives you'll find in the reference book [9] (Silva V., Pro Android Games, 2009. Apress, ISBN 978-1-4302-2647-5).
The best of luck!
Only support the TOP os's which generate income. So at this moment IOS and Android.
Don't go down the path of Symbian and Java... it's dirty, and you won't like what you see down there.
What really got me going was the Hello, Views documentation. Will really get you up and running instantly.
I recently decided studying Android, and http://developer.android.com was a great resource. You should read the Application fundamentals doc first and User Interface documentations later.
There are some tutorials too.
I read the whole Application fundamentals, and that gave me a good idea of "how to program for Android" since it has its own architecture and environment. Get the idea of Activities, Services, Broadcast Receivers and Content Providers and try to adapt yourself to that structure. Then read about how Tasks work, and later go into UI.
As a subjective opinion, being Android so popular and growing, I don't think it's worth the effort to study Java ME or even C (I'd go for iPhone devel in any case with Objective-C). Android will probably give you more money and faster. Java FX might be interesting...
iPhone
Android
Samsung Bada
I would like to mention that iphone and Android communities are very much evolved and have a great developer community and resources. Samsung Bada doesnt have a good developer network nor does the SDK support many operating systems. I think it works only on Windows.
You need to first understand the mobile platform architecture, the different frameworks which the platform exposes to the programmers to develop applications.
There are emulators for you to test, however you have to have one of those devices to do a real time on-device testing.
With respect to programming, i think your experience is more than enough but one needs to come out of the frame of mind and think differently. A typical device has limited processing power, limited memory, limited screen space but the user demands beats expectations compared to desktop/enterprise software.
Lastly most important thing is the IDEA of the application. You may want to survey existing application on the stores and start thinking. You can also develop and application which would solve your problem with mobile devices and you know other users also may want such a application.

Software Synth Library for Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I've been thinking a lot lately about a music-oriented project I'd like to work on. Kind of like a game... kind of like a studio workstation (FL Studio, Reason).
I guess the best way to describe it would be: like "Guitar Hero", but with no canned tracks. All original music--composed by you, on the fly--but the software would use its knowledge of music theory (as well as some supervised learning algorithms) to make sure that your input gets turned into something that sounds great.
It sounds a little silly, explaining it like that, but there ya go. It's something I think would make an interesting side project.
Anyhow, I'm looking for a Java library for generating the actual audio. Browsing around on sourceforge, there are countless software synths, and I have no idea which to choose.
My top priority is that it should sound incredible... Really rich, layered, textured synths, with gobs of configurable parameters. Emulation of acoustic instruments is not important to me.
My second priority is that it ought to be straightforward to use strictly as a library, with no GUI involved at all. (If there's a synth with really breathtaking output, but it's tightly-coupled with a GUI, then I might consider ripping the audio portion out of the application, but I'd rather start with a nicely contained library).
I know I could send MIDI to a standalone synth, but I think it'd be cool to read the actual synth code and learn a little DSP while I'm at it.
Any suggestions?
Oh yeah, I'm on Windows, so posix-only stuff is a no go.
Thanks!
Have you checked out JFugue? It's an "open-source Java API for programming music without the complexities of MIDI".
Additional information: Found a couple of other resources referenced in the JFugue documentation (pdf):
Audio Synthesis Engine Project: open source version of Java’s MIDI synthesizer
Gervill: open source software synthesizer created as a proposal for the Audio Synthesis Engine Project
Yeah, I noticed JFugue a few years ago. It's on my list of interesting computer/music bookmarks:
http://delicious.com/BenjiSmith/computermusic
http://delicious.com/BenjiSmith/programming.java.libraries.music
But JFugue is all about the structure of the music itself... the melodies, harmonies, rhythms, etc....
What I'm looking for right now is just the synthesizer. Something like this...
Synth s = new Synth();
Instrument i = s.getInstrument("Robot Bass");
i.makeAwesome(true);
And then I'll send my events into the MIDI stream (or into whatever control API the synth library provides).
If Clojure is an acceptable option (runs on the JVM, easy to integrate with Java), then it's definitely worth checking out Overtone.
It uses SuperCollider as the synthesis engine, but wraps it all in a nice DSL and interactive programming environment.
minim isn't exactly a java synth, but it is a processing lib and I imagine that it should be pretty easy to use with vanilla java too.

Categories

Resources