Changing audio speed in java
I'm having trouble changing the audio speed in a java app. I can effectively load an mp3 using using Java's sound API and a few plugins, but I can't change the speed. I'v tried to change the sample rate, but that affects both the pitch and the speed. Does anyone know of a way to alter only the speed? Or does any开发者_开发技巧one know how I can alter just the pitch? I've thought about altering the sample rate and than after I can change the pitch to the normal pitch of the song.
You can achieve all that using spectral representation of the sound. Changing the sample rate will indeed affect the pitch, so you keep the sampling rate as it is. Perform Fourier transformation of the initial sound signal, then you can move the frequencies up and down in the spectrum as you wish. Once done, perform inverse Fourier transformation to get a 'playable' audio data back. For long audio stream, split the data in chunks and be sure to apply windowing and overlap processed data, elsewhere you will hear clicks at the chunks borders as they will not stick seamlessly after the frequencies manipulation.
精彩评论