Insert custom AudioTrack

Hi, I created some subclasses of AudioTrack, because I want give them some extra-properties, but now I don’t know how to add them in the edit, I would like to implement something like this, but obviously for the works done in edit or trackList I can’t (I put this in a Edit subclass “MyEdit”):

CustomTrack::Ptr insertNewCustomTrack(String named, TrackInsertPoint insertPoint, SelectionManager* sm)
    {
        if (auto newTrack = insertNewTrack(insertPoint, MyNamespace::IDs::CUSTOMTRACK, sm))
        {
            newTrack->pluginList.addDefaultTrackPlugins (false);
            (!named.isEmpty()) ? newTrack->setName(named) : newTrack->setName("newCustomTrack");
            return dynamic_cast<CustomTrack*> (newTrack.get());
        }
        return {};
    }

which could be the best way to achieve something like that?

@RolandMR or @dave96, sorry for tagged you, I don’t want to bother you, but I don’t know how find a good solution for this.

What do you think about?

Really thank you in advice and sorry again for trouble!

Do they need to be a new track type?

For each of the items in the Engine you can access the ValueTree state so you can add your own custom properties there. Does that do what you need?

1 Like

Not only, they should do extra stuff in their init and also having other methods and properties.

Without inheriting audiotrack code of items that manage those tracks would become unmanageable and redundant…

I think I’ll need a more concrete explanation of what you’re trying to do before I can advise better.

In our experience it’s best to try and not create new types for all the tracks as it greatly complicates the audio graph logic.

Usually, if you need extra functionality, you can do this in a layer above the Engine and add you functionality there. For example, in your UI code.

What is it you need to add that the Engine needs to know about?

1 Like