Skip to content

Commit

Permalink
pkgs(audio/neuralnote): init
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnvgr committed Feb 3, 2024
1 parent 49101b8 commit 67b0cba
Show file tree
Hide file tree
Showing 7 changed files with 504 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
### Audio

- [reaper-sws-extension](https://www.sws-extension.org/)
- [neuralnote](https://github.com/DamRsn/NeuralNote)

### Overrides

Expand Down
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ in rec {
# Audio

reaper-sws-extension = p ./pkgs/audio/reaper-sws-extension { };
neuralnote = p ./pkgs/audio/neuralnote { };

# some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { };
# ...
Expand Down
115 changes: 115 additions & 0 deletions pkgs/audio/neuralnote/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Thanks to @polygon!
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
, alsa-lib
, freetype
, webkitgtk
, curl
, fftwFloat
, jack2
, xorg
, pcre2
, pcre
, libuuid
, libselinux
, libsepol
, libthai
, libdatrie
, libxkbcommon
, libepoxy
, libsysprof-capture
, sqlite
, libpsl
, callPackage
}:
let
buildType = "Release";
libonnxruntime-neuralnote = callPackage ./libonnxruntime-neuralnote.nix;
in
stdenv.mkDerivation rec {
pname = "NeuralNote";
version = "162e2c93083358c9e3e4c0bd9ff4f4016ead2c32";

src = fetchFromGitHub {
owner = "polygon";
repo = pname;
rev = version;
sha256 = "sha256-iMjD4evVmM6yo3g0k5Apfm1AhikL5G+WpoCIafDpy5o=";
fetchSubmodules = true;
};

nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
freetype
alsa-lib
webkitgtk
curl
fftwFloat
jack2
xorg.libX11
xorg.libXext
xorg.libXinerama
xorg.xrandr
xorg.libXcursor
xorg.libXfixes
xorg.libXrender
xorg.libXScrnSaver
];

# JUCE dlopens these, make sure they are in rpath
# Otherwise, segfault will happen
NIX_LDFLAGS = (toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
]);

# Needed for LTO to work, currently unsure as to why
cmakeFlags = [
"-DCMAKE_AR=${stdenv.cc.cc}/bin/gcc-ar"
"-DCMAKE_RANLIB=${stdenv.cc.cc}/bin/gcc-ranlib"
"-DCMAKE_NM=${stdenv.cc.cc}/bin/gcc-nm"
];

postPatch = ''
sed -i -e 's/if (canDrop)/if (1)/' ThirdParty/JUCE/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp
cd ThirdParty
rm -rf onnxruntime || true
mkdir onnxruntime
cd onnxruntime
tar xf ${libonnxruntime-neuralnote}/libonnxruntime-neuralnote.tar.gz
mv model.with_runtime_opt.ort ../../Lib/ModelData/features_model.ort
cd ../..
'';

cmakeBuildType = buildType;

installPhase =
let
vst3path = "${placeholder "out"}/lib/vst3";
binpath = "${placeholder "out"}/bin";
in
''
runHook preInstall
mkdir -p ${vst3path}
mkdir -p ${binpath}
cp -R NeuralNote_artefacts/${buildType}/VST3/* ${vst3path}
cp -R NeuralNote_artefacts/${buildType}/Standalone/* ${binpath}
runHook postInstall
'';

meta = with lib; {
description = "Audio Plugin for Audio to MIDI transcription using deep learning";
homepage = "https://github.com/DamRsn/NeuralNote";
license = licenses.asl20;
platforms = platforms.linux;
};
}
Loading

0 comments on commit 67b0cba

Please sign in to comment.