I'm working on a Processing project. I tried to set the Volume of the audio played with the minim library. (setVolume seems not to be supported, and setGain has no effect)
So, I'm wondering whether there is no other, simpler way to control the audio in Processing? Or are there some Java commands, that can be used directly?
(In fact, I want to fade In and Out a short audio file, which means, I go through a loop and increase the volume after some steps)
I thank for every help!
Greetings
Nicolas
Try using Sonia or Beads (both listed here). Both of these will let you do what you're after.
I've had nothing but problems with Minim since it was first rolled into Processing; the other libraries are better documented, easier to use and a lot more stable!
I did it now with ESS.
ESS is perfect, because you have also a pause() and resume() function. And it works with MP3's.
thanks for your help!
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.
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.
I'm a bit stumped here. I need background music for the game I'm making, and for most songs, there will be a beginning section that will head into a loop once it's done playing (aka an intro). Although this seems kinda simple, I haven't been able to find anything that would do this. Could anyone help? Thanks!
EDIT: Screwed up a tag
First of all, I recommend you to use OGG instead of MP3, has better performance.
You have to separate the music into two tracks, one with the intro, and one with the looping part. In the code you have to initialize both tracks as two different Music objects. Set the looping in the object with the intro track to false and start playing it. Now on each cycle of the game you have to check if the intro track is playing, if not, start playing the loop (You have to make additional checkings if you can stop the music by other means, e.g: pausing the game).
Depending of the performance of the computer, the change will be amost unnoticeable or be a small gap.
edit:
my bad, I saw Java and automatically assumed it was Android.
Try looking in this answer
I'm new to using the javax.sound.sampled package, the reason I chose to to use the package was to have more control over the audio I was using than some simpler sound solutions such as AudioClip.
I've read through: Oracle's Sound Tutorial
(or at least as much as I could grasp) but I don't see a method of modulating the level/volume of playback on a Line using the Clip interface they seemed to give these kinds of options in the portions of the package that allow you to create sound, but I can't find any way of making these adjustments be it through my Line, or my AudioInputStream.
I found [this] page with the text,
Float controls, on the other hand, are well suited to represent continuously variable controls, such as pan, balance, or volume.
but no Lines on my computer return any Controls (using Line.getControls())
(I tried to force the line to accept the FloatControl.Type.VOLUME similar to this but I get an "unsupported control type exception")
Is the only way to modify the volume/level on a Line (using the Clip interface) through use of the Line's controls? Or is it possible to modify the volume of an AudioInputStream?
Alternatively is there a method of adding Controls to an existing Line?
Instead of using FloatControl.Type.VOLUME use FloatControl.Type.MASTER_GAIN.
There is at least one other way, besides using lines. (I was also having trouble getting a control line, and found that a Master line worked, as recommended by Travis Meyers. I'm giving him a + vote.) Not sure if you want to go there, but it is possible to multiply EVERY frame's audio values by a volume factor. The Java Tutorial makes a passing reference to this technique, but like much else in that document, they don't provide explicit examples.
Thus, when you acquire a buffer of bytes, you have to loop through the buffer, assembling the bytes to get the audio values. Then, multiply by your volume factor (often a float from 0 to 1.0), then dissassemble the audio value back into bytes.
It works. I do it in a crude Java Theremin you can try out. I also manipulate my pitches on a per frame basis in that program. But there are still issues with the program! I'm working right now on improving the way I pipe GUI event data to the audio loop. Also, I'm responding to changes on a per-frame basis rather than via per-buffer basis. But for most uses, per-buffer is fine.
That said, something to listen for is to take care about sending in changes in volume that cause discontinuities, which can cause loud clicks. The amount that causes the click can vary in the different volume ranges. Also, volume doesn't exactly drop off in a linear fashion, as you go from 0 to 1.0 with your volume factor.
I have converted a few of my Processing sketches into Android apps, but they seem to run really slowly in the emulator and on my device.
Are there any tips on how to increase the speed and performance of my sketch running as an Android app? Are there things or parts of the Processing API I should avoid?
http://developer.android.com/guide/practices/design/performance.html
I hope that helps you.
Facepalm to all answers...Their answers are for programmers that need every single % of the CPU optimized. But I have the same issue as you, not really having much going on in the sketch, but it's still slow. And I doubt BlackDragon even knows what Processing is
My answer:
Try using a different renderer,
P2D for example.
You can use it by putting it next to the sketch size definition:
size(Width,Heigth,P2D);
Or if you don't want to use that function, you can override the sketchRenderer by placing this method.
String sketchRenderer(){
return P2D;
}