# Open Waveform project in Tracktion Engine

**URL:** <https://forum.juce.com/t/open-waveform-project-in-tracktion-engine/56322>\
**Category:** Tracktion Engine\
**Created:** [May 21, 2023, 10:39pm UTC](https://forum.juce.com/t/open-waveform-project-in-tracktion-engine/56322 "2023-05-21T22:39:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamiepond](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jamiepond/32/12570_2.png) [@jamiepond](https://forum.juce.com/u/jamiepond)\
**Post date:** [May 21, 2023, 10:39pm UTC](https://forum.juce.com/t/open-waveform-project-in-tracktion-engine/56322/1 "2023-05-21T22:39:40Z")

</div>

Hi everyone!

I’ve been experimenting with saving / opening edits in tracktion and I’ve been trying to open projects from Waveform in a test tracktion project. However, the `source` field of each of the clips seems like it needs decoding. Looks like it’s in the format `projectId/clipId`.

When I load a project like this:

```cpp
void loadProject(const juce::File &file) {
    jassert(file.existsAsFile());
    edit = tracktion::loadEditFromFile(engine, file, tracktion::Edit::forEditing);
    jassert(edit != nullptr);
    editFileOps = std::make_unique<te::EditFileOperations>(*edit);
    edit->getTransport().setPosition(te::TimePosition::fromSeconds(0));
}

```

This works great if I manually change the `AUDIOCLIP` `source` to be a relative or absolute path in the edit file XML. However it won’t automatically load the encoded project file. I’ve seen in [this post](https://forum.juce.com/t/open-a-tracktion-7-project-in-a-multitrack-audioplayer-via-the-tracktion-engine/37722) that you need to use the `te::ProjectManager` in some way but I cannot find the incantation required to get that to work.

Any feedback or pointers would be much appreciated!

Thanks,

Jamie

---

<div class="post-metadata">

**Author:** ![jamiepond](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jamiepond/32/12570_2.png) [@jamiepond](https://forum.juce.com/u/jamiepond)\
**Post date:** [May 21, 2023, 11:17pm UTC](https://forum.juce.com/t/open-waveform-project-in-tracktion-engine/56322/2 "2023-05-21T23:17:25Z")

</div>

Ok I got this to work, but not sure if this is the most canonical or best way to do it? @dave96 @RolandMR

```cpp
    void loadProject(const juce::File &file) {
        jassert(file.existsAsFile());
        auto tempProject = te::ProjectManager::TempProject{engine.getProjectManager(), projectFile, false};
        auto project = tempProject.project;
        jassert(project != nullptr);
        const auto numProjectItems = project->getNumProjectItems();
        jassert(numProjectItems > 0);
        auto projectItemId = project->getProjectItemID(0);
        const auto vt = tracktion::loadEditFromFile(engine, file, projectItemId);
        edit = std::make_unique<te::Edit>(engine, vt, te::Edit::forEditing, nullptr, te::Edit::getDefaultNumUndoLevels());
        jassert(edit != nullptr);
        editFileOps = std::make_unique<tracktion::EditFileOperations>(*edit);
        edit->getTransport().setPosition(tracktion::TimePosition::fromSeconds(0));
    }

```

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [May 23, 2023, 11:47am UTC](https://forum.juce.com/t/open-waveform-project-in-tracktion-engine/56322/3 "2023-05-23T11:47:06Z")

</div>

I think that will work but you’ll need to keep the Project alive whilst using the Edit or the file resolver won’t work. It depends if you want to go back and forth between the two but you might be better off doing a conversion pass on all the audio clips getting the `SourceFileReference`, getting the path (via Project resolution) and then setting it to `setToDirectFileReference` to create a relative path.

* * *

One other small thing, `EditFileOperations` is lightweight so you can just create it on the stack when required, like `EditFileOperations (*edit).save (...)`

One final thing, `TimePosition` is constructible from a std::chrono so if you have a `using namespace std::literals;` somewhere in your headers, you can write positions like `edit->getTransport().setPosition(0s)` which I quite like.
