Waveform display

This forum is for developers of Rack Extensions to discuss the RE SDK, share code, and offer tips to other developers.
Post Reply
User avatar
pongasoft
RE Developer
Posts: 478
Joined: 21 Apr 2016
Location: Las Vegas
Contact:

10 Jan 2021

I am interested in building an interface that displays a waveform (representing the file that was loaded) like Grain does


Screen Shot 2021-01-10 at 07.57.05.png
Screen Shot 2021-01-10 at 07.57.05.png (88.74 KiB) Viewed 1001 times


I do know how to build the content of the waveform (meaning from the data loaded, I know how to generate the array of points that represents the waveform since this is something I did for my SAM-SPL 64 VST plugin). What I am wondering is how to build such a widget in Reason.

I am sure it is a custom display but how is the data about the waveform itself fed into it? Does the custom display have access to the raw data of the file loaded and then can compute the waveform itself? Does the waveform need to be computed in the RT and then "sent" to the custom display? If that is the case how do you transfer such a large amount of data?

Thanks
Yan

User avatar
buddard
RE Developer
Posts: 1245
Joined: 17 Jan 2015
Location: Stockholm
Contact:

10 Jan 2021

In the RT layer you reduce the sample data to what’s needed to draw the waveform at the desired resolution.
Then you encode this data in an “RT String”, i e a string property in the RT scope, which is then read by the custom display..
An RT string can be up to 2048 bytes in size, which should be more than enough for this purpose.

It’s not 100% smooth sailing though, there are some issues with property updates “getting lost” without letting you know about it, so you can end up drawing stale data unless you take precautions in your code.

User avatar
rcbuse
RE Developer
Posts: 1176
Joined: 16 Jan 2015
Location: SR388
Contact:

10 Jan 2021

I try to do as little as possible in the display.lua code. I want the rt string to basically have only an array of x length and y values. In the C++ code, whenever I load long samples I run over them generating a 'max' value for a given chunk of samples and use that for the display.

To add to what buddard said about losing updates. I've found a good strategy is to send the rt update a few times, each time doubling the interval. Like, send at 0ms, repeat at 50ms, repeat at 100ms, repeat at 200ms, repeat at 400ms, repeat at 800ms, repeat at 1600ms. If there is new data, send update and reset the counter. I've also had cases where multiple string properties would be out of sync, where I had string parameters being generated from display.lua and then strings coming out of realtime and had to use rolling counters on updates and only accept the invalidate when those counters were equal.

User avatar
pongasoft
RE Developer
Posts: 478
Joined: 21 Apr 2016
Location: Las Vegas
Contact:

11 Jan 2021

I see. Thanks for the info. I remember now having read "horror stories" in the forum about RT string. I am not entirely sure why this is a "feature" and that is not being addressed by the devs...

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests