SUMMARY="A library to adjust the sound tempo, pitch and playback rate"
DESCRIPTION="SoundTouch is an open-source audio processing library for \
changing the tempo, pitch and playback rates of audio streams or audio files. \
The library additionally supports estimating stable beats-per-minute rates for \
audio tracks.

- Tempo (time stretch): Changes the sound to play at faster or slower tempo \
than originally without affecting the sound pitch.
- Pitch (key) : Changes the sound pitch or key while keeping the original \
tempo (speed).
Playback Rate : Changes both tempo and pitch together as if a vinyl disc was \
played at different RPM rate."
HOMEPAGE="https://www.surina.net/soundtouch/"
COPYRIGHT="2001-2019 Olli Parviainen"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://gitlab.com/soundtouch/soundtouch/-/archive/$portVersion/soundtouch-$portVersion.tar.bz2"
CHECKSUM_SHA256="992bba58ecda8c0a3a94cc9648ccebbb84fb6f4f8c1a90fbb4ec3817354ad40d"
SOURCE_DIR="soundtouch-$portVersion"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="1.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVersionCompat="$portVersion compat >= ${portVersion%.*}"

PROVIDES="
	libsoundtouch$secondaryArchSuffix = $portVersionCompat
	cmd:soundstretch$commandSuffix = $portVersion
	lib:libSoundTouch$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libsoundtouch${secondaryArchSuffix}_devel = $portVersionCompat
	devel:libSoundTouch$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libsoundtouch$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage libsoundtouch$secondaryArchSuffix \
	"$commandBinDir"/soundstretch \
	"$libDir"/libSoundTouch.so.$libVersion

BUILD()
{
	mkdir -p config/m4
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir"
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f "$libDir"/*.la

	prepareInstalledDevelLibs libSoundTouch
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$dataDir" \
		"$developDir"
}

TEST()
{
	make check
}
