Hi all,
I create a new JUCE GUI project with ProJuce linking tracktion_engine (cloned with git) and it seams integrated correctly.
I have my MainComponent.h like this:
private:
std::unique_ptr<tracktion::engine::Engine> engine;
std::unique_ptr<ProjectSelectionComponent> projectSelection;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
Then my MainComponent.cpp:
#include "tracktion_engine/tracktion_engine.h" corretto
MainComponent::MainComponent()
{
engine = std::make_unique<tracktion::engine::Engine>(ProjectInfo::projectName);
projectSelection = std::make_unique<ProjectSelectionComponent>(*engine);
addAndMakeVisible(*projectSelection);
projectSelection->setListener(this);
setSize(800, 480);
}
Then in ProjectSelectionComponent.h I have:
private:
te::Engine& engine;
te::Edit edit { engine, te::Edit::EditRole::forEditing };
te::TransportControl& transport { edit.getTransport() };
and in ProjectSelectionComponent.cpp I have this:
ProjectSelectionComponent::ProjectSelectionComponent(te::Engine& eng)
: engine(eng)
{
auto& deviceManager = engine.getDeviceManager().deviceManager;
deviceManager.getCurrentDeviceTypeObject()->scanForDevices();
auto result = deviceManager.initialiseWithDefaultDevices(0, 2);
if (result != "") {
DBG("Attempt to initialise default devices failed!");
}
edit.ensureNumberOfAudioTracks(1);
auto track = te::getAudioTracks(edit)[0];
DBG("Track name: " + juce::String(track->getName()));
juce::File audioFile("correct_path/sample2.wav");
if (!audioFile.existsAsFile())
{
DBG("Audio file not found!");
}
else
{
const tracktion::TimeRange fourBarTimeRange(
0s,
edit.tempoSequence.toTime({ 4, tracktion::BeatDuration() })
);
auto clip = track->insertNewClip(te::TrackItem::Type::wave, "Audio Clip", fourBarTimeRange, nullptr);
if (clip == nullptr)
DBG("Failed to insert audio clip!");
auto& transport = edit.getTransport();
transport.setPosition(0s);
transport.setLoopRange(clip->getEditTimeRange());
transport.looping = true;
transport.play(false);
}
I see Track Name: Track 1 so it seams that the track is correctly inizialized but I don’t ear anything. Is that wrong?
Any suggestion? Sorry I’m a little bit noob and I don’t find a good starting guide.
Thanks