Skip to content

Commit

Permalink
Gradle and zig builds
Browse files Browse the repository at this point in the history
  • Loading branch information
JorenSix committed Jan 13, 2023
1 parent 4e1a250 commit 2beddca
Show file tree
Hide file tree
Showing 116 changed files with 6,011 additions and 3,117 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ bin

*.DS_Store

.classpath
.project
.settings/
build/

*.o
Binary file not shown.
Empty file.
Binary file added .gradle/7.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file added .gradle/7.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/7.2/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/7.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/7.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/7.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file added .gradle/7.2/gc.properties
Empty file.
Binary file added .gradle/7.6/checksums/checksums.lock
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added .gradle/7.6/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/7.6/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/7.6/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/7.6/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/7.6/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file added .gradle/7.6/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Fri Jan 13 21:06:59 CET 2023
gradle.version=7.6
Binary file added .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file added .gradle/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/file-system.probe
Binary file not shown.
Empty file added .gradle/vcs-1/gc.properties
Empty file.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# JGaborator - High resolution spectral transforms from Java

This library calculates fine grained constant-Q spectral representations of audio signals quickly from Java. The spectral transform can be visualized or further processed in a (Music Information Retrieval) processing chain.
This library calculates fine-grained constant-Q spectral representations of audio signals quickly from Java. The spectral transform can be visualized or further processed in a (Music Information Retrieval) processing chain.

