How can I change the BPM without affecting the insertWaveClip?

How can I keep the original audio without affecting stretching or pitch?

this all code in Constructor:

tempoSlider.setRange (30.0, 200.0, 0.1);
tempoSlider.setValue (edit.tempoSequence.getTempo (0)->getBpm());
tempoSlider.onValueChange = [this]
{ edit.tempoSequence.getTempo (0)->setBpm (tempoSlider.getValue()); };

//=========================================

float beatWidth = 30;

File file ("D:/Samples Pack/Kick.wav");

if (file.existsAsFile())
{
    te::AudioFile audioFile (engine, file);
    double lengthWave = audioFile.getLength();

    if (auto track = EngineHelpers::getOrInsertAudioTrackAt (edit, 0)) {
        auto& ts = edit.tempoSequence;
        bpmPerSeconds = bpmWClip / 60;

        te::BeatRange beatRange (
            te::BeatPosition::fromBeats (0),
            te::BeatPosition::fromBeats (beatWidth * bpmPerSeconds * lengthWave));
        ClipPosition position = createClipPosition (ts, beatRange);

        wClip = insertWaveClip (*track, {}, file, position, DeleteExistingClips::no);
        wClip->setLength (wClip->getSourceLength(), false);

        if (wClip != nullptr)
        {
            //=========================================
            
            wClip->setAutoTempo (false);
            wClip->setAutoPitch (false);
            wClip->setUsesProxy (false);
            wClip->setTimeStretchMode (te::TimeStretcher::defaultMode);

        }

    }

    DBG ("File exist!");
}

I think you want

            wClip->setTimeStretchMode (te::TimeStretcher::disabled);

I tried it and it’s still the same. I want it to be like in FLS.

That is time-stretching as you’re changing the tempo and keeping the same pitch.

What you’re talking about (I think) is that the transport is staying at the same time position when you want it to stay at the same beat position when you change the tempo right?

1 Like