summaryrefslogtreecommitdiff
path: root/libs/ardour/test/test_needing_playlist_and_regions.cc
blob: 4e0e42c67b90f9ffc4dfea61c55f0c86b758e763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "pbd/filesystem.h"
#include "ardour/playlist_factory.h"
#include "ardour/source_factory.h"
#include "ardour/region.h"
#include "ardour/region_factory.h"
#include "ardour/sndfilesource.h"
#include "test_needing_playlist_and_regions.h"
#include "test_globals.h"

using namespace std;
using namespace PBD;
using namespace ARDOUR;

void
TestNeedingPlaylistAndRegions::setUp ()
{
	TestNeedingSession::setUp ();

	/* This is important, otherwise createWritable will mark the source immutable (hence unwritable) */
	unlink ("libs/ardour/test/test.wav");
	string const test_wav_path = "libs/ardour/test/test.wav";
	_playlist = PlaylistFactory::create (DataType::AUDIO, *_session, "test");
	_source = SourceFactory::createWritable (DataType::AUDIO, *_session, test_wav_path, "", false, Fs);

	/* Write a staircase to the source */

	boost::shared_ptr<SndFileSource> s = boost::dynamic_pointer_cast<SndFileSource> (_source);
	assert (s);

	int const signal_length = 4096;
	
	Sample staircase[signal_length];
	for (int i = 0; i < signal_length; ++i) {
		staircase[i] = i;
	}

	s->write (staircase, signal_length);
	
	PropertyList plist;
	plist.add (Properties::start, 0);
	plist.add (Properties::length, 100);
	for (int i = 0; i < 16; ++i) {
		_region[i] = RegionFactory::create (_source, plist);
	}
}

void
TestNeedingPlaylistAndRegions::tearDown ()
{
	_playlist.reset ();
	_source.reset ();
	for (int i = 0; i < 16; ++i) {
		_region[i].reset ();
	}

	TestNeedingSession::tearDown ();
}