diff --git a/PlayWallNative/libNativeAudio.dylib b/PlayWallNative/libNativeAudio.dylib new file mode 100644 index 0000000000000000000000000000000000000000..5d34a877a4081659539f91224ba8a58850a20af9 Binary files /dev/null and b/PlayWallNative/libNativeAudio.dylib differ diff --git a/PlayWallNative/src/de/tobias/playpad/Waveform.java b/PlayWallNative/src/de/tobias/playpad/Waveform.java new file mode 100644 index 0000000000000000000000000000000000000000..16cd9ee899a2f98f81f050b851adfaaa94451422 --- /dev/null +++ b/PlayWallNative/src/de/tobias/playpad/Waveform.java @@ -0,0 +1,26 @@ +package de.tobias.playpad; + +public class Waveform { + + public static native void initialize(); + + public static native void createWaveform(String path); + + private static WaveformDelegate delegate; + + private static void sampleProcessed(float[] data) { + if (delegate != null) { + delegate.sampleProcessed(data); + } + } + + public static void setDelegate(WaveformDelegate delegate) { + Waveform.delegate = delegate; + } + + public interface WaveformDelegate { + + public void sampleProcessed(float[] data); + + } +} diff --git a/PlayWallNative/src/de_tobias_playpad_Waveform.h b/PlayWallNative/src/de_tobias_playpad_Waveform.h new file mode 100644 index 0000000000000000000000000000000000000000..9d0e45dcb853ff654b6c6e50ca73a8d9fc6ac183 --- /dev/null +++ b/PlayWallNative/src/de_tobias_playpad_Waveform.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class de_tobias_playpad_Waveform */ + +#ifndef _Included_de_tobias_playpad_Waveform +#define _Included_de_tobias_playpad_Waveform +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: de_tobias_playpad_Waveform + * Method: initialize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_Waveform_initialize + (JNIEnv *, jclass); + +/* + * Class: de_tobias_playpad_Waveform + * Method: createWaveform + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_Waveform_createWaveform + (JNIEnv *, jclass, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/PlayWallNative/test/de/tobias/playpad/WaveformTest.java b/PlayWallNative/test/de/tobias/playpad/WaveformTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a958018418620114b5decae89f01df3f2d8df40f --- /dev/null +++ b/PlayWallNative/test/de/tobias/playpad/WaveformTest.java @@ -0,0 +1,37 @@ +package de.tobias.playpad; + +import de.tobias.playpad.Waveform.WaveformDelegate; + +public class WaveformTest implements WaveformDelegate { + + public static void main(String[] args) { + System.load("/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWallNative/libNativeAudio.dylib"); + + new WaveformTest(); + } + + public WaveformTest() { + Waveform.initialize(); + Waveform.setDelegate(this); + Waveform.createWaveform("/Users/tobias/Downloads/Short.mp3"); + + synchronized (this) { + try { + wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + @Override + public void sampleProcessed(float[] data) { + System.out.println(data.length); + for (int i = 0; i < data.length; i++) { + System.out.println(data[i]); + } + synchronized (this) { + notify(); + } + } +}