How are tracks created (correctly) with Tracktion?

hey, just a basic? question… how do you correctly create tracks in Tracktion?

what im looking to create is a VERY basic tracklist/playlist that has a collection of audio and midi tracks with clips.

im not 100% sure how this works; my understanding is that Track is the shell and Clips are the content?

I can create a new say AudioTrack like:

auto track = new te::AudioTrack{ edit, te::createEmptyEdit(engine) };

then I found i can’t do what i want, or atleast what i’ve tried hasn’t worked the way i’d like… with just this.
through some forum searching i found topics in tracktion that dont relate specifically to this but i found this method:

auto* clip = dynamic_cast<te::WaveAudioClip*>(track);

this compiles fine, but if i try to access any of clip methods i get a nullptr exception, so clearly i am not setting something correctly.

if it wasnt clear what im trying to achieve from above; i am trying to re-create a very simple component like this:

To create a track, you must not only create it, but also add it to the edit. The following will add a new track at the end and return a pointer to it:

auto track = insertNewAudioTrack (TrackInsertPoint (nullptr, getTopLevelTracks (*this).getLast()), nullptr);

Then you need to insert clips into the track:

track->insertWaveClip ("name", src, pos, false)

Check out the RecordingDemo for a basic example of what you are trying to do.

1 Like

Ah, the edit! Of course. Thanks for this!