8000 chumpify fluidsynth by nshaheed · Pull Request #101 · ccrma/chugins · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chumpify fluidsynth #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
2 changes: 2 additions & 0 deletions FluidSynth/FluidSynth-play.ck
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "FluidSynth"

NRev rev => dac;
0.01 => rev.mix;

Expand Down
2 changes: 2 additions & 0 deletions FluidSynth/FluidSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ CK_DLL_QUERY( fluidsynth )
// begin the class definition
QUERY->begin_class(QUERY, "FluidSynth", "UGen");

QUERY->doc_class(QUERY, "A chugin to load and use FluidSynth soundfonts");

QUERY->add_ctor(QUERY, fluidsynth_ctor);
QUERY->add_dtor(QUERY, fluidsynth_dtor);

Expand Down
14 changes: 14 additions & 0 deletions FluidSynth/FluidSynth.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
75 changes: 75 additions & 0 deletions FluidSynth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# FluidSynth

A chugin for loading [FluidSynth soundfonts](https://en.wikipedia.org/wiki/FluidSynth).

## Building the chump package

If you're building `FluidSynth` for your own use, you can just call `make mac/win/linux/etc`. These instructions are specific to building `FluidSynth.chug` to be packages with chump.

### Mac

Note: Currenty the `meson.build` does not work as a cross-platform
build, so you will need to build the arm64 and x86_64 versions of the
`FluidSynth.chug` on their respective machines before making a
universal binary.

The mac build process is a little involved due to the need to make a
universal binary, codesigning, and notarization. It requires and
apple developer account to do all this.

First, compile FluidSynth. This requires meson:

```make build-mac-x86_64 # must be done on an intel machine```
```make build-mac-arm64 # must be done on an M-series mac```

Next, we being the codesigning process.

```sh chump_build_mac/1-codesign.sh```

The next step is to take the chugin, and related files and created a new package
for chump (be sure to change the version number!
```sh chump_build_mac/2-chumpinate.sh```

Finally, we notarize the outputted `FluidSynth_mac.zip`:
``` sh chump_build_mac/3-notarize.sh```

Afterwards, we upload this to ccrma servers:
```
ssh nshaheed@ccrma-gate.stanford.edu \"mkdir -p ~/Library/Web/chugins/FluidSynth/<verno>/mac/
scp FluidSynth_mac.zip nshaheed@ccrma-gate.stanford.edu:~/Library/Web/chugins/FluidSynth/<verno>/mac
```

And then we add this new version definition to the chump manifest repo:
```
cp -r FluidSynth/ <path_to_chump_packages_repo>
```

### Windows

Note: this requires `meson` to build `FluidSynth` as a chump package.

First, setup your build directory:

```meson setup --buildtype=release builddir-release --backend vs```

Next, we build the chugin:

```meson compile -C builddir-release```

After this, we create a chump package:

```chuck build-pkg-win.ck```

Afterwards, we upload this to ccrma servers:
```
ssh nshaheed@ccrma-gate.stanford.edu \"mkdir -p ~/Library/Web/chugins/FluidSynth/<verno>/win/
scp FluidSynth_win.zip nshaheed@ccrma-gate.stanford.edu:~/Library/Web/chugins/FluidSynth/<verno>/win
```

And then we add this new version definition to the chump manifest repo:
```
cp -r FluidSynth/ <path_to_chump_packages_repo>
```


### Linux
64 changes: 64 additions & 0 deletions FluidSynth/build-pkg-mac.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@import "Chumpinate"

// Our package version
"1.0.0" => string version;

<<< "Generating FluidSynth package release " >>>;

// instantiate a Chumpinate package
Package pkg("FluidSynth");

// Add our metadata...
"Spencer Salazar" => pkg.authors;

"https://github.com/ccrma/chugins" => pkg.homepage;
"https://github.com/ccrma/chugins" => pkg.repository;

"MIT" => pkg.license;
"Chugin for loading FluidSynth soundfonts" => pkg.description;

["midi", "FluidSynth", "UGen"] => pkg.keywords;

// generate a package-definition.json
// This will be stored in "Chumpinate/package.json"
"./" => pkg.generatePackageDefinition;

<<< "Defining version " + version >>>;;

// Now we need to define a specific PackageVersion for test-pkg
PackageVersion ver("FluidSynth", version);

"10.2" => ver.apiVersion;

"1.5.4.0" => ver.languageVersionMin;

"mac" => ver.os;
"universal" => ver.arch;

// The chugin file
ver.addFile("./FluidSynth.chug");

// These build files are examples as well
ver.addExampleFile("FluidSynth-play.ck");
ver.addExampleFile("fluidsynth-help.ck");
ver.addExampleFile("fluidsynth-pitchbend.ck");
ver.addExampleFile("fluidsynth-tuning.ck");
ver.addExampleFile("fluidsynth-test.ck");
ver.addExampleFile("HS_African_Percussion.sf2");

// The version path
"chugins/FluidSynth/" + ver.version() + "/" + ver.os() + "/FluidSynth.zip" => string path;

<<< path >>>;

// wrap up all our files into a zip file, and tell Chumpinate what URL
// this zip file will be located at.
ver.generateVersion("./", "FluidSynth_mac", "https://ccrma.stanford.edu/~nshaheed/" + path);

chout <= "After notarizing, use the following commands to upload the package to CCRMA's servers:" <= IO.newline();
chout <= "ssh nshaheed@ccrma-gate.stanford.edu \"mkdir -p ~/Library/Web/chugins/FluidSynth/"
<= ver.version() <= "/" <= ver.os() <= "\"" <= IO.newline();
chout <= "scp FluidSynth_mac.zip nshaheed@ccrma-gate.stanford.edu:~/Library/Web/" <= path <= IO.newline();

// Generate a version definition json file, stores this in "chumpinate/<VerNo>/FluidSynth_mac.json"
ver.generateVersionDefinition("FluidSynth_mac", "./" );
64 changes: 64 additions & 0 deletions FluidSynth/build-pkg-win.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@import "Chumpinate"

// Our package version
"1.0.0" => string version;

<<< "Generating FluidSynth package release " >>>;

// instantiate a Chumpinate package
Package pkg("FluidSynth");

// Add our metadata...
"Spencer Salazar" => pkg.authors;

"https://github.com/ccrma/chugins" => pkg.homepage;
"https://github.com/ccrma/chugins" => pkg.repository;

"MIT" => pkg.license;
"Chugin for loading FluidSynth soundfonts" => pkg.description;

["midi", "FluidSynth", "UGen"] => pkg.keywords;

// generate a package-definition.json
// This will be stored in "Chumpinate/package.json"
"./" => pkg.generatePackageDefinition;

<<< "Defining version " + version >>>;;

// Now we need to define a specific PackageVersion for test-pkg
PackageVersion ver("FluidSynth", version);

"10.2" => ver.apiVersion;

"1.5.4.0" => ver.languageVersionMin;

"win" => ver.os;
"x86_64" => ver.arch;

// The chugin file
ver.addFile("./builddir-release/FluidSynth.chug");

// These build files are examples as well
ver.addExampleFile("FluidSynth-play.ck");
ver.addExampleFile("fluidsynth-help.ck");
ver.addExampleFile("fluidsynth-pitchbend.ck");
ver.addExampleFile("fluidsynth-tuning.ck&quo F438 t;);
ver.addExampleFile("fluidsynth-test.ck");
ver.addExampleFile("HS_African_Percussion.sf2");

// The version path
"chugins/FluidSynth/" + ver.version() + "/" + ver.os() + "/FluidSynth.zip" => string path;

<<< path >>>;

// wrap up all our files into a zip file, and tell Chumpinate what URL
// this zip file will be located at.
ver.generateVersion("./", "FluidSynth_win", "https://ccrma.stanford.edu/~nshaheed/" + path);

chout <= "After notarizing, use the following commands to upload the package to CCRMA's servers:" <= IO.newline();
chout <= "ssh nshaheed@ccrma-gate.stanford.edu \"mkdir -p ~/Library/Web/chugins/FluidSynth/"
<= ver.version() <= "/" <= ver.os() <= "\"" <= IO.newline();
chout <= "scp FluidSynth_win.zip nshaheed@ccrma-gate.stanford.edu:~/Library/Web/" <= path <= IO.newline();

// Generate a version definition json file, stores this in "chumpinate/<VerNo>/Chumpinate_win.json"
ver.generateVersionDefinition("FluidSynth_win", "./" );
21 changes: 21 additions & 0 deletions FluidSynth/chump_build_mac/1-codesign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#--------------------------------------------------------------
# codesign.sh
# pre-condition: both arm64 and intel FluidSynth.chug builds
# are located in the proper directories
#--------------------------------------------------------------

# where the FluidSynth build can be found
FLUIDSYNTH_ARM=./FluidSynth-arm64.chug
FLUIDSYNTH_INTEL=./FluidSynth-x86_64.chug
FLUIDSYNTH_UB=./FluidSynth.chug

# remove code signature from chugin and dylibs
codesign --remove-signature ${FLUIDSYNTH_ARM}
codesign --remove-signature ${FLUIDSYNTH_INTEL}

# codesign FluidSynth.chug
codesign --deep --force --verify --verbose --timestamp --options runtime --entitlements FluidSynth.entitlements --sign "Developer ID Application" ${FLUIDSYNTH_ARM}
codesign --deep --force --verify --verbose --timestamp --options runtime --entitlements FluidSynth.entitlements --sign "Developer ID Application" ${FLUIDSYNTH_INTEL}


lipo -create -output ${FLUIDSYNTH_UB} ${FLUIDSYNTH_ARM} ${FLUIDSYNTH_INTEL}
5 changes: 5 additions & 0 deletions FluidSynth/chump_build_mac/2-chumpinate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#--------------------------------------------------------------
# chumpinate.sh
# pre-condition: universal FluidSynth.chug codesigned
#--------------------------------------------------------------
chuck -s build-pkg-mac.ck
18 changes: 18 additions & 0 deletions FluidSynth/chump_build_mac/3-notarize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#--------------------------------------------------------------
# notarize.sh
# pre-condition: codesigned, packaged, also developer
# credentials are loaded into the environment
# post-condition: notarizes the chump package
#--------------------------------------------------------------

# dir location of this bash script
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo ${SCRIPT_DIR}

# where the FluidSynth build can be found
FLUIDSYNTH=./FluidSynth_mac.zip


echo "notarizing FluidSynth.chug..."
${SCRIPT_DIR}/notarize.sh ${FLUIDSYNTH}
13 changes: 13 additions & 0 deletions FluidSynth/chump_build_mac/notarize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

echo xcrun notarytool submit "$1" \
--key "$NOTARIZATION_KEY" \
--key-id "$NOTARIZATION_KEY_ID" \
--issuer "$NOTARIZATION_ISSUER" \
--wait

xcrun notarytool submit "$1" \
--key "$NOTARIZATION_KEY" \
--key-id "$NOTARIZATION_KEY_ID" \
--issuer "$NOTARIZATION_ISSUER" \
--wait
20 changes: 20 additions & 0 deletions FluidSynth/cross/arm64-macos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[binaries]
c = ['clang']
cpp = ['clang++']
objc = ['clang']
objcpp = ['clang++']
ar = ['ar']
strip = ['strip']
pkg-config = ['pkg-config']

[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'

[built-in options]
c_args = ['-arch', 'arm64']
cpp_args = ['-arch', 'arm64']
c_link_args = ['-arch', 'arm64']
cpp_link_args = ['-arch', 'arm64']
20 changes: 20 additions & 0 deletions FluidSynth/cross/x86_64-macos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[binaries]
c = ['clang']
cpp = ['clang++']
objc = ['clang']
objcpp = ['clang++']
ar = ['ar']
strip = ['strip']
pkg-config = ['pkg-config']

[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

[built-in options]
c_args = ['-arch', 'x86_64']
cpp_args = ['-arch', 'x86_64']
c_link_args = ['-arch', 'x86_64']
cpp_link_args = ['-arch', 'x86_64']
7 changes: 6 additions & 1 deletion FluidSynth/fluidsynth-help.ck
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
FluidSynth foo => dac;
@import "FluidSynth.chug"

<<< "???" >>>;
FluidSynth foo => Gain g => dac;
1::second => now;
<<< "done" >>>;
2 changes: 2 additions & 0 deletions FluidSynth/fluidsynth-pitchbend.ck
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Values less than the minimum value of 0 or more than the maximum value of 16383
respectively. This ensures a small rounding error won't stop your program.
*/

@import "FluidSynth"

// Here's a function which manipulates the pitch bend in a sinusoidal manner:
fun void pitchWobble(FluidSynth f, dur duration, int cycles, int chan) {
(duration/1::samp) $ int => int sampleLength;
Expand Down
3 changes: 2 additions & 1 deletion FluidSynth/fluidsynth-test.ck
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@import "FluidSynth.chug"

// synchronize to period
0.75::second => dur T;
T - (now % T) => now;

// connect patch
FluidSynth f => NRev reverb => dac;
f.open("/usr/share/sounds/sf2/FluidR3_GM.sf2");
f.open("HS_African_Percussion.sf2");
.75 => f.gain;
0.02 => reverb.mix;

Expand Down
2 changes: 2 additions & 0 deletions F28D FluidSynth/fluidsynth-tuning.ck
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ channels are set to use this, but again, you usually shouldn't need to care.)
Forrest Cahoon (forrest.cahoon@gmail.com)
*/

@import "FluidSynth"

// set up a FluidSynth object
FluidSynth f => dac;
f.open("/usr/share/sounds/sf2/FluidR3_GM.sf2");
Expand Down
14 changes: 14 additions & 0 deletions FluidSynth/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,17 @@ install: $(CHUG)
clean:
rm -rf $(C_OBJECTS) $(CXX_OBJECTS) $(CHUG) $(WEBCHUG) Release Debug


setup-mac-x86_64:
meson setup --cross-file cross/x86_64-macos.txt builddir-x86_64

setup-mac-arm64:
meson setup --cross-file cross/arm64-macos.txt builddir-arm64

build-mac-x86_64: setup-mac-x86_64
meson compile -C builddir-x86_64
cp builddir-x86_64/FluidSynth.chug FluidSynth-x86_64.chug

build-mac-arm64: setup-mac-arm64
meson compile -C builddir-arm64
cp builddir-arm64/FluidSynth.chug FluidSynth-arm64.chug
Loading
Loading
0