RectangleList

Hi Guys,

I am working on the multiple real time audio signal plots and facing the performance problems. In the plot, I am using the rectlist to depict the signal like the one available in audioLiveScrolling in Juce demo.  But, instead of moving the entire rectlist lefwards for every sample, I am using the vertical line to show the current sample and once it reaches the end, it traverses back from left.

 

Because of the only the current few rectangle heights needs to be changed according the new arriving samples. But I couldnt find any functions in the rectlist to update the parameters of only specific rectanlges. Am I missing something?? Could you guys please let me know is it possible to change specific rectangles in the rectlist??

 

So, please let me know your suggestions is there any other efficient way to implement this which improves the performance since in realtime im plotting 4 channels, their frequency domain and their spectrogram. Because of that, its using too much cpu. 

 

Please let m eknow your suggestions.

 

Best Regards,

Ranjith

 

 

Could you explain what you need to do a little more? For instance, what are you trying to apply on individual Rectangles? Also, do you really need a RectangleList (do you need to apply operations on all Rectangles)? If you need to access a single Rectangle in the list, you can use RectangleList::getRectangle(). If you don't actually need the features of a RectangleList, you could just use a vector or Array. 

I have a waveform in the rectanglelist with each sample(min and max of a audio block) represented in rectangles. The audio data is real time signal from sound card and I am re-painting the plot continously every 100 ms.

 

Since I am plotting again and again continuously, I dont want to change the whole waveform(rectangleList) and instead change only one sample(rectangle) in the rectangleList for every audio block. As you have mentioned, I tried to use the getRectangle function to extract the rectangle at a particular index and change its height(I am change only the height and not its position since I am using the vertical line in the waveform to depict the current sample and so I am not moving all the rectangles left for every audio block). But, when I change the rectangle paramters, its is not getting reflected in the rectangleList.

Hopefully, I explained clearly. Please suggest me what can be done in this case. Also, if not rectangleList, please suggest me some other approach which is good in performance for repainting continuously.  

Ahh, I see... getRectangle() returns by value so you can't modify or assign to the original value in the container. Sorry about that. You could probably do some iterator stuff, but that doesn't seem like a very good idea for your needs. I would just store them in a std::vector<Rectangle> if all you need to do is store Rectangles in a container. Perhaps you could try other containers if you'd like and do some benchmarking to see which is faster. std::vector is the "default" container so I'd probably start with that. It doesn't seem like you actually need a RectangleList.

I will try all your suggestions.  I feel like I need to use rectangleList since Jules had said that if we want to plot the many rectangles, it is good to use the rectangleList which is faster!!!

FWIW RectangleList will be either faster or the same as a std::vector, depending on which compiler you're using.

Yeah, RectangleList is the right thing to use for this kind of stuff, but you probably just want to create a temporary one each time you need to draw it, and actually store your live data window in some other more appropriate, non-graphical format. That's what the juce scrolling waveform viewer component does, so use that as an example.

Yeah i thought it would be. I just figured that if you're trying to just store Rectangles and access/modify them individually,  std::vector or juce::Array would be an easier choice.