Skip to content

Commit

Permalink
bespokesynth: Modernise, 1.2.1 -> 1.3.0 (#367767)
Browse files Browse the repository at this point in the history
  • Loading branch information
OPNA2608 authored Jan 24, 2025
2 parents f09cc49 + 450fcb5 commit 99317f1
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp b/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp
index 4cce7016f..25554a7cd 100644
--- a/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp
+++ b/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp
@@ -291,7 +291,6 @@ public:
juce::jack_on_info_shutdown (client, infoShutdownCallback, this);
juce::jack_set_xrun_callback (client, xrunCallback, this);
juce::jack_activate (client);
- deviceIsOpen = true;

if (! inputChannels.isZero())
{
@@ -336,6 +335,7 @@ public:
}

updateActivePorts();
+ deviceIsOpen = true;

return lastError;
}
@@ -525,7 +525,8 @@ private:
static void portConnectCallback (jack_port_id_t, jack_port_id_t, int, void* arg)
{
if (JackAudioIODevice* device = static_cast<JackAudioIODevice*> (arg))
- device->mainThreadDispatcher.updateActivePorts();
+ if (device->isOpen())
+ device->mainThreadDispatcher.updateActivePorts();
}

static void threadInitCallback (void* /* callbackArgument */)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
stdenv,
fetchFromGitHub,
fetchzip,
gitUpdater,
apple-sdk_11,
cmake,
pkg-config,
ninja,
Expand All @@ -11,6 +13,7 @@
alsa-lib,
alsa-tools,
freetype,
jsoncpp,
libusb1,
libX11,
libXrandr,
Expand All @@ -31,13 +34,6 @@
pcre,
mount,
zenity,
Accelerate,
Cocoa,
WebKit,
CoreServices,
CoreAudioKit,
IOBluetooth,
MetalKit,
# It is not allowed to distribute binaries with the VST2 SDK plugin without a license
# (the author of Bespoke has such a licence but not Nix). VST3 should work out of the box.
# Read more in https://github.com/NixOS/nixpkgs/issues/145607
Expand All @@ -58,32 +54,64 @@ let
};

in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "bespokesynth";
version = "1.2.1";
version = "1.3.0";

src = fetchFromGitHub {
owner = "BespokeSynth";
repo = pname;
rev = "v${version}";
hash = "sha256-vDvNm9sW9BfWloB0CA+JHTp/bfDWAP/T0hDXjoMZ3X4=";
repo = "bespokesynth";
rev = "v${finalAttrs.version}";
hash = "sha256-ad8wdLos3jM0gRMpcfRKeaiUxJsPGqWd/7XeDz87ToQ=";
fetchSubmodules = true;
};

patches = [
# Fix compatibility with pipewire's JACK emulation
# https://github.com/BespokeSynth/BespokeSynth/issues/1405#issuecomment-1721437868
./2001-bespokesynth-fix-pipewire-jack.patch
];

# Linux builds are sandboxed properly, this always returns "localhost" there.
# Darwin builds doesn't have the same amount of sandboxing by default, and the builder's hostname is returned.
# In case this ever gets embedded into VersionInfoBld.cpp, hardcode it to the Linux value
postPatch = ''
substituteInPlace Source/cmake/versiontools.cmake \
--replace-fail 'cmake_host_system_information(RESULT BESPOKE_BUILD_FQDN QUERY FQDN)' 'set(BESPOKE_BUILD_FQDN "localhost")'
'';

cmakeBuildType = "Release";

cmakeFlags = lib.optionals enableVST2 [ "-DBESPOKE_VST2_SDK_LOCATION=${vst-sdk}/VST2_SDK" ];
cmakeFlags =
[
(lib.cmakeBool "BESPOKE_SYSTEM_PYBIND11" true)
(lib.cmakeBool "BESPOKE_SYSTEM_JSONCPP" true)
]
++ lib.optionals enableVST2 [
(lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst-sdk}/VST2_SDK")
];

strictDeps = true;

nativeBuildInputs = [
python3
python3 # interpreter
makeWrapper
cmake
pkg-config
ninja
];

buildInputs =
lib.optionals stdenv.hostPlatform.isLinux [
[
jsoncpp
# library & headers
(python3.withPackages (
ps: with ps; [
pybind11
]
))
]
++ lib.optionals stdenv.hostPlatform.isLinux [
# List obtained from https://github.com/BespokeSynth/BespokeSynth/blob/main/azure-pipelines.yml
libX11
libXrandr
Expand All @@ -110,25 +138,14 @@ stdenv.mkDerivation rec {
mount
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
Accelerate
Cocoa
WebKit
CoreServices
CoreAudioKit
IOBluetooth
MetalKit
apple-sdk_11
];

env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin (toString [
# Fails to find fp.h on its own
"-isystem ${CoreServices}/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/CarbonCore.framework/Versions/Current/Headers/"
]);

postInstall =
if stdenv.hostPlatform.isDarwin then
''
mkdir -p $out/{Applications,bin}
mv Source/BespokeSynth_artefacts/${cmakeBuildType}/BespokeSynth.app $out/Applications/
mv Source/BespokeSynth_artefacts/${finalAttrs.cmakeBuildType}/BespokeSynth.app $out/Applications/
# Symlinking confuses the resource finding about the actual location of the binary
# Resources are looked up relative to the executed file's location
makeWrapper $out/{Applications/BespokeSynth.app/Contents/MacOS,bin}/BespokeSynth
Expand Down Expand Up @@ -158,24 +175,29 @@ stdenv.mkDerivation rec {
libXScrnSaver
])
}";

dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath

meta = with lib; {
passthru.updateScript = gitUpdater {
rev-prefix = "v";
};

meta = {
description = "Software modular synth with controllers support, scripting and VST";
homepage = "https://www.bespokesynth.com/";
license =
with licenses;
with lib.licenses;
[
gpl3Plus
]
++ lib.optional enableVST2 unfree;
maintainers = with maintainers; [
maintainers = with lib.maintainers; [
astro
tobiasBora
OPNA2608
PowerUser64
];
mainProgram = "BespokeSynth";
platforms = platforms.all;
platforms = lib.platforms.all;
};
}
})
4 changes: 0 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12997,10 +12997,6 @@ with pkgs;

barrier = libsForQt5.callPackage ../applications/misc/barrier { };

bespokesynth = darwin.apple_sdk_11_0.callPackage ../applications/audio/bespokesynth {
inherit (darwin.apple_sdk_11_0.frameworks) Accelerate Cocoa WebKit CoreServices CoreAudioKit IOBluetooth MetalKit;
};

bespokesynth-with-vst2 = bespokesynth.override {
enableVST2 = true;
};
Expand Down

0 comments on commit 99317f1

Please sign in to comment.