2#include "trkn/tracktion.hh"
12static tracktion::WaveAudioClip::Ptr
13load_audio_file_as_clip (tracktion::Edit &edit,
const juce::File &file)
15 edit.ensureNumberOfAudioTracks (1);
16 if (
auto track = tracktion::getAudioTracks (edit)[0]) {
17 tracktion::AudioFile audioFile (edit.engine, file);
18 if (audioFile.isValid())
21 { { {}, tracktion::TimeDuration::fromSeconds (audioFile.getLength()) }, {} },
false))
27template<
typename ClipType>
static typename ClipType::Ptr
28loop_around_clip (ClipType &clip)
31 auto &transport = clip.edit.getTransport();
32 transport.setLoopRange (clip.getEditTimeRange());
33 transport.looping =
true;
34 transport.setPosition (0s);
39test_audio_sample_load()
41 ProjectImplP project = ProjectImpl::create (
"AudioSampleTest");
46 TASSERT (project->name() ==
"AudioSampleTest");
47 TASSERT (project->bpm() == 120.0);
52 auto clip = load_audio_file_as_clip (*project->edit_,
sampleFile);
54 loop_around_clip (*clip);
55 project->edit_->getTransport().ensureContextAllocated();
57 project->_deactivate();
String getFileNameWithoutExtension() const
The Anklang C++ API namespace.
std::string anklang_runpath(RPath rpath, const String &segment)
Retrieve various resource paths at runtime.
#define TASSERT(cond)
Unconditional test assertion, enters breakpoint if not fullfilled.
#define TEST_ADD(fun)
Register a function to run as part of the unit test suite.