I have a small test project on Linux that uses Tracktion Engine with the command line application template. The goal is just to play a loop for some time, pause playback and then resume playback from the current position. The problem is that the sound is always played from start. Is that behavior intended?
Here is the code from Main.cpp:
#include <JuceHeader.h>
#include <iostream>
namespace te = tracktion;
int main (int argc, char* argv[])
{
//Setup engine and edit with 1 track
te::Engine engine(ProjectInfo::projectName);
te::Edit edit(engine, te::createEmptyEdit(engine), te::Edit::EditRole::forEditing, nullptr, 0);
edit.ensureNumberOfAudioTracks(1);
//Setup transport for looping
te::TransportControl& transport = edit.getTransport();
transport.looping = true;
//Load sound from file to track 0 as clip and loop around that clip
juce::File loopFile(PATH-TO-SOME-WAV-FILE);
te::AudioFile audioFile(edit.engine, loopFile);
te::AudioTrack* track = te::getAudioTracks(edit)[0];
juce::ReferenceCountedObjectPtr<te::WaveAudioClip> newClip = track->insertWaveClip (loopFile.getFileNameWithoutExtension(), loopFile,
{ { {}, te::TimeDuration::fromSeconds (audioFile.getLength()) }, {} }, false);
transport.setLoopRange(newClip->getEditTimeRange());
//User presses buttons to trigger actions: play, stop, play, exit
std::cout << "Play";
std::cin.get();
transport.play(false);
std::cout << "Stop";
std::cin.get();
transport.stop(true, false);
std::cout << "Play";
std::cin.get();
transport.play(false); //HERE THE SOUND IS PLAYED FROM BEGINNING, NOT FROM POSITION WHERE STOPPED
std::cout << "Exit";
std::cin.get();
return 0;
}
JuceHeader and AppConfig:
JuceHeader.h (2.0 KB)
AppConfig.h (10.3 KB)