summaryrefslogtreecommitdiff
path: root/test/loop.c
blob: 3778eefe30ac9671b76626991885355fc7d161ca (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
#include <audiofile.h>

int main (int argc, char **argv)
{
	AFfilehandle	file;
	AFfilesetup	setup;
	int		markerIDs[] = {1, 2, 3, 4};
	int		loopIDs[] = {1, 2};
	short		frames[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

	setup = afNewFileSetup();
	afInitFileFormat(setup, AF_FILE_AIFF);

	afInitMarkIDs(setup, AF_DEFAULT_TRACK, markerIDs, 4);
	afInitMarkName(setup, AF_DEFAULT_TRACK, 1, "sustain loop start");
	afInitMarkName(setup, AF_DEFAULT_TRACK, 2, "sustain loop end");
	afInitMarkName(setup, AF_DEFAULT_TRACK, 3, "release loop start");
	afInitMarkName(setup, AF_DEFAULT_TRACK, 4, "release loop end");

	afInitLoopIDs(setup, AF_DEFAULT_INST, loopIDs, 2);

	file = afOpenFile(argv[1], "w", setup);

	afWriteFrames(file, AF_DEFAULT_TRACK, frames, 5);

	afSetMarkPosition(file, AF_DEFAULT_TRACK, 1, 0);
	afSetMarkPosition(file, AF_DEFAULT_TRACK, 2, 2);
	afSetMarkPosition(file, AF_DEFAULT_TRACK, 3, 4);
	afSetMarkPosition(file, AF_DEFAULT_TRACK, 4, 5);

	afSetLoopStart(file, AF_DEFAULT_INST, 1, 1);
	afSetLoopEnd(file, AF_DEFAULT_INST, 1, 2);
	afSetLoopStart(file, AF_DEFAULT_INST, 2, 3);
	afSetLoopEnd(file, AF_DEFAULT_INST, 2, 4);

	afCloseFile(file);
}