createEditForPreviewingClip- How is it used?

I would like to preview a clip from an edit and it seems like createEditForPreviewingClip is what I need. Can I get some pointers on how it’s used?


Just call that method passing the Clip you would like to preview.
It will return a new Edit object which you can play back which contains only a copy of that clip you passed in.

We use it in Waveform for previewing just a clip on a track which effectively gets rid of any other track contents.

1 Like

I’m obviously still missing something. I’ve tried the following:

auto ped = ed->createEditForPreviewingClip(*this->clip);
auto ptp = &ped->getTransport();

I’m getting no playback :sob:

At what time is your clip located? You may need to set the transport position to inside the clip boundaries.

And what type of Clip is it? (IIRC this can only be used for audio clips, not MID or Step clips).

It’s at the start of the edit on the first AudioTrack. I’ve tried:

if (auto wc = dynamic_cast<te::WaveAudioClip*> (clip.get()))
auto ped = ed->createEditForPreviewingClip(*wc);
auto ptp = &ped->getTransport();

If you change that to:

if (auto wc = dynamic_cast<te::WaveAudioClip*> (clip.get()))
    auto ped = ed->createEditForPreviewingClip (*wc);
    auto& ptp = ped->getTransport();
    ptp.setCurrentPosition (0.0); (false);

Does that work?
(I don’t think Edits get automatically attached to the DeviceManager).

Still nothing unfortunately.

Have you got an example that I could replicate the problem with?
Maybe as a PIP?

I’ll have to make one…

@ToneCre8 were you able to figure this out? I need to implement something similar.

Does the following work?

            previewEdit = Edit::createEditForPreviewingClip (clip);

            transport = &previewEdit->getTransport();

I just tried it and no I’m not getting any playback when I do “transport->play (false)” afterwards

after digging in and looking at the edit object being returned from “createEditForPreviewingClip” I have discovered that the clip inside that new edit has a sourceLength of 0, while the clip i gave to that function call did not, and I think that may be why I’m not getting any playback from the new edit. It doesn’t seem to be getting the source file correctly…but I’m at a loss as to why

the preview edit is destroyed before it has a chance to play. If you have a member
std::unique_ptr<te::Edit> previewEdit
it works.