class FluidSynth < Formula desc "Real-time software synthesizer based on the SoundFont 2 specs" homepage "https://www.fluidsynth.org" url "https://github.com/FluidSynth/fluidsynth/archive/refs/tags/v2.5.2.tar.gz" sha256 "1dcb13308b3aa383db658c60a7b63d73d0ff4601ccee589582ba7a816475410e" license "LGPL-2.1-or-later" head "https://github.com/FluidSynth/fluidsynth.git", branch: "master" bottle do sha256 cellar: :any, arm64_tahoe: "6f171d112d81af040767534a9923100f105fd610f21ad11064df6aa2c8e96061" sha256 cellar: :any, arm64_sequoia: "05f2c73344154dd16b4e9ef7aac7e33fd5bc6eb4a3e520254000e58aaad6d523" sha256 cellar: :any, arm64_sonoma: "8df94fba76b75cb4ba91e890e03018ede154c6789188dc12c7c2a88be383c96b" sha256 cellar: :any, sonoma: "c69e657fb36b7ebee76f70853ae5c6e7542a590fee7317643360f688d946b10e" sha256 cellar: :any_skip_relocation, arm64_linux: "f36d1b2d5a35bb6d16a8e59bd9d01398b73406f6114a648089c11b5d680b5234" sha256 cellar: :any_skip_relocation, x86_64_linux: "749a021fac69c4fdd6105cf95347e1ff3ace29bb7bb6d5fa94c5a92de1f51451" end depends_on "cmake" => :build depends_on "pkgconf" => [:build, :test] depends_on "glib" depends_on "libsndfile" depends_on "portaudio" depends_on "readline" on_macos do depends_on "gettext" end on_linux do depends_on "alsa-lib" depends_on "jack" depends_on "systemd" end def install args = %W[ -Denable-alsa=#{OS.linux?} -Denable-aufile=ON -Denable-coverage=OFF -Denable-coreaudio=#{OS.mac?} -Denable-coremidi=#{OS.mac?} -Denable-dart=OFF -Denable-dbus=OFF -Denable-dsound=OFF -Denable-floats=OFF -Denable-fpe-check=OFF -Denable-framework=OFF -Denable-ipv6=ON -Denable-jack=#{OS.linux?} -Denable-ladspa=OFF -Denable-lash=OFF -Denable-libinstpatch=OFF -Denable-libsndfile=ON -Denable-midishare=OFF -Denable-network=ON -Denable-opensles=OFF -Denable-oboe=OFF -Denable-openmp=OFF -Denable-oss=OFF -Denable-pipewire=OFF -Denable-portaudio=ON -Denable-profiling=OFF -Denable-pulseaudio=OFF -Denable-readline=ON -Denable-sdl2=OFF -Denable-systemd=#{OS.linux?} -Denable-trap-on-fpe=OFF -Denable-threads=ON -Denable-ubsan=OFF -Denable-wasapi=OFF -Denable-waveout=OFF -Denable-winmidi=OFF ] system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args # On macOS, readline is keg-only so use the absolute path to its pc file # uses_from_macos "readline" produces another error # Related error: Package 'readline', required by 'fluidsynth', not found if OS.mac? inreplace "build/fluidsynth.pc", "readline", "#{Formula["readline"].opt_lib}/pkgconfig/readline.pc" end system "cmake", "--build", "build" system "cmake", "--install", "build" pkgshare.install "sf2" system "cmake", "-S", ".", "-B", "static", *args, *std_cmake_args, "-DBUILD_SHARED_LIBS=OFF" system "cmake", "--build", "static" lib.install "static/src/libfluidsynth.a" end test do resource "homebrew-test" do url "https://upload.wikimedia.org/wikipedia/commons/6/61/Drum_sample.mid" sha256 "a1259360c48adc81f2c5b822f221044595632bd1a76302db1f9d983c44f45a30" end # Synthesize wav file from example midi resource("homebrew-test").stage testpath wavout = testpath/"Drum_sample.wav" system bin/"fluidsynth", "-F", wavout, pkgshare/"sf2/VintageDreamsWaves-v2.sf2", testpath/"Drum_sample.mid" assert_path_exists wavout # Check the pkg-config module ENV.append_path "PKG_CONFIG_PATH", Formula["systemd"].lib/"pkgconfig" if OS.linux? system "pkgconf", "--cflags", "--libs", "--static", lib/"pkgconfig/fluidsynth.pc" end end