Hi, sorry for the title, didn’t know what to put.
My question is mostly theoretical rather than actual code.
I made a simple canvas where a user can draw a line (as image below).
Now, assuming that vertical axis corresponds to frequencies in range (0-n) and horizontal axis is time (0-nseconds) I’d like to implement a player that plays that line of frequencies (sine oscillator is more than enough for now) in the correct time.
- I can add points in the canvas (and each point has a set frequency), but how do I calculate the exact frequency to play for each point the line is made of?
- Should I first calculate all the frequencies (on the line) and store them in a buffer to be played back later, or just calculate everything in real time?
- I understand the Lerp function generates values between 2 points at specific interval. Could it be useful in this situation? I think it could work since the lines are straight but I will have many points. Also I need to make sure the values generated by the Lerp are the same as those the line is made of (so to make sure the line is actually representing the sound that is played). In addition, the line might not be straight in the future (I might add possibility to bend it). In this case, the Lerp might not work?
- If I calculate all these values and store them in a buffer (array I guess), how do I play them “smoothly”?
- How can I add a vertical player line that moves left to right and should, obviously, synced with the sound position.
In general I’m asking about how to approach this, sorry for the broad question.