Tracktion Engine: Set custom directory for recordings

Hi,

I’d like to set a custom directory for the recordings when using tracktion engine. Recordings are commonly put in the tracktion project folder, but I’d prefer some more flexibility. One of the reasons is that I’m using Tracktion inside a plug-in and so I am not creating a tracktion Project. (the state and everything is stored inside the DAW project, not inside an edit or tracktion project file). I cannot find a way to set a custom directory for the recordings.

Thanks,
Jelle

It’s not documented yet but what you’re looking for is WaveInputDevice::setFilenameMask.

If you have a look at expandPatterns in tracktion_WaveInputDevice.cpp you can see how this is used. You can set a specific path or use the patterns just above the function for string replacements.

2 Likes

Thank you Dave.
I’m really impressed with the tracktion engine but there is so more to explore.

I found out that I can also manually set editFileRetriever to a custom directory and the recordings will be placed in there.

However, related to this I wondered if it is possible to use this editFileRetriever or your proposed technique and have tracktion store the file names in the state as relative paths instead of absolute paths. This makes it possible to copy the project from one computer to another if the the user just manually provides tracktion with the path to all the media. Perhaps I should consider using tracktion Project instead and have it take care of all of that…?

If you use Project, the paths will be stored as ProjectItemIDs and have to be resolved by the project.

If you’ve set an editFileRetriever, the file paths stored should be relative to the edit file. Is that not what you’re seeing?

Tbh this is one of the problems with plugins that store files. There’s no good way to get access to the project folder of the hosting DAW.

I’m okay if the user manually has to suggest the plug-in a directory to store the media.

I tried setting editFileRetriever but it seems like the files are still stored as absolute paths. I will double check to make sure.

I really like the idea of ProjectItemID’s though… ;). It’d be nice if I can use something similar without requiring a Project for instance if I could manually compose some id map that the edit uses to resolve id’s.

Update:
The files after setting editFileRetriever are indeed stored as relative paths. My mistake.

Well isn’t that kind of the same as a relative path?

Step through SourceFileReference::setToDirectFileReference when a file is saved or imported to see which path is taken.

I mean for my application it’d be useful to reference files by ID’s. In general I like the idea of using ID’s for referencing files instead of providing the file path manually. This way I can in theory change the file that tracktion uses by just changing the ID to file mapping. For my application, this is useful, but I’m wondering if it’s possible without using a Project.

It’s not really possible without a Project and in our experience the extra burden of having to manage a Project and make sure all your references stay intact etc. isn’t worth.

If you have a local file, you can always change the data of the file to update it. Or it’s straightforward to iterate all clips that use a source file and change them.

1 Like

@dave96

To tell the engine to save paths relatively, I set editFileRetriever. The problem is that a .tracktionedit file is created on the users computer. Because I’m trying to implement this as a plug-in, this is not ideal.

Is there a way to tell the engine to not save the .tracktionedit file or is there an alternative way to save files as relative paths?

Is is a problem if the .tracktionedit file is stored on the users computer? Or is it just there doing nothing…?

I’ve not really thought it through but I guess you could just save the Edit ValueTree state in the plugin’s state when getStateInformation is called?

Then you could just use Edit::filePathResolver to resolve the file paths to a folder on the user’s machine?