On Tue, 2023-03-28 at 09:29 +0200, Simon Iten wrote:
yeah, the workaround with array_set causes clicks in the recording
The visual representation of arrays whose number of samples exceeds the number of visual pixels suffers from aliasing so that resulting visual waveform looks pretty random sometimes. Another issue is that the amount of data is pretty large in the table holding audio data, much larger than what is necessary for a proper visual representation. This lead me to create an abstraction [rh_wavedisplay] that translates original audio data from a table to a smaller table that is only used for visual representation. Because the display table is much smaller, updating it is not so costly and it allows for neat tricks like zooming and panning. Also, you can use it to update the display during the recording to an audio table. See example in the link:
https://netpd.org/~roman/tmp/wavedisplay_example.zip
The visual table has twice the points of its visual width in pixels so that the minimum and maximum of the segment of audio data covered by one display pixel is displayed. This creates a solid black waveforms for audio data that would otherwise be displayed with weird aliasing.
Note: there is a bug where some peaks of the previous display are still apparent in the updated display. If some brave person knows how to fix this, that would be more than welcome.
Roman