I'm trying to get the data that the soundcard is outputting. Unfortunately, from my understanding of the Java Sound API, SourceDataLine does not support the read method, and there is no way to listen for raw data. I want to stick to Java for this, rather than C++, so if anyone knows how to listen for audio output on the soundcard that would be great.
Thanks very much!
Sorry if this post is confusing, just woke up.
I've researched this a while, and determined any implementation using only java sound will not work with any reliability on multiple audio cards.
There are a few solutions though. Hopefully one of these helps you.
Bite the bullet, write some C++ code to allow this functionality on different operating systems.
Use Java Sound to capture audio from a virtual audio recorder adapter which loops back the system audio output.
Create a loopback yourself using cables to feed a sound output port into a sound input port.
I recommend option 1 if you're developing this for a professional application as installation will be cleaner.
Go with option 2 if you've a short amount of time, and you expect to spend more time with your users, or your users are tech savvy.
Use option 3 if this is just a hobby, or some one-off project for a client.
Related
Working on a project requiring the analysis (speech to text) and recording of up to 10 real-time audio (microphone) input streams simultaneously and separately. I'm most comfortable with Java, so my central question is if this is possible with Java Sound API (or other 3rd party lib). But development is just beginning so if there is a better tool for this job I'm open to suggestions.
Development platform is MBP OSX 10.8.
Regarding audio input, I'd assume a bunch of USB microphones, unless someone knows of an appropriate device that allows separate simultaneous addressing of inputs.
Java Sound API isn't the easiest to learn, but it is reasonably low-level and powerful. I've mixed more 10 tracks before, using .wav inputs, custom-made "Clips" (reading sound files from memory) and procedural FM synthesis, using software I was able to write as a Java programmer with intermediate skills and some basic knowledge about sound (but NOT an engineering degree level of sound knowledge).
I've not tried recording multiple lines, or recording at all for that matter except one "toy" program that takes an input wave and stores it for varispeed playback. That really wasn't much more complex than just uploading a .wav, so I don't know the answers to t your question. I do anticipate it will be worth a look at the TargetDataLine interface as a key tool.
There are various sound engines written in Java. A contributor at Java-Gaming.org ("nsigma") has done some fine work on a media tool/system called "Praxis". AH -- just found this link:
http://neilcsmith.net/software
He often answers questions on the "Sound" topic at Java-gaming.org, and has spoken of "JAudioLibs" (linked on the page above).
How does one obtain the system sound, (beeps and such), and then record it and output to a sound file? I can get sound from a line - in mic, but I can't figure out how to get the actual system sound.
Any assistance?
This has been a long unanswered question which has been frustrating me as well.
I found a way to capture/record Windows' audio output, but it is more of a hack job rather then an actual solution. Disclaimer: This is my blog. I say this because from what I have found Java doesn't capture the data from a specified audio device [See the official Accessing Audio System Resources Java tutorial (although you can list out all of the audio I/O devices/audio ports, See: Programming JavaSound), instead it just takes the default device (which is how I 'solved' the problem).
This, however, introduces a problem where because the default recording device is no longer the microphone, you can no longer record from the microphone as another input; Although, using the Port.Info class to capture the microphone might be a possible solution to this side effect.
I hope this will help.
I have made a few simple apps on android, and thought it was time for something a bit more complex. So, i thought I'd try something that's already out there, but build it from scratch.
The idea is to create an app that allows user to play piano by pressing virtual keys on the display. But I'm not sure how to go about synthesizing the sound of each note, is it best to have copies of of each note stored on file, or is there a more dynamic way of synthesising notes and chords on the fly.
I have worked with C++ so NDK stuff is also okay.
Thanks for any help.
Sound playback (handing off buffers) pretty much has to be done from the Android java apis
Synthesis could be done in native or java, whichever it preferred.
Short (uncompressed) samples could be played back repeatedly, but you probably also want an attack transient. Perhaps you could have an attack, a sustain, and release, repeating the sustain as long as the key is down. Ideally each sample should be an integral number of periods of its fundamental component long so that you don't get a transient when you change between the attack to sustain or sustain to decay.
I'm sure you can find code somewhere for an FM or other synthesizer... this you might well want to implement in a native library that hands off buffers to java code to pass to the audio apis.
What is too bad is that android already has an internal midi synthesizer, but apparently lacks a dynamic interface to it, so it can only play midi files.
By far the easiest solution would be to record the sound of each note on the piano and play it back when the key is pressed. Many professional virtual piano instruments work this way, recording every note on the piano being played at multiple velocities. Obviously this can take many gigabytes of disk space, but for a mobile phone app, you might get away with a single MP3 recording of each note in an octave.
Actually algorithmically synthesizing the sound of a piano is very difficult to do, and until fairly recently, very few have done it convincingly (pianoteq is one of the best current implementations).
does any one know how to capture voice and send it through a network then play it on another computer in java
I did some research on this about 10 years ago at a research lab so I might be a bit out of date! At the time there was no standard for the whole process. You have to use the Java sound API to record and playback, then any network protocol you want to send it.
If it is just for a person to listen to, then use something with good compression - something like the media streaming in the Java Media Framework. If you want to use speech recognition on the data you'll probably need something higher quality and closer to the raw data, and it might be worth looking at the Java Speech API.
Let me first state that I do not know Java. I'm a .NET developer with solid C# skills, but I'm actually attempting to learn Java and the Android SDK at the same time (I know it's probably not ideal, but oh well, I'm adventurous :))
That said, my end goal is to write a streaming media player for Android that can accept Windows Media streams. I'm okay with restricting myself to Android 2.0 and greater if I need to. My current device is a Motorola Droid running Android 2.0.1. There is one online radio service I listen to religiously on my PC that only offers Windows Media streaming, and I'd like to transcode the stream so my Android device can play it.
Is such a thing possible? If so, would it be feasible (i.e., would it be too CPU intensive and kill the battery)? Should I be looking into doing this with the NDK in native code instead of Java? I'm not opposed to writing some sort of service in between that runs on a desktop computer (even in C#), but ideally I'd like to explore purely device-based options first. Where should I start?
Thanks in advance for any insight you can provide!
Having a proxy on your PC that captures windows audio output, encodes it, and sends it to your phone is perfectly possible. I had something like that 8 years ago on a linux-based PDA (sharp zaurus). The trick is that you're not trying to decode or access the XM radio stream directly, you're simply capturing what is being sent to the speakers on your desktop and re-sending it. There will be a minor hit in audio quality due to the re-encode, but shouldn't be too bad.
I've done cloud-to-phone transcoding using an alpha version of Android Cloud Services. The transcoding is transparently done on a server and the resulting stream is streamed on the phone. Might worth having a look. http://positivelydisruptive.blogspot.com/2010/08/streaming-m4a-files-using-android-cloud.html