How can I pitch-shift audio preferably without modifying the file? I need to change the pitch without changing the speed. I have a .wav and a .mp3 version of the same sound file if I can only use one or the other.
Asked
Active
Viewed 1,698 times
1 Answers
0
It looks like the TarsosDSP library will do what you're looking for. They even have a specific example on pitch shifting.
Source code for the pitch shifting demo can be found here.

CA2C7B
- 368
- 1
- 14
-
I'm trying but this example is really complex and I can't figure out how to use it or even get it to work for my purpose. I need a method that allows me to do this really frequently and have it be controlled by a program. Is there a less cluttered/clearer example/method? – Jacbo Mar 23 '19 at 22:36
-
@BruhBruh I guess I'm not entirely sure what you're trying to do, so it's hard to give a specific answer. What do you mean by "without modifying the file"? Are you trying to read in the same file and play it back over and over again at different pitches? or read in file after file? What is your goal? – CA2C7B Mar 23 '19 at 22:44
-
The former. I wanted to try to make my own midi player as a project. I was hoping there was a simple solution like how you can control the volume with javax.sound – Jacbo Mar 23 '19 at 23:16
-
@BruhBruh Unfortunately I don't think you're going to find anything as clear and easy as the controls in javax.sound. You can naively edit the pitch by changing the speed through javax.sound. but to do that without impacting speed, you need to do more advanced processing. Have you learned DSP or Digital Signal Processing? – CA2C7B Mar 23 '19 at 23:26
-
I can't find any simple code which would help you, but this page gives a really good mathematical explanation of what you're trying to do. http://www.guitarpitchshifter.com/pitchshifting.html – CA2C7B Mar 23 '19 at 23:43