File hydrogen.spec of Package hydrogen

#
# spec file for package hydrogen
#
# copyright (c) 2025 munix9@googlemail.com
#

%define pkversion %(echo "%{version}" | cut -d~ -f1)
%define soversion %(echo "%{pkversion}" | tr . _)

# The use of librubberband2 is marked as experimental.
# Because the current implementation produce wrong timing!
# So long this bug isn't solved, please disable this option.
# If rubberband-cli is installed, the hydrogen rubberband-function
# will work properly as expected.
%bcond_with librubberband

Name:           hydrogen
Version:        2.0.0
Release:        0
Summary:        A Real-Time Drum Machine and Sequencer
License:        GPL-2.0-or-later
URL:            http://www.hydrogen-music.org/
Source0:        %{name}-%{version}.tar.gz
Patch0:         fix-CMakeLists_txt.patch
BuildRequires:  cmake
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  ladspa
BuildRequires:  ladspa-devel
BuildRequires:  ninja
BuildRequires:  pkgconfig
BuildRequires:  cmake(Qt6Core)
BuildRequires:  cmake(Qt6LinguistTools)
BuildRequires:  cmake(Qt6Network)
BuildRequires:  cmake(Qt6Svg)
BuildRequires:  cmake(Qt6Test)
BuildRequires:  cmake(Qt6Widgets)
BuildRequires:  cmake(Qt6Xml)
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(flac)
BuildRequires:  pkgconfig(jack)
BuildRequires:  pkgconfig(libarchive)
BuildRequires:  pkgconfig(liblo)
BuildRequires:  pkgconfig(libpulse)
BuildRequires:  pkgconfig(lrdf)
BuildRequires:  pkgconfig(portaudio-2.0)
BuildRequires:  pkgconfig(portmidi)
BuildRequires:  pkgconfig(raptor2)
BuildRequires:  pkgconfig(sndfile)
BuildRequires:  pkgconfig(zlib)
%if 0%{?suse_version} < 1600
BuildRequires:  gcc11
BuildRequires:  gcc11-PIE
BuildRequires:  gcc11-c++
%else
BuildRequires:  gcc-c++
%endif
%if %{with librubberband}
BuildRequires:  pkgconfig(rubberband)
%else
BuildRequires:  rubberband-cli
Requires:       rubberband-cli
%endif

%description
Hydrogen is a software synthesizer which can be used alone, emulating
a drum machine based on patterns, or via an external MIDI
keyboard/sequencer software.

It features a modular and graphical interface based on QT, has a
sample-based stereo audio engine, with import of sound samples in PCM
formats. Furthermore, a pattern-based sequencer with the ability to
chain patterns into a song. Up to 64 ticks per pattern with
individual level per event and variable pattern length are possible.
32 instrument tracks with volume, mute, solo, pan capabilities are
provided, and there is multi-layer support for instruments (up to 16
samples for each instrument). Human velocity, human time, pitch and
swing functions are implemented as well.

%package -n libhydrogen-core-%{soversion}
Summary:        Library essential for the hydrogen drum machine software

%description -n libhydrogen-core-%{soversion}
Hydrogen is a software synthesizer which can be used alone, emulating
a drum machine based on patterns, or via an external MIDI
keyboard/sequencer software.

This library is the core of hydrogen's operation.

%package -n libhydrogen-core-devel
Summary:        Development files and headers for libhydrogen-core
Requires:       libhydrogen-core-%{soversion} = %{version}
BuildArch:      noarch

%description -n libhydrogen-core-devel
These are the headers needed to develop apps that
link with libhydrogen-core.

%prep
%autosetup -p1

# fix "CMake Deprecation Warning"
sed -e 's/VERSION 3\.[0-9]/VERSION 3.10/' \
    -i cmake/rtclock/CMakeLists.txt cmake/sscanf/CMakeLists.txt \
	src/tests/CMakeLists.txt

%build
%define __builder ninja
export LADSPA_PATH=%{_libdir}/ladspa

%cmake \
%if 0%{?suse_version} < 1600
	-DCMAKE_C_COMPILER=gcc-11 \
	-DCMAKE_CXX_COMPILER=g++-11 \
%endif
	-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
	-DCMAKE_SKIP_RPATH:BOOL=ON \
	-DDISPLAY_VERSION_PIPELINE="%{version}" \
	-DWANT_DEBUG:BOOL=OFF \
	-DWANT_LIBARCHIVE:BOOL=ON \
	-DWANT_LIBTAR:BOOL=OFF \
	-DWANT_LRDF:BOOL=ON \
	-DWANT_PORTAUDIO:BOOL=ON \
	-DWANT_PORTMIDI:BOOL=ON \
%if %{with librubberband}
	-DWANT_RUBBERBAND:BOOL=ON \
%endif
	-DWANT_SHARED:BOOL=ON \
	-DWANT_QT6:BOOL=ON

%cmake_build

%install
%cmake_install

%fdupes %{buildroot}%{_datadir}/%{name}

%check
desktop-file-validate \
	%{buildroot}%{_datadir}/applications/org.hydrogenmusic.Hydrogen.desktop

%files
%license COPYING
%doc AUTHORS CHANGELOG.md README.md
%{_bindir}/%{name}
%{_bindir}/h2cli
%{_bindir}/h2player
%{_datadir}/%{name}
%{_datadir}/applications/org.hydrogenmusic.Hydrogen.desktop
%{_datadir}/icons/hicolor/scalable/apps/org.hydrogenmusic.Hydrogen.svg
%{_datadir}/metainfo/org.hydrogenmusic.Hydrogen.metainfo.xml
%{_mandir}/man1/%{name}.1%{?ext_man}

%files -n libhydrogen-core-%{soversion}
%{_libdir}/libhydrogen-core-%{pkversion}.so

%files -n libhydrogen-core-devel
%{_includedir}/%{name}

%changelog
openSUSE Build Service is sponsored by