I am piss-poor at math which makes certain things difficult for me to figure out.
Here's what I am up against.
I am trying to move a vertical bar horizontally across a picturebox at a precise as possible amount of time.
In this picturebox is a display of a sine wave from a sound file (a .wav). The duration of time varies from one sound file to another. I need this bar to start moving left to right at a given pace so that it will reach the right edge of the picturebox as close as possible when the sound stops. I can calculate the duration of the sound from the sound file header records but I cannot get the correct amount of speed to move the vertical bar so it will be at the right edge of the picturebox when the sound stops.
I have this code line that works somewhat but really starts to get out of sync as the sound plays on.....many times it way too slow and other times it's way too fast.
Speed of vertical bar = (picturebox width /10) / (sound data size in bytes \ average number of bytes per second)
In the sound file header record is a field that gives me the total number of bytes there are in the actual sound data and another field that gives me the average number of bytes per second that are sent to the player device. I believe that (sound data size in bytes \ average number of bytes per second) gives me the duration in seconds of the sound.
Some of the problems I have is I do not know what scale mode I should use for the picturebox, what timing interval I need to use for the timer control, whether I should divide picturebox width by 10 or 100 or what. I'm not even sure if the equation I posted is the best way to go or not.
Here's what I am up against.
I am trying to move a vertical bar horizontally across a picturebox at a precise as possible amount of time.
In this picturebox is a display of a sine wave from a sound file (a .wav). The duration of time varies from one sound file to another. I need this bar to start moving left to right at a given pace so that it will reach the right edge of the picturebox as close as possible when the sound stops. I can calculate the duration of the sound from the sound file header records but I cannot get the correct amount of speed to move the vertical bar so it will be at the right edge of the picturebox when the sound stops.
I have this code line that works somewhat but really starts to get out of sync as the sound plays on.....many times it way too slow and other times it's way too fast.
Speed of vertical bar = (picturebox width /10) / (sound data size in bytes \ average number of bytes per second)
In the sound file header record is a field that gives me the total number of bytes there are in the actual sound data and another field that gives me the average number of bytes per second that are sent to the player device. I believe that (sound data size in bytes \ average number of bytes per second) gives me the duration in seconds of the sound.
Some of the problems I have is I do not know what scale mode I should use for the picturebox, what timing interval I need to use for the timer control, whether I should divide picturebox width by 10 or 100 or what. I'm not even sure if the equation I posted is the best way to go or not.