I was trying to create a sliding window on a signal. I have implemented the windowing function on a precalculated data from a csv file but when I was trying to do the same for a real time data where we dont have data available for some time and have to wait until we have enough data window it. To understand this, I have created a fake signal using a sine wave as shown in my sketch and try to implement a windowing function but I think my code is not correct. As I said there are no errors but I feel that my code isn’t doing what it suppose to do. I am saving the part of the signal into a buffer which represents the data from the captured using window function.
The buffer part is in red, and signal is in blue.
Here is the visualization in P5JS Sketch Link