Marking Audio Data, DrawChannels, Paint Help


Hello guys and Happy New Year!
I’m pretty new at JUCE and I got a problem with something. In my project I have a component, which draws me channels of my audio (using AudioThumbnail::drawChannels()). What i wanna do is add a possibility to mark audio data, like it’s possible in DAWs (using mouse). I’ve made a new component for this. I’ve come up with something like this:

void paint(Graphics&g) override

void mouseDown(const MouseEvent & event)override

void mouseUp(const MouseEvent & event)override
	xUp = event.position.x;

void markAudio(Graphics&g)
	double diff = xUp - xDown;
	double duration = transportSource.getLengthInSeconds();
	const double positionDown = (xDown / getWidth()) * duration;
	const double positionUp = (xUp / getWidth()) * duration;
	const Rectangle<int> markBounds(xDown, 0, xUp, getHeight());
	thumbnail.drawChannels(g, markBounds, positionDown, positionUp, 1.0f);


        AudioTransportSource &transportSource;
        AudioThumbnail &thumbnail;
        double xDown, xUp;

Can u tell me if my thinking is right? What should i do to make it work? This code currently doesnt paint anything for me in my component.


Create a Range with a start and end point and have a couple of methods which converts samples to and from pixels… then repaint when required. make sure your Range has a limit of zero and length of the audio file.

I believe there may be code in the dRowAudio demo which may help you.