Warp example?


Is there any example of how to use warp markers?

I’m trying to insert some markers into a clip but that causes the audio file to start from the beginning every time a marker is hit, rather than the audio being stretched.

This is my attempt:

    auto clip = EngineHelpers::loadAudioFileAsClip(*track, file, pos);
    clip->setAutoPitch (false);
    clip->setAutoTempo (false);
    clip->setTimeStretchMode (te::TimeStretcher::defaultMode);
    auto& wtm = clip->getWarpTimeManager();
    wtm.insertMarker(te::WarpMarker(1.0, 1.0));
    wtm.insertMarker(te::WarpMarker(2.0, 2.5));
    wtm.insertMarker(te::WarpMarker(3.0, 3.0));
    wtm.insertMarker(te::WarpMarker(4.0, 4.5));
    wtm.insertMarker(te::WarpMarker(5.0, 5.0));


Anything? I would really like to do some warping! :smiley:

Two things spring initially to mind:

  1. Do you have a timestretch algorithm enabled by way of config flags? Current options are Elastique ($) or the built-in SoundTouch (more on this in the near future…)
  2. Are you trying to do this synchronously? The warping will trigger a file render that needs time to render and then update the play graph. Are you giving this time to happen?

Do you have a timestretch algorithm enabled by way of config flags?

Yes, SoundTouch is enabled. (At first, before I had any timestretch algorithm enabled, the rendered audio files contained really strange garbage :slight_smile: )

Are you trying to do this synchronously?

No, I just load a file into a clip and place warp markers and later start playback. The audio that is played back matches the content of the rendered audio file (i.e. the content of the rendered audio file is also bad).

As far as I can tell what you’ve got is correct.
I’ve just tested this in Waveform and end up with the following XML:

      <WARPTIME warpEndMarkerTime="4.234916666666667" timecodeFormat="beats"
                viewleft="0.0" viewright="4.234916666666667">
          <WARPMARKER sourceTime="0.0" warpTime="0.0"/>
          <WARPMARKER sourceTime="0.533062496687906" warpTime="1.5625"/>
          <WARPMARKER sourceTime="4.234916666666667" warpTime="4.234916666666667"/>

I presume yours is similar? The only marker I added explicitly was the middle one. I think the end ones get added automatically.

The only thing I can think of is that SoundTouch isn’t behaving itself. I’ve actually refactored this code over the past couple of days which might improve SoundTouch performance, I just need to get the final tweaks finished up…

Yes, my clip looks similar:

<AUDIOCLIP name="c" start="4.0" length="4.969070294784579" offset="0.0"
           id="1080" source="/Users/admin/Music/c.wav" sync="0" elastiqueMode="4"
           pan="0.0" colour="ffffaa00" warpTime="1" autoPitch="0" autoTempo="0">
  <LOOPINFO rootNote="-1" numBeats="4.96907029478458" oneShot="0" denominator="4"
            numerator="4" bpm="0.0" inMarker="0" outMarker="-1"/>
  <WARPTIME warpEndMarkerTime="4.96907029478458">
      <WARPMARKER sourceTime="0.0" warpTime="0.0"/>
      <WARPMARKER sourceTime="1.0" warpTime="1.0"/>
      <WARPMARKER sourceTime="1.5" warpTime="2.0"/>
      <WARPMARKER sourceTime="3.0" warpTime="3.0"/>
      <WARPMARKER sourceTime="3.5" warpTime="4.0"/>
      <WARPMARKER sourceTime="4.96907029478458" warpTime="4.96907029478458"/>

Is there any chance you could make this in to a PIP like the example projects so I can test it quickly?