I have a physical simulation of a vibrating string (made with matter.js). From this, how can I derive the sound wave / air pressure over time, that would result from such a string?
I had considered simply summing up each segment's vertical (y) position at discrete time steps, but this approach does not work for any shape other than the most basic mode of vibration shown above. For example if the string develops another node in the center as shown below, the y-positions would cancel each other out most of the time.
So, what would be a good way to derive the shape of the resulting sound wave from an arbitrary string shape?
Edit: As Philip pointed out in a comment to Gert's answer, this question could probably have been worded better, so here is another try, by giving an example:
Let's say you pluck a guitar string, take a sound recoding and a video recording with a super slow motion camera, for 1 second.
What we see in the video (all the ways the string vibrates) and the audio matches up.
Now say we lost the audio recoding. Is it possible for me to re-create the audio only with the help of the video?
We can say for convenience that the super slow motion camera recorded 44k frames, which is a typical audio sampling rate. So for each video frame, I want to produce an 'air pressure' value that I can send to my speakers.
(I hope this makes it a bit clearer what I'm asking for. If anybody has any other suggestions for improving this question, they are very welcome!)