I'm trying to make a program that roughly does the following:
produceBeepSound(double loudness);
can I do such a thing in Java? I need it to be very precise. What about matlab? Which language would be best for this task. The language must have a GUI component.
You can use Java Media Framework to produce sound but it is not necessary because you can work with javax.sound.sampled package and integrate it with Java Swing.
In python take a look at pyaudio library and also take a look at PythonInMusic it has a whole lot of collection of various A/V module.
Also, take a look at Beeper.
It is a GUI program, using only J2SE classes, that can produce a sound
of configurable tone & duration, and (with a bit of tweaking) at
different raw volumes
Thanks to #Andrew for once again correcting me.
In MATLAB, just use the SOUND function:
http://www.mathworks.com/help/techdoc/ref/sound.html
You can specify a vector which represents your signal, and the amplitude on that vector will determine loudness, so its a matter of simple scaling.
you can try Csound. There is API for java.
You should also check this wiki page: http://en.wikipedia.org/wiki/Comparison_of_audio_synthesis_environments.
But if you need somthing simple you can try:
java.awt.Toolkit.beep();
or
System.out.println((char)7);
But you won't have volume control.
Probably my favourite approach would be HTML 5 audio api - https://wiki.mozilla.org/Audio_Data_API#Writing_Audio
on windows actually any language can emit a sound just outputting ascii character "\007". Here is a nice article about how to do it in java.
Related
I want to apply DWT and SWT to images in Java but can't find code, pseudocode or libraries for that. Until now, I only found existing code in other languages like C, C++ or Python but I need it in Java and I'm not able to change the code from one to another language on my own.
Does anyone know a library or another way I could use to solve this problem?
Thanks in advance!
Detailed description of the problem:
I want to apply DWT or SWT to an image and then do some further calculations with specific DWT/SWT subbands e.g. applying Discrete Cosine Function (DCT) to the LL-subband. If possible, I want to work with BufferedImages.
Just curious to know what it will take for me to have human capability to my java programs. Currently to display a message i use System.out.println and to read user's input i may use something like System.in. Wondering if there is a way for me to say System.out.speak() and System.hear();
If not possible with Java i'm okay to learn other languages please help.
Wondering if there is a way for me to say System.out.speak() and System.hear();
Literally, no.
System.out is a PrintWriter and there is no speak() method.
There is no System.hear() method.
Adding such methods would entail hacking on standard system classes ... making the resulting library "NOT Java(tm)".
Furthermore, there are no standard APIs in the Java libraries for text to speech or speech to text. (And I'm not aware of any other language that offers this functionality as a standard feature.)
However, I'm sure that if you looked hard enough you could find 3rd-party tools for doing this that could be integrated with Java, one way or another.
UPDATE
In fact, you have found the standard Android (as distinct from Java) APIs for this:
Speech recognition: android.speech
Text to speech: android.speech.tts
From a design perspective, I think it would be a better idea to support this kind of thing in the OS's user interface framework (where the user can control it), and not embed it in individual applications.
So it sounds like this is what you want:
"System.out.speak()" -- as you know by now, that's not a real thing. I think I could propose a high-level, temporary solution.
It sounds like you just want to be audibly notified when you reach a certain part in your code. Perhaps you could just record a wav or mp3 of yourself saying whatever it is you want to hear as an alert, and then import the wav/mp3 into your project directory. Refer to this article to figure out how to playback that audio:
Playing .mp3 and .wav in Java?
You could simply make a static method that takes in a string representing the desired audio playback and then does so by however the link above suggests.
If you want it to take in a string, and then have some sort of computer voice (e.g. Microsoft Sam) speak that string, that's a lot more complicated. I have no idea how to do that haha. But I'm guessing it's not as hard as your idea of "System.in.hear()"
"System.in.hear()" -- This is definitely not a thing. This requires knowledge in the field of Speech-To-Text (STT). This is basically how Siri or Google Now parses what you say to them. I'm sure there are libraries you could find that do this, but I'm too lazy to look for you :(
I hope this helps a little bit. I'm doing a little bit of research right now on STT and I saw your question pop up. I'm not very knowledgeable in the area, but I hope you figure out a way to get audio feedback instead of having to put println's everywhere. You should figure that out and reuse it.
Happy programming!
I'm trying to develop a system whereby clients can input a series of plant related data which can then be queried against a database to find a suitable list of plants.
These plants then need to be displayed in a graphic output, putting tall plants at the back and small plants at the front of a flower bed. The algorithm to do this I have set in my mind already, but my question to you is what would be the best software to use that:
1) Allows a user to enter in data
2) Queries a database to return suitable results
3) Outputs the data into a systemised graphic (simple rectangle with dots representing plants)
and the final step is an "if possible" and something I've not yet completely considered:
4) Allow users to move these dots using their mouse to reposition if wanted
--
I know PHP can produce graphic outputs, and I assume you could probably mix this in with a bit of jQuery which would allow the user to move the dots. Would this work well or could other software (such as Java or __) produce a better result?
Thanks and apologies if this is in the wrong section of Stack!
Your question is a bit vague. To answer it directly, any general programming language these days is able to do what you want, with the right libraries - be it C/++, Java, PHP+Javascript, Python, Ruby, and millions of others
With Java in particular, you'll probably want to use the swing toolkit for the GUI.
If you do know PHP+Javascript exclusively, it's probably best for your project to stick to what you know. If, however, you see this more as a learning opportunity than a project that needs be done NOW, you could take time to learn a new language in the process.
As to what language to learn, each person has a different opinion, obviously, but generally speaking, a higher-level a language is faster to prototype in.
EDIT
If you need this for a website, however, you'll need to use something web based - that is, you'll necessarily have two programs, one that runs server-side, the other one in the client (browser). On the server side, you could very well use PHP, JSP (JavaServer Pages), Python or Ruby. On the client side, you'll be limited to Javascript+DOM (maybe HTML5), a Java applet, or something flash-based.
Is there any way I could visualize a binary tree in java and C++? It could be a plugin for eclipse or VC++(although I dont think a plugin would be capable) or, it could be a library that enables you to draw them. I want to do this with the minimum amount of work possible. I can do it now with C++ and Win32 but that isn't an option because it requires too much time to code the damned thing. I also know that there might not be quite a simple solution to this, but I am looking for the best possible one out there, for both languages. The BST structure I talk of here will be custom, not a library one.
Thanks!
I think AT&T graphviz and its dot.exe is as easy as it gets to use. You can all it from inside Java if you must.
If you can output your binary tree in DOT format, it's pretty easy to visualize it. DOT is a super simple language which you should be able to emit in just a few lines of code. An example looks like this:
digraph graphname {
a -> b -> c;
b -> d;
}
Which generates http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/DotLanguageDirected.svg/168px-DotLanguageDirected.svg.png
Wikipedia has more: http://en.wikipedia.org/wiki/DOT_language
If you just want to visualize it for debugging and are using a Unix-like operating system, you can try ddd.
I'm developing a simple (or at least thought so) desktop application in Java for real-time image processing. I've chosen to access video frames using the Java Media Framework (JMF). I have a PAL camera and use EasyCAP video converter for digitizing. The device is visible on my Windows machine as a VFW device, allowing for YUV and 24-Bit RGB format acquisitions (32-Bit not available).
I already figured out the basics of the framework. I'm using a javax.media.Processor for media-data controlling and, for the beginning, wanted to add a grayscale-codec (implementing javax.media.Codec) for further rendering. In the codec I can access individual frames as javax.media.Buffer objects.
What is the fastest way to do the grayscale conversion in Java? I'd like to stick to some standard like JAI or so, as I'd like to be able to easily do further conversions using the same framework / methods.
I've been considering the following until now:
Adding a codec on the beginning of the codec chain to convert 24-Bit RGB to 32-Bit RGB. Than using java.nio.ByteBuffer to cast byte[] to int[] pixel-array for further processing with javax.awt.image filters. I've already tried to use com.sun.media.codec.video.colorspace.RGBConverter to achieve that, without success, though.
I'd be really grateful for any help, hope anyone has already done that.
I'd be grateful for any suggestions regarding overall application architecture as well. My general goal is to implement an Optical Flow algorithm in Java to be able to estimate camera attitude in real-time using visual input only.
Have a look at this library at JH Labs ( http://www.jhlabs.com/ip/filters/index.html ).
It is available with source code. You can check the implementation there... specifically GrayscaleFilter.. Also Check the license before use. If you like it then please give credit to the original author.. :)