Is there a library for detecting the currently playing song with Java? Not only with WinAMP or WMP, but generally, a technique to listen the audio output for example?
Thank you.
Edit: No, I just want to listen the audio output and decide whether there's a song playing right now, or not.
Not identifying. Just there's a song or not (playing right now).
You can take the Fourier transform of the audio input and compare it to known frequency distributions of various songs in your database. If they are close enough, you can say that they are the same.
This obviously has some flaws, but it's an idea you can work off of.
CLAMP is a good choice for WinAMP. People misunderstood the question so hard.
Two things you could try: 1. do STFFT and look for harmonic relationships. These appear in ordinary speech as well, of course, so you'll have to experiment with what kinds of harmonic relationships exist in music vs speech. 2. analyse the envelope for repeating rhythmic patterns.
Related
So I can get an array of all the bytes of a wav file, I just want to know how I can decode the raw sound data to something I can use to tell when the singer is speaking/his beat (I don't know the proper musical terms, sorry)
If there is an API or tutorial out there that someone could link me to, that would be swell since I can't seem to find anything good.
Will you know this beat in advance? If so, you could cross correlate the two signals and the highest peak in this output would correspond to the time delay.
Other than that, depending on the sound before the beat starts, you could convert to frequency domain (via FFT) and have a look at what frequencies are present and see whether there's a significant change when the beat begins.
Some examples/extra detail would help.
If you're trying to detect the tempo of said beat, please ignore everything most of what I've said.
In general, detecting "the instances when something beats" in a wave file is not as one may imagine at the first thought.
A possible first step is to transform your .wav into a so-called "spectrogram."
I don't think Java has a dedicated API for this purpose, but googling "java spectrogram" would give you a number of third-party examples.
I also found this question might be relevant.
P.S. I'm not a specialist in signal processing, so corrections are welcome.
I pretty much have no idea how I would go about doing this- I need to find the frequency of a played sine wave at a specific point in time.
I've been doing some research and see that it involves a Fourier transform. I've found a DFT class but am not really sure how to use it.
My questions are these:
How do I save a sound file from a mic at a specific point in time?
What format will this be saved in?
From this, how would I go about using an FFT/DFT to find the frequencies in that sample?
I don't really have a clear understanding of the mathematics behind the FFT (and yes, I've tried to understand it), so am not really sure what outputs/inputs represent.
Alternatively if there are any libraries that support this type of thing, a link would be much appreciated.
Thanks in advance
So basically I want this to get the range of 60 - 150 Hz which is the general area for bass that lies in a song. Whenever it is in this range I want it do a function, and only it the range, my problem is I have tried to look up the functions needed to do so but with no luck, if one could show me here or a good article or explanation on this it will be great! I appreciate all the help and I will continue looking on my own. If more explanation is needed I can provide whatever information that is needed!
Austin.
UPDATE: I simplified an algorithm here:
User selects the song they want
Song loads onto player
Function scans song and finds the lower frequencies throughout the song and the output is a pattern.
Step 1) Do a fast fourier transform: http://en.wikipedia.org/wiki/Fast_Fourier_transform
An FFT takes a piece of sound and transforms it into the frequency/time domain - as in, which frequencies are playing and how intensely and during what parts of the sound. This is a useful mathematical operation that relies upon the property that all sound, no matter how complex, can be fundamentally constructed out of one or more sine waves of different frequencies and amplitudes.
If you've ever looked at a spectrogram, for example in foobar2000, it is implemented using FFT:
I suggest instead of trying to implement FFT yourself you find a library that is well tested and fast, such as http://en.wikipedia.org/wiki/FFTW which is written in C
Step 2) Now that you've FFTed the part of the sound that the user is listening to, you can simply inspect the frequency bins and do whatever you want! Although detecting bass kicks is not as simple as 'is this frequency bin a high value?' because then you may mistake bass lines for bass kicks. You may need to do further testing and research to get it to work juuust right.
EDIT: Delyan suggests http://www.clear.rice.edu/elec301/Projects01/beat_sync/beatalgo.html and it looks pretty good.
I am looking for a successful method to identify self-generated sounds.
My idea is to spend even two different sounds over stereo. The two tones differ in their frequency. The tones I turn then back on a self-made cables for the microphone. The cable has two switches, which switches between the left or the right channel.
I want to note which of the two frequencies arrived at the microphone input, and then count them.
I've tried many things, but nothing brought the desired success. Well, I came across DTMF, but the implementation in Android is insufficient.
Does anyone have any idea what I can try next?
You need to take the Fast Fourier Transform (FFT) of the input audio. What you would need to do is capture a short window of audio, run an FFT, and then analyze the result. FFTs are a bit a complicated if you're not familiar with them, but it's possible to count and measure tones, provided that they're sufficiently separated in frequency.
You can use FSK modulation and demodulation. You don't need an FFT, as this can be done more simply by narrow-band DSP filters (a couple of Goertzel filters), or quadrature demodulators.
I just want to play a very simple, straight forward note by giving my computer a certain frequency as an integer, and from there I can figure out how to make it play the note longer or shorter. It does not necessarily have to come out of the actual sound card - if it's generated and output by the internal speaker that's okay.
I looked at the midi libraries that java has included, and they are way more than what I want to do. This just needs to be very basic.
Look into JFugue -- it's really easy to do some basic stuff, and the capabilities are there if you want to expand later.
Player player = new Player();
player.play("A C# E");
This example constructs and plays an equal tempered scale.
As far as i know there is no way to do this without some boilerplate code in Java. The most simple API is probably provided by the Applet class (can be used by non-Applets as well) in the form of the static newAudioClip(URL url)-method. However this gives you just the ability to play predefined audio clips and you have very little control over the audio. If you just need to play audio from a small, predefined set of clips it might suffice (you could have a set of wav-files containing your notes and play them this way, AudioClip's can be looped if desired).
Other than that, both midi and sampled audio API's are much more powerful, but the flexibility comes at a price: You need considerably more code to set them up.