The calculation of a [Gabor transform](https://en.wikipedia.org/wiki/Gabor_transform) is done by a C++ library named [Gaborator](http://gaborator.com). A Java native interface (JNI) bridge to the C++ Gaborator is provided here. A combination of Gaborator and a fast FFT library (such as [pfft](https://bitbucket.org/jpommier/pffft)) allows fine grained constant-Q transforms at a rate of about 200 times real-time on moderate hardware.

For more information on the Gaborator C++ library by Andreas Gustafsson, please see the [gaborator.com](http://gaborator.com) website or a talk by the author on the library called [Exploring time-frequency space with the Gaborator](https://www.youtube.com/watch?v=ONJVJBmFiuE)

While the gaborator allows reversible transforms, only a forward transform (from time domain to the spectral domain) is currently supported by JGaborator.

A spectral visualization tool for sprectral information is part of this package. See below for a screenshot:
A spectral visualization tool for spectral information is part of this package. See below for a screenshot:

![JGaborator](build/jgaborator.png "A screenshot of JGaborator in action.")
![JGaborator](media/jgaborator.png "A screenshot of JGaborator in action.")

## Using JGaborator

Expand Down Expand Up @@ -42,10 +42,9 @@ List<float[]> coefficients = zsazsa.getCoefficents()

* `src` contains the java source files
* `gaborator` contains the C++ JNI bridge and a makefile
* `gaborator\gaborator-1.2` The gaborator C++ library, licensed under AGPL
* `gaborator\pfft` the pfft C++ library, licensed under a BSD type license
* `build` ant build files
* `lib` a Java dependency: the TarsosDSP audio processing library.
* `gaborator\gaborator-1.x` The gaborator C++ library, licensed under AGPL
* `gaborator\pffft` the pffft c-library, licensed under a BSD type license
* `media`


## Compilation and development for JGaborator
Expand Down Expand Up @@ -78,7 +77,7 @@ The makefile contains similar instructions.
On macOS the Apple's vDSP library can be used by defining GABORATOR_USE_VDSP and linking with the Accelerate framework. The following should suffice:

~~~~~~~~
c++ -std=c++11 -I"gaborator-1.2" -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/darwin" -O3 -ffast-math -DGABORATOR_USE_VDSP -o libjgaborator.so jgaborator.cc -framework Accelerate
c++ -std=c++11 -I"gaborator-1.7" -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/darwin" -O3 -ffast-math -DGABORATOR_USE_VDSP -o libjgaborator.so jgaborator.cc -framework Accelerate
~~~~~~~~

The makefile contains similar instructions. To compile the mac version call `make mac` If the JAVA_HOME environment variable is not set, run the following before calling `c++`:
Expand Down
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

group 'be.ugent.jgaborator'
version '0.7'

repositories {
maven {
name = "TarsosDSP repository"
url = "https://mvn.0110.be/releases"
}
}

dependencies {
implementation 'be.tarsos.dsp:core:2.5'
implementation 'be.tarsos.dsp:jvm:2.5'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
useJUnitPlatform()
}
Binary file removed build/precompiled/aarch64_libjgaborator.dylib
Binary file not shown.
Binary file removed build/precompiled/libjgaborator.so
Binary file not shown.
27 changes: 22 additions & 5 deletions gaborator/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@


JNI_INCLUDES=-I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/darwin" -I"$(JAVA_HOME)/include/linux" -I"$(JAVA_HOME)/include/win32" -I"$(JAVA_HOME)/include/win64"


all:
# Performance can be significantly improved by using a faster FFT library.
# On macOS, you can use the FFT from Apple's vDSP library by defining GABORATOR_USE_VDSP and linking with the Accelerate framework
# On Linux and NetBSD, you can use the PFFFT (Pretty Fast FFT) library which is what is done below:
cc -c -O3 -ffast-math -fPIC pffft/pffft.c -o pffft/pffft.o
cc -c -O3 -ffast-math -fPIC -DFFTPACK_DOUBLE_PRECISION pffft/fftpack.c -o pffft/fftpack.o
c++ -std=c++11 -I"gaborator-1.2" -I"pffft" -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/linux" -fPIC -shared -O3 -ffast-math -DGABORATOR_USE_PFFFT -o ../build/precompiled/libjgaborator.so jgaborator.cc pffft/pffft.o pffft/fftpack.o
c++ -std=c++11 -I"gaborator-1.7" -I"pffft" $(JNI_INCLUDES) -fPIC -shared -O3 -ffast-math -DGABORATOR_USE_PFFFT -o ../build/precompiled/libjgaborator.so jgaborator.cc pffft/pffft.o pffft/fftpack.o

mac:
c++ -std=c++11 -I"gaborator-1.2" -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/darwin" -O3 -ffast-math -DGABORATOR_USE_VDSP -o ../build/precompiled/libjgaborator.dylib jgaborator.cc -framework Accelerate
c++ -std=c++11 -I"gaborator-1.7" $(JNI_INCLUDES) -O3 -ffast-math -DGABORATOR_USE_VDSP -o ../build/precompiled/libjgaborator.dylib jgaborator.cc -framework Accelerate

mac_dummy:
c++ -std=c++11 -I"gaborator-1.2" -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/darwin" -O3 -ffast-math -DGABORATOR_USE_VDSP -o ../build/precompiled/libjgaborator.dylib jgaborator_dummy.cc -framework Accelerate
c++ -std=c++11 -I"gaborator-1.7" $(JNI_INCLUDES) -O3 -ffast-math -DGABORATOR_USE_VDSP -o ../build/precompiled/libjgaborator.dylib jgaborator_dummy.cc -framework Accelerate

clean:
rm *.so *.class pfft/*o

zig_windows_example:
echo $(JNI_INCLUDES)
zig cc -target x86_64-windows-gnu -c -O3 -ffast-math -fPIC pffft/pffft.c -o pffft/pffft.o
zig cc -target x86_64-windows-gnu -c -O3 -ffast-math -fPIC -DFFTPACK_DOUBLE_PRECISION pffft/fftpack.c -o pffft/fftpack.o
zig c++ -target x86_64-windows-gnu -I"pffft" -I"gaborator-1.7" $(JNI_INCLUDES) -O3 -ffast-math -DGABORATOR_USE_PFFFT -o libjgaborator.dll jgaborator.cc pffft/pffft.o pffft/fftpack.o

zig:
zig cc -target $(ZIG_TARGET_PLATFORM) -c -O3 -ffast-math -fPIC pffft/pffft.c -o pffft/pffft.o
zig cc -target $(ZIG_TARGET_PLATFORM) -c -O3 -ffast-math -fPIC -DFFTPACK_DOUBLE_PRECISION pffft/fftpack.c -o pffft/fftpack.o
zig c++ -target $(ZIG_TARGET_PLATFORM) -I"pffft" -I"gaborator-1.7" $(JNI_INCLUDES) -O3 -ffast-math -DGABORATOR_USE_PFFFT -o $(ZIG_OUTPUT_FILE) jgaborator.cc pffft/pffft.o pffft/fftpack.o



clean:
rm *.so *.class
34 changes: 0 additions & 34 deletions gaborator/gaborator-1.2/CHANGES

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 2beddca

Please sign in to comment.