Thumbnail Drawing

I’m trying to studing how a thumbnail is drawn in tracktion.
My goal is drawing a thumbnail that fits on my timeline where I can zoom and change the playhead behaviour (it can be vissualized with variable playhead velocity and so all beats with the same distance like softwares as cubase and the or constant playhead velocity and so beats variable according bpm changes as tracktion).

After a bit of studing on recording example that uses SmartThumbnail and behaviour on tracktion, I understand that the path is calculated by “TracktionThumbnail::CachedWindow” but before coding I’d like figure out:

  1. There’s some sort of zoom variable of Edit (that I’m not finding) that this class refers to in any way? so changing this zoom TracktionThumbnail emains hooked?

  2. x on CachedWindow::drawingChannel function is iterated by ±1 and it’s ok, but what’s the sample of the audio track founded? (this is related also to previous question by logic in my mind around this problem);

  3. when I warp the wave (like adding warp marker on clip in waveform) I immagine that source audio file is not modified but a reference (right?) and that to the TracktionThumbnail is not passed an audio file but an audio segment list, that right or I don’t understand the utility of AudioSegmentList? anyway how does TracktionThumbnail show waveform when it is warped internally with markers?

I’d like to understand how get the interested sample for my x, I have 2 funcs that up to now convert X->Time and Time->X taking into account about stuff I already told above and I know that finally I shold create my Own Thumbnail class, but TracktionThumbnail looks very solid and well done and I’d like to understand what is already done by it and where a start point to understand wich sample of the audio waveform it founds at X.

Really thank you in advice!

1 Like

FYI, TracktionThumbnail is basically the same as juce::AudioThumbnail, we just use a different algorithm to draw the thumbnail as a Path instead of vertical line sections.

Can you point to the bit of code this “zoom” variable is?

x is the pixel position. The time per pixel will depend on the size of the window being drawn and the time range specified in drawChannel

You have to split up the thumbnail in to sections with constant tempo and draw them separately. In Waveform we do this using WarpTimeManager::getWarpTimeRegions if a file is being warped with WarpTime.

It’s not so simple because it’s not only the zoom variable interested:
My Timeline could work in those ways:

  • Rappresentation of times constant and playhead constant
  • Rappresentation of times variable and playhead variable (at a higher bpm the distance between the separators increases)
  • Rappresentation of Bar&Beats constant and playhead variable
  • Rappresentation of Bar&Beats variable and playhead constant

Once said that I have also possibility to zoom in and out and to scroll my timeline.
To do this at the end I have two funcs called convertXToTime(float x) and convertTimeToX(double time) that takes count of all these settings and obviously of the bpm of each TempoSection.

My clips in timeline contains variable of type EditTimeRange and according to this timeRange I’d like to obtain information about sample that is shown every X pixels (for example if X is 1 i’ll iterate for each getSamplesAtTime( convertXToTime(hereThePixelSearched) ) ).

Ok about Warp, it makes sense

Sorry, I’m still not sure I understand the question there.
You need to draw your thumbnail in sections, not modify the contents of the internal thumbnail drawing code. Think of it like chopping up the thumbnail drawing in to lots of small, constant-tempo sections and draw them separately but at concurrent screen positions.

1 Like