Reputation: 3062
I have been trying to generate Audacity-like waveforms. I used java sound api and got up to a decent point of representing the actual mp3 to a waveform. Do you have in mind any mathematic function that I can apply to the dataset to be painted so the it looks more dense and smoother?
Thanks!
EDIT 1:
The proposal for moving average(I used the exponential) works great but do to the restrictions I have(single threaded) was performing really heavy. Apart from that the output was excellent!
I ended up into a small implementation of my own. I take the local maxima of an area of values and connect it with a straight line to the local maxima of the next area. It is fast and gives nice output.
EDIT 2: Linking code/solution by @Nicholas DiPiazza
Upvotes: 0
Views: 1199
Reputation: 7910
If I understand you correctly, you have figured out how to get to the PCM datapoints, but are now wanting to fit a curve to them. Yes?
Linear interpolation is the simplest way to do this. I'm surprised if it isn't smooth enough. What is your sample rate?
I know there are higher-order curves that can also be used to fit datapoints and that would make the graphical representation smoother. I'm not sure exactly what would be the best for representing an audio wave. I seem to recall the term "cubic interpolation" bandied about for use with audio. Can't say for sure though, and the math is a bit rough.
Upvotes: 